Вы находитесь на странице: 1из 27

SEVEN SEGMENT LED USING 8051 DIGITICKX

AIM: To understand the basic formality of LED interface with 8051 using Digitickx. DESCRIPTION: LED displays are packages of many LEDs arranged in a pattern, the most familiar pattern being the 7-segment displays for showing numbers (digits 0-9). PROCEDURE: Open Digiticx 1.0 program development environment. Create a new project Project Name : Any Name Tool kit: Microc 8051->8052 Debugger: Digitickx 51-> C Debugger Right Click on Project Files-> Settings-> General-> Debug with: Digitickx 51 C loader Debug: Digitickx 51 C Debug Linker: asm Output: hex Write a program, save the program, compile the program, Build the program and Download.

PROGRAM: #include <8051io.h> #include <8051bit.h> #include <8051reg.h> #include "led.h" main() { delay(100); serinit(SBR_19200); while(1) { SendBuffer(ONE,SEVEN,EIGHT,THREE); delay(1000); SendBuffer(TWO,ONE,ZERO,SEVEN); delay(1000); } while(1); } RESULT: Thus the program was executed and the output was verified using Digitickx.

LCD INTERFACE USING 8051 DIGITICKX


AIM: To understand the basic formality of LCD interfaces using 8051 Digitickx. DESCRIPTION: A liquid crystal display (LCD) is a thin, flat electronic visual display that uses the light modulating properties of liquid crystals (LCs). LCs do not emit light directly.They are used in a wide range of applications including: computer monitors, television, instrument panels, aircraft cockpit displays, signage, etc. They are common in consumer devices such as video players, gaming devices, clock, watches, calculators, and telephones. LCDs have displaced cathode ray tube (CRT) displays in most applications. They are usually more compact, lightweight, portable, less expensive, more reliable, and easier on the eyes. They are available in a wider range of screen sizes than CRT and plasma displays, and since they do not use phosphors, they cannot suffer image burn-in. LCDs are more energy efficient and offer safer disposal than CRTs. Its low electrical power consumption enables it to be used in batterypowered electronic equipment. It is an electronically-modulated optical device made up of any number of pixels filled with liquid crystals and arrayed in front of a light source (backlight) or reflector to produce images in colour or monochrome. PROCEDURE: Open Digiticx 1.0 program development environment. Create a new project Project Name : Any Name Tool kit: Microc 8051->8052 Debugger: Digitickx 51-> C Debugger Right Click on Project Files-> Settings-> General-> Debug with: Digitickx 51 C loader Debug: Digitickx 51 C Debug Linker: asm Output: hex Write a program, save the program, compile the program, Build the program and Download.

PROGRAM: #include <8051io.h> #include <8051bit.h> /* Bit set/clear macros */ #include <8051reg.h> #define READ P0.1 /*READ=SET & WRITE=RESET*/ #define STROBE P0.2 /*DATA STROBE (ENABLE)*/ #define CTRL P0.0 //#define PRINT(str) (unsigned char t[]=str) void InitLCD(); void WriteCtrl( unsigned char value ); /* Declare the necessary functions */ void WriteData( unsigned char value ); void WriteCommon( unsigned char value ); void CursorHome(); void CursorSet( unsigned char pos ); main() { static unsigned char t[]="WELCOME TO TIFAC CORE ; static int k; InitLCD(); CursorHome(); k=0; while(t[k]) { if(k==20) { WriteCtrl(12); /* Write to control word */ delay(1); WriteCtrl(0); /* Move to next line */ delay(1); } WriteData(t[k]); /* Write the message character wise */ k++; } delay(2000);} void InitLCD() {

/* Wait a bit after power-up */ delay(200); WriteCtrl(3); delay(50); WriteCtrl(3); delay(10); WriteCtrl(3); delay(10); WriteCtrl(2); delay(10); WriteCtrl(2); delay(10); WriteCtrl(8); delay(10);*/ WriteCtrl(0); delay(10); WriteCtrl(8); delay(10); WriteCtrl(0); delay(10); WriteCtrl(12); delay(10); WriteCtrl(0); delay(10); WriteCtrl(4); delay(10); WriteCtrl(0); delay(10); WriteCtrl(1); delay(100); WriteCtrl(0); delay(10); WriteCtrl(2); delay(100);} void CursorSet( unsigned char pos ) { WriteCtrl(8);

delay(1); WriteCtrl(pos); delay(1); } void CursorHome() { WriteCtrl(0); delay(1); WriteCtrl(2); delay(1); } void WriteCtrl( unsigned char value ) { clrbit(CTRL); WriteCommon( value ); } void WriteData( unsigned char value ) { setbit(CTRL); WriteCommon( value >> 4 ); WriteCommon( value ); } void WriteCommon( unsigned char value ) { clrbit(READ); value = value & 0x0F; value = value << 4; P0 = P0 & 0x0F; P0 = P0 | value; setbit(STROBE); delay(1); clrbit(STROBE); setbit(READ); delay(1); }

RESULT: Thus the program was executed and the output was verified using 8051 Digitickx.

KEYPAD INTERFACE USING 8051 DIGITICKX

AIM: To understand the basic formality of keypad interface with 8051 using Digitickx. DESCRIPTION: Keypads are organized in a matrix of rows and columns. The CPU accesses both rows and column through ports; therefore, with two 8-bit ports, an 8*8 matrix of keys can be connected to a microprocessor. When a key pressed, a row and column make a connect; otherwise, there is no connection between row and column. In IBM PC keyboards, a single microcontroller (consisting of microprocessor, RAM and EPROM, and several ports all on a single chip) takes care of software and hardware interfacing of keyboard. In such systems it is the function of programs stored in the EPROM of microcontroller to scan the keys continuously, identify which one has been activated, and present it to the motherboard. In this section we look at the mechanism by which the 8051 scans and identifies the key. PROCEDURE: Open Digiticx 1.0 program development environment. Create a new project Project Name : Any Name Tool kit: Microc 8051->8052 Debugger: Digitickx 51-> C Debugger Right Click on Project Files-> Settings-> General-> Debug with: Digitickx 51 C loader Debug: Digitickx 51 C Debug Linker: asm Output: hex Write a program, save the program, compile the program, Build the program and Download.

PROGRAM: #include <8051io.h> #include <8051bit.h> #include <8051reg.h> #include "led.h" #define READ P0.1 /*READ=SET & WRITE=RESET*/ #define STROBE P0.2 /*DATA STROBE (ENABLE)*/ /* General I/O definitions */ /* Bit set/clear macros */ /* 8051 register definitions */

#define CTRL P0.0 /*CONTROL BIT (CONTROL=RESET & DATA=SET)*/ //for 7 segment data charnum[]={0x77,0x14,0xb3,0xb6,0xd4,0xe6,0xe7,0x34,0xf7,0xf6,0xf5,0xc7,0 x63,0x97,0xe3, 0xe1}; unsigned int e,f,c,d; unsigned int i; // for keypad data static char table[4][4]={'D','#','0','*', 'C','9','8','7', 'B','6','5','4', 'A','3','2','1' }; static unsigned char t[50]="jenni muthu deepa"; message to be displayed */ int k; static unsigned char r1[5]={ 0xf7,0xfb,0xfd,0xfe }; int row=0,column; void led(); /* Store

void display(unsigned int value); void lcd( ); void keypad(); void InitLCD(); void WriteCtrl( unsigned char value ); void WriteData( unsigned char value ); void WriteCommon( unsigned char value ); void CursorHome(); void CursorSet( unsigned char pos ); main() { serinit(9600); i=0; row=0; while(1) { led(); lcd(); keypad(); i++; if(i==9) { i=0;

} } }

void led() { display(i); SendBuffer(num[d],num[c],num[f],num[e]); delay(1); } void display(unsigned int val) { e=val%10; val=val/10; f=val%10; val=val/10; c=val%10; val=val/10; d=val%10; } void lcd() {

InitLCD(); /* Initialize the LCD */ CursorHome(); /* Set the location of cursor at first position*/ k=0; while(t[k]) { if(k==24) {

WriteCtrl(12); delay(1); WriteCtrl(0); delay(1); }

/* Write to control word */

/* Move to next line */

WriteData(t[k]); /* Write the message character wise */ k++; } delay(500); } void InitLCD() { /* Wait a bit after power-up */ delay(20); /* Initialize the LCD to 4-bit mode */ WriteCtrl(3); delay(50); WriteCtrl(3); delay(10); WriteCtrl(3); delay(10); WriteCtrl(2); delay(10); /*DISPLAY OFF*/ WriteCtrl(0); delay(10); WriteCtrl(8);

delay(10); /*display ON*/ WriteCtrl(0); delay(10); WriteCtrl(12); delay(10); /*entry mode*/ WriteCtrl(0); delay(10); WriteCtrl(4); delay(10); /*clear screen*/ WriteCtrl(0); delay(10); WriteCtrl(1); delay(10); /*cursor at home*/ WriteCtrl(0); delay(10); WriteCtrl(2); delay(10); } void CursorSet( unsigned char pos ) { WriteCtrl(8); delay(1); WriteCtrl(pos);

delay(1); } void CursorHome() { WriteCtrl(0); delay(1); WriteCtrl(2); delay(1); } void WriteCtrl( unsigned char value ) { clrbit(CTRL); WriteCommon( value ); } void WriteData( unsigned char value ) { setbit(CTRL); WriteCommon( value >> 4 ); WriteCommon( value ); } void WriteCommon( unsigned char value ) { clrbit(READ); value = value & 0x0F; value = value << 4; P0 = P0 & 0x0F; P0 = P0 | value;

setbit(STROBE); delay(1); clrbit(STROBE); setbit( READ); delay(1); } void keypad() { k=0; P2=0xf0;

P2=r1[row]; delay(20); if((P2 & 0xf0) != 0xf0) { if((P2 & 0xf0)==0x70) { printf("key no %c\n",table[row][0]); display(table[row][0]-48); SendBuffer(num[d],num[c],num[f],num[e]); delay(500); InitLCD(); CursorHome(); WriteData(table[row][0]); t[k]=table[row][0]; k++; t[k]='\0';

delay(3); }

else if((P2 & 0xf0)==0xb0) { printf("key no %c\n",table[row][1]); display(table[row][1]-48); SendBuffer(num[d],num[c],num[f],num[e]); delay(500); InitLCD(); CursorHome(); WriteData(table[row][1]); t[k]=table[row][1]; k++; t[k]='\0'; delay(3); } else if((P2 & 0xf0)==0xd0) { printf("key no %c\n",table[row][2]); display(table[row][2]-48); SendBuffer(num[d],num[c],num[f],num[e]); delay(500); InitLCD(); WriteData(table[row][2]); t[k]=table[row][2]; k++;

t[k]='\0'; delay(3); } else if((P2 & 0xf0)==0xe0) { printf("key no %c\n",table[row][3]); display(table[row][3]-48); SendBuffer(num[d],num[c],num[f],num[e]); delay(500); InitLCD(); CursorHome(); WriteData(table[row][3]); t[k]=table[row][3]; k++; t[k]='\0'; delay(3); } } row++; if(row==4)row=0; }

RESULT: Thus the program was executed and the output was verified using Digitickx.

TRAFFIC LIGHT INTERFACE USING 8051 DIGITICKX


AIM: To understand the basic formality of traffic light with 8051 using digitickx. DESCRIPTION: Signal lamp consists of cluster of Red, Green, and Yellow LEDs. These lamps requires current of 60mA which microcontroller doesnt capable to deliver this current, hence drivers are used. The purpose of microcontroller is to switch on the signal lamps with proper timing and to read the timer on/off switch and to dip switches for pass time delay. Led show the status of operation. By configuring jumpers, the pass time delay can be changed. In order to do all the activities a program (sequence of instruction) must be written for the microcontroller. This program is called firmware. In order to execute the program, Microcontroller requires basic configuration like 5V regulated power supply, clock, and reset circuit. Microcontroller and ICs requires 5V regulated power supply, which is obtained from 230V AC by using step down transformer , rectifier, filter and regulators. PROCEDURE: 1. Open Digiticx 1.0 program development environment. 2. Create a new project Project Name : Any Name Tool kit: Micro c 8051->8052 Debugger: Digitickx 51-> C Debugger 3.Right Click on Project Files-> Settings-> General-> Debug with: Digitickx 51 C loader Debug: Digitickx 51 C Debug Linker: asm Output: hex

4.Write a program, save the program, compile the program, Build the program and Download PROGRAM: #include <8051io.h> #include <8051bit.h> #include <8051reg.h> void portinitialize(void); void south_side(void); void west_side(void); void north_side(void); void east_side(void); void main(void) { while(1) { portinitialize(); south_side(); west_side(); north_side(); east_side(); } } void portinitialize(void) { P1=0x20; P3=0x00;

} void south_side(void) { P1=0x22; P3=0xD0; delay(10000); portinitialize(); P3=0xD2; delay(5000); portinitialize(); P3=0x70; } void west_side(void) { P1=0xA8; P3=0x70; delay(10000); portinitialize(); P3=0x78; delay(5000); portinitialize(); P3=0xE0; } void north_side(void) { P1=0x31; P3=0xE0;

delay(10000); portinitialize(); P3=0xE1; delay(5000); portinitialize(); P3=0xB0; } void east_side(void) { P1=0x64; P3=0xB0; delay(10000); portinitialize(); P3=0xB4; delay(5000); portinitialize(); P3=0xD0; }

RESULT: Thus the program was executed and the output was verified using Digitickx.

STEPPER MOTOR USING MSP 430


AIM: To understand the basic formality of stepper motor with 8051 using MSP430. DESCRIPTION: Stepper motors are electrical motor that are driven by digital pulse rather than a continuously applied voltage. Inherent in this concept is open loop control, wherein a train of pulses translates, with each revolution requiring a given number of pulses. Each pulse equals one rotary increment, or step sequence, step motors, which is only a portion of one complete rotation. Motor can be rotated in steps by giving proper excitation sequence to these windings. The lower nibble of 8051 is used to generate excitation signals in the proper sequence. PROCEDURE: 1. Open IAR workbench MSP 430 2. Go to Project-> Create new project (ASM+, C+ main) 3. Create new folder and save the corresponding file name (Desktop Folder) 4. Display the IAR main and delete the previous file. 5. Program copied and pasted it and then save it. 6. Right click of your project-> Option-> General-> Device selection-> MSP 430 2xx-> 20143 and debugger-> FET Debugger 7. Select-> Ok 8. Go to project-> Rebuild all -> Download and debug 9. Debug-> Go 10.Switch Selection:4th PIN

PROGRAM: #include "msp430x20x3.h" #include<stdio.h> void DELAY (); unsigned char data[]={0x01,0x02,0x04,0x08}; void main(void) { WDTCTL = WDTPW + WDTHOLD; P1DIR =0XFF; P2SEL=0X00; int i; do { for(i=0;i<4;i++) { P1OUT=data[i]; DELAY(2); } }while(1); } void DELAY (unsigned int d ) { unsigned int k,j; for(k=0;k<d;k++) for(j=0;j<1400;j++); } void DELAY1 (int k ) { /*do { int j; for(j=0;j<1000;j++); k--; }while(k!=0); */ } RESULT: Thus the program was executed and the output was verified using MSP430.

DC MOTOR USING MSP 430

AIM: To understand the basic formality of DC motor with 8051 using MSP430. DESCRIPTION: Embedded based DC motor speed control system using cygnal microcontroller (C8051F020) has been designed and developed. It is based on frequency domain technique. The principle is opto-coupler senses the speed of the motor in the form of TTL pulses, which is given to F/V (frequency to voltage) converter. The output of the F/V converter voltage is fed to an inbuilt 12-bit ADC of cygnal microcontroller. The converted digital value applied in Liner equitation for converting back to frequency and speed is displayed on two lines LCD in RPM. Microcontroller is applied for PID control action to correct error in the form of voltage to the motor through built-in 12-bit D/A converter, PWM circuit, and actuator. The present study discusses the design, development, fabrication, and analysis of cygnal microcontroller based PID logic controller for DC motor speed control systems. Software is developed in 'C' language using Si-Lab IDE C-cross compiler. The paper deals with the hardware and software details. Copyright 2010 IFSA. Keyword: Speed control, PID logic, Frequency to voltage converter PROCEDURE: 1. Open IAR workbench MSP 430 2. Go to Project-> Create new project (ASM+, C+ main) 3. Create new folder and save the corresponding file name (Desktop Folder) 4. Display the IAR main and delete the previous file. 5. Program copied and pasted it and then save it. 6. Right click of your project-> Option-> General-> Device selection-> MSP 430 2xx-> 20143 and debugger-> FET Debugger 7. Select-> Ok 8. Go to project-> Rebuild all -> Download and debug 9. Debug-> Go 10.Switch Selection: DC Motor 5th Pin

PROGRAM: /* INTERFACING THE DC MOTOR TO MSP430 DIP SWITCH # 5 ON */ #include<msp430x20x3.h> void delay(unsigned int); int main() { int i=0xff; WDTCTL = WDTPW + WDTHOLD; P1DIR =0xff; P1OUT = i; while(1) { delay(1000); P1OUT=~P1OUT; } } void delay(unsigned int delay) { unsigned int i,j; for(i=0;i<200;i++); for(j=delay;j>0;j--); }

RESULT: Thus the program was executed and the output was verified using MSP430.

Вам также может понравиться