Senin, 29 September 2008

Writing "Hello World" to LCD Character in the Upper Left firs Line.


In this lesson, you can try to write word " Hello World " in first line of LCD Character.

Step 1st
Build the circuit as shown in figure 2.11. As you seen on figure 2.11. P0.0 trough P0.7 is connected to DB0 - DB7,and P2.0- P2.1. is connected to RS and EN each. Remember, that all we want to do with this lesson is write " Hello World ", in the first line of LCD Character, below the schematic


Step 2nd
In this step, you must tipe the assembly program to make your LCD Character shown the word, we assume that you have already known the editor, we used RIDE-51 to edit the program.

       org 0h
start: call init_LCD
mov R1,#80h
call write_inst
mov R1,#'H'
call write_data
mov R1,#'e'
call write_data
mov R1,#'l'
call write_data
mov R1,#'l'
call write_data
mov R1,#'o'
call write_data
mov R1,#' '
call write_data
mov R1,#'W'
call write_data
mov R1,#'o'
call write_data
mov R1,#'r'
call write_data
mov R1,#'l'
call write_data
mov R1,#'d'
call write_data
EndChar:
sjmp Endchar

Init_lcd:
mov r1,#00000001b ;Display clear
acall write_inst ;
mov r1,#00111000b ;Function set,
;Data 8 bit,2 line font 5x7
acall write_inst ;
mov r1,#00001100b ;Display on,
;cursor off,cursor blink off
acall write_inst
mov r1,#00000110b ;Entry mode, Set increment
acall write_inst
ret
;
Write_inst:
clr P2.0 ; RS = P2.0 = 0, write mode instruction
mov P0,R1 ; D7 s/d D0 = P0 = R1
setb P2.1 ; EN = 1 = P2.1
call delay; call delay time
clr P2.1 ; EN = 0 = P2.1
ret
;
Write_data:
setb P2.0 ; RS = P2.0 = 1, write mode data
mov P0,R1 ; D7 s/d D0 = P0 = R1
setb P2.1 ; EN = 1 = P2.1
call delay; call delay time
clr p2.1 ; EN = 0 = P2.1
ret
;
delay: mov R0,#0
delay1:mov R7,#0fh
djnz R7,$
djnz R0,delay1
ret
;
end

Step 3rd

Safe your assembly program above, and name it with lcd1.asm (for example)
Compile the program that you have been save by using RIDE-51, see the
software instruction.
Step 4th
Download your hex file ( lcd1.hex ) into the microcontroller by using Microcontroller Laros ATMEL ISP software, see the instruction.After download this hex file you'll see the action of the 7 segmen ( of course if your cable connection and your program are corrected ).

Moving Display


In this lesson, we are going to drive 8 x7 segmen, in this way you can write eight character on multi 7 segmen. We used a multiplexing methode to transfer data for driver transistor consequtively.

Step 1st
Build the circuit as shown in figure 2.3.5. As you seen on figure 2.3.5. P2.0 trough P2.7 is connected to driver transistor, and all eight 7 segment is connected to P0.0 trough P0.6 parallelly. Remember, that all we want to do with this lesson is to write ( k-O-n-P-U-t-E-r ) to 1st, 2nd, 3rd, 4th, 5th, 6th, 7th and 8th 7 segmen each sifting the word to the left.

Step 2nd
In this step, you must tipe the assembly program to make your 7 segmen shown some number on 7 segmen, we assume that you have already known the editor, we used RIDE-51 to edit the program.

       org 0h
Begin: mov r1,#150
start1: mov dptr,#word1
mov r5,#8
mov r2,#01111111b
again1: clr A
movc A,@A+dptr
inc dptr
mov p2,A
mov A,r2
mov p3,A
rr A
mov r2,A
acall delay
mov p2,#11111111b
djnz r5,again1
djnz r1,start1
mov r1,#150
start2: mov dptr,#word2
mov r5,#8
mov r2,#01111111b
again2: clr A
movc A,@A+dptr
inc dptr
mov p2,A
mov A,r2
mov p3,A
rr A
mov r2,A
acall delay
mov p2,#11111111b
djnz r5,again2
djnz r1,start2
mov r1,#150
start3: mov dptr,#word3
mov r5,#8
mov r2,#01111111b
again3: clr A
movc A,@A+dptr
inc dptr
mov p2,A
mov A,r2
mov p3,A
rr A
mov r2,A
acall delay
mov p2,#11111111b
djnz r5,again3
djnz r1,start3
mov r1,#150
start4: mov dptr,#word4
mov r5,#8
mov r2,#01111111b
again4: clr A
movc A,@A+dptr
inc dptr
mov p2,A
mov A,r2
mov p3,A
rr A
mov r2,A
acall delay
mov p2,#11111111b
djnz r5,again4
djnz r1,start4
mov r1,#150
start5: mov dptr,#word5
mov r5,#8
mov r2,#01111111b
again5: clr A
movc A,@A+dptr
inc dptr
mov p2,A
mov A,r2
mov p3,A
rr A
mov r2,A
acall delay
mov p2,#11111111b
djnz r5,again5
djnz r1,start5
mov r1,#150
start6: mov dptr,#word6
mov r5,#8
mov r2,#01111111b
again6: clr A
movc A,@A+dptr
inc dptr
mov p2,A
mov A,r2
mov p3,A
rr A
mov r2,A
acall delay
mov p2,#11111111b
djnz r5,again6
djnz r1,start6
mov r1,#150
start7: mov dptr,#word7
mov r5,#8
mov r2,#01111111b
again7: clr A
movc A,@A+dptr
inc dptr
mov p2,A
mov A,r2
mov p3,A
rr A
mov r2,A
acall delay
mov p2,#11111111b
djnz r5,again7
djnz r1,start7
mov r1,#150
start8: mov dptr,#word8
mov r5,#8
mov r2,#01111111b
again8: clr A
movc A,@A+dptr
inc dptr
mov p2,A
mov A,r2
mov p3,A
rr A
mov r2,A
acall delay
mov p2,#11111111b
djnz r5,again8
djnz r1,start8
ljmp begin
;
delay: mov r3,#10
delay1: mov r4,#10
djnz r4,$
djnz r3,delay1
ret
;
word1: db 10001010b,11000000b,11001000b,10001100b
db 11000001b,10000111b,10000110b,11001110b
word2: db 11000000b,11001000b,10001100b,11000001b
db 10000111b,10000110b,11001110b,10001010b
word3: db 11001000b,10001100b,11000001b,10000111b
db 10000110b,11001110b,10001010b,11000000b
word4: db 10001100b,11000001b,10000111b,10000110b
db 11001110b,10001010b,11000000b,11001000b
word5: db 11000001b,10000111b,10000110b,11001110b
db 10001010b,11000000b,11001000b,10001100b
word6: db 10000111b,10000110b,11001110b,10001010b
db 11000000b,11001000b,10001100b,11000001b
word7: db 10000110b,11001110b,10001010b,11000000b
db 11001000b,10001100b,11000001b,10000111b
word8: db 11001110b,10001010b,11000000b,11001000b
db 10001100b,11000001b,10000111b,10000110b
end
end

Step 3rd
Safe your assembly program above, and name it with *.asm (for example) Compile the program that you have been save by using RIDE-51, see the software instruction.

Step 4th
Download your hex file ( *.hex ) into the microcontroller by using Microcontroller Laros ATMEL ISP software, see the instruction.After download this hex file you'll see the action of the 7 segmen( of course if your cable connection and your program are corrected ).

8 x 7 Segmen Multiplexing



Writing multi character on 8 x 7 segmen

In this lesson, we are going to drive more 7 segmen, in this way you can write eight character or number on multi 7 segmen. We used a multiplexing methode to transfer data for driver transistor consequtively.

Step 1st
Build the circuit as shown in figure 2.3.5. As you seen on figure 2.3.5. P2.0 trough P2.7 is connected to driver transistor, and all eight 7 segment is connected to P0.0 trough P0.6 parallelly. Remember, that all we want to do with this lesson is write multi number ( 1-2-3-4-5-6-7-8 ) to 1st, 2nd, 3rd, 4th, 5th, 6th, 7th and 8th 7 segmen each.

Step 2nd
In this step, you must tipe the assembly program to make your 7 segmen shown some number on 7 segmen, we assume that you have already known the editor, we used RIDE-51 to edit the program.Below the schematic of 8 seven segmen multiplexing.

       org 0h
start: mov P0,#11111001b;write a number '1'
clr P2.7 ;turn on 1st 7 segment
call delay ;call delay time
setb P2.7 ;turn off 1st 7 segment
;
mov P0,#11011011b;write a number '2'
clr P2.6 ;turn on 2nd 7 segment
call delay ;call delay time
setb P2.6 ;turn off 2nd 7 segment
;
mov P0,#10110000b;write a number '3'
clr P2.5 ;turn on 3rd 7 segment
call delay ;call delay time
setb P2.5 ;turn off 3rd 7 segment
;
mov P0,#10011001b;write a number '4'
clr P2.4 ;turn on 4th 7 segment
call delay ;call delay time
setb P2.4 ;turn off 4th 7 segment
;
mov P0,#10010010b;write a number '5'
clr P2.3 ;turn on 5th 7 segment
call delay ;call delay time
setb P2.3 ;turn off 5th 7 segment
;
mov P0,#10000010b;write a number '6'
clr P2.2 ;turn on 2nd 7 segment
call delay ;call delay time
setb P2.2 ;turn off 2nd 7 segment
;
mov P0,#11111000b;write a number '7'
clr P2.1 ;turn on 7th 7 segment
call delay ;call delay time
setb P2.1 ;turn off 7th 7 segment
;
mov P0,#10000000b;write a number '8'
clr P2.0 ;turn on 8th 7 segment
call delay ;call delay time
setb P2.0 ;turn off 8th 7 segment
sjmp start ;jump forever
;=============================================
;subroutine delay created to rise delay time
;=============================================
delay: mov R1,#255
del1: mov R2,#255
del2: djnz R2,del2
djnz R1,del1
ret
end

Step 3rd
Safe your assembly program above, and name it with 7seg3.asm (for example) Compile the program that you have been save by using RIDE-51, see the software instruction.

Step 4th
Download your hex file ( 7seg3.hex ) into the microcontroller by using Microcontroller Laros ATMEL ISP software, see the instruction.After download this hex file you'll see the action of the 7 segmen( of course if your cable connection and your program are corrected ).

Programming Microcontroller H Bridge Motor

Assembly programming
CODE:
L293D_A equ P2.0 ;L293D A - Positive of Motor
L293D_B equ P2.1 ;L293D B - Negative of Motor
L293D_E equ P2.2 ;L293D E - Enable pin of IC

org 0H
Main:
acall rotate_f ;Rotate motor forward
acall delay ;Let the motor rotate
acall break ;Stop the motor
acall delay ;Wait for some time
acall rotate_b ;Rotate motor backward
acall delay ;Let the motor rotate
acall break ;Stop the motor
acall delay ;Wait for some time
sjmp Main ;Do this in loop

rotate_f:
setb L293D_A ;Make Positive of motor 1
clr L293D_B ;Make negative of motor 0
setb L293D_E ;Enable to run the motor
ret ;Return from routine

rotate_b:
clr L293D_A ;Make positive of motor 0
setb L293D_B ;Make negative of motor 1
setb L293D_E ;Enable to run the motor
ret ;Return from routine

break:
clr L293D_A ;Make Positive of motor 0
clr L293D_B ;Make negative of motor 0
clr L293D_E ;Disable the o/p
ret ;Return from routine

delay: ;Some Delay
mov r7,#20H
back: mov r6,#FFH
back1: mov r5,#FFH
here: djnz r5, here
djnz r6, back1
djnz r7, back
ret

C programming
CODE:
#include #define L293D_A P2_0 //Positive of motor
#define L293D_B P2_1 //Negative of motor
#define L293D_E P2_2 //Enable of L293D

// Function Prototypes
void rotate_f(void); //Forward run funtion
void rotate_b(void); //Backward run function
void breaks(void); //Motor stop function
void delay(void); //Some delay

void main(){ //Our main function
while(1){ //Infinite loop
rotate_f(); //Run forward
delay(); //Some delay
breaks(); //Stop
delay(); //Some delay
rotate_b(); //Run Backwards
delay(); //Some delay
breaks(); //Stop
delay(); //Some delay
} //Do this infinitely
}

void rotate_f(){
L293D_A = 1; //Make positive of motor 1
L293D_B = 0; //Make negative of motor 0
L293D_E = 1; //Enable L293D
}

void rotate_b(){
L293D_A = 0; //Make positive of motor 0
L293D_B = 1; //Make negative of motor 1
L293D_E = 1; //Enable L293D
}

void breaks(){
L293D_A = 0; //Make positive of motor 0
L293D_B = 0; //Make negative of motor 0
L293D_E = 0; //Disable L293D
}

void delay(){ //Some delay...
unsigned char i,j,k;
for(i=0;i<0x20;i++)
for(j=0;j<255;j++)
for(k=0;k<255;k++);
}

L293D Dual H-Bridge Motor Driver


L293D is a dual H-Bridge motor driver, So with one IC we can interface two DC motors which can be controlled in both clockwise and counter clockwise direction and if you have motor with fix direction of motion the you can make use of all the four I/Os to connect up to four DC motors. L293D has output current of 600mA and peak output current of 1.2A per channel. Moreover for protection of circuit from back EMF ouput diodes are included within the IC. The output supply (VCC2) has a wide range from 4.5V to 36V, which has made L293D a best choice for DC motor driver.

A simple schematic for interfacing a DC motor using L293D is shown side.

As you can see in the circuit, three pins are needed for interfacing a DC motor (A, B, Enable). If you want the o/p to be enabled completely then you can connect Enable to VCC and only 2 pins needed from controller to make the motor work.


As per the truth mentioned in the image above its fairly simple to program the microcontroller. Its also clear from the truth table of BJT circuit and L293D the programming will be same for both of them, just keeping in mind the allowed combinations of A and B. We will discuss about programming in C as well as assembly for running motor with the help of a microcontroller.

Build Digital to Analog Converter Using 0808


The first task this week is to build a simple D/A convertor and evaluate its performance. You will be using a DAC0808 (DAC0808 datasheet).Your design should take 8 bits from the microcontroller (use the 8 8bits on Port 0 of the AT89s51 as the input to the D/A convertor). The D/A output should range from 0 to 5 volts. The lower 8 bits from the AT89s51 should go into the 8 bits from the DAC0808. Note: I expect you to try to get the device to work by reading the datasheet and trying to understand it, if you have trouble you should come see me, but I expect you to have fairly specific questions that indicate you have put some thought into the problem.

Things to consider with the this design:

Figure 2.6.1 from page 4 of the DAC0808 datasheet is a good place to start your design.
The pins are labeled A1 through A8, but note that A1 is the Most Significant Bit, and A8 is the Least Significant Bit (the opposite of the normal convention). Ground the two least significant bits.
The D/A convertor has an output current, instead of an output voltage. The output pin should stay at about 0 volts. The op-amp on the "Typical Application" on the datasheet converts the current to a voltage. How does it do this?
The output current from pin 4 ranges between 0 (when the inputs are all 0) to Imax*255/256 when all the inputs are 1. The current, Imax, is determined by the current into pin 14 (which is at 0 volts). Note: Since we are using 8 bits, the maximum value is Imax*255/256.
You'll need to modify the circuit given in the datasheet to get a full scale range of 0 to 5 volts. Again, our output will be just under 5 volts. The output of the D/A convertor takes some time to settle. You may need to take this in consideration when planning the timing of the A/D conversion in later sections of this lab. Check the DAC0808 datasheet for specs. The code below shows an easy way to send 8 bits to the output of the microcontrollerr. You should probably test your code without the D/A convertor separately to ensure that the microcontroller is behaving as you expect

Displaying data ADC 0804 in 8x7 Segmen as a Decimal


In this lesson will be learn how to display data ADC on 8 x 7 segmen, for a simple task, we assume ADC have input ranges 0 - 5 volt, and then will display data as desimal that must be 3 digit 0 - 255, and each digit would be placed on 3rd, 2nd and 1st 7 segmen.

Figure 2.5.2. Connecting ADC and display to 7 segmen

Step 1st
Build the circuit as shown in figure 2.5.2. As you seen on figure 2.5.2. P3.0 trough P3.7 is connected to DB0 - DB7 ADC0804, and P2.0- P2.7. is connected to transistor driver, and P3.0 trough P3.7. is connected to 7 Segmen. Remember, that all we want to do with this lesson is write data ADC, to 8 x 7 Segmen.

Step 2nd
In this step, you must tipe the assembly program to make your 8 x 7 Segmen shown the data, we assume that you have already known the editor, we used RIDE-51 to edit the program. ( Download File asm : exp252.zip)

      org 0h
hundreds equ 30h
tens equ 31h
ones equ 32h
start: call ADC
call Bin2Dec
call Display2SevenSegmen
sjmp start
;
;=================================================
;this subroutine is used to take data from ADC and
;keep to Accumulator
;=================================================
ADC: mov A,P0
nop
nop
ret
;
;========================================================
;this subroutine is used to convert binary data from ADC
;become decimal 3 digit
;========================================================
Bin2Dec:
mov b,#100d
div ab
mov hundreds,a
mov a,b
mov b,#10d
div ab
mov tens,a
mov ones,b
ret
;===============================================
;this subroutine is used to convert data ADC to
;8 x 7 segmen
;===============================================
Display2SevenSegmen:
Mov P2,#11111111b
mov A, Hundreds
mov DPTR,#Data7segmen
movc A,@A+DPTR
mov P0,A
clr P2.5
call delay
;
mov A,tens
mov DPTR,#Data7segmen
movc A,@A+DPTR
setb P1.5
mov P0,A
clr P2.6
call delay
;
mov A,ones
mov DPTR,#Data7segmen
movc A,@A+DPTR
setb P1.6
mov P0,A
clr P2.7
call delay
ret
;
delay: mov R0,#0
delay1:mov R2,#0fh
djnz R2,$
djnz R0,delay1
ret
;
Data7segmen:
db 11000000b,11111001b,10100100b,10110000b,10011001b
db 10010010b,10000010b,11111000b,10000000b,10010000b
end

Step 3rd
Safe your assembly program above, and name it with adc2.asm (for example) Compile the program that you have been save by using RIDE-51, see the software instruction.

Step 4th
Download your hex file into the microcontroller by using Microcontroller Laros ATMEL ISP software, see the instruction.After download this hex file you'll see the action of ADC ( of course if your cable connection and your program are corrected )

K E Y P A D 4 x 4 (2)


Keypads are often used as a primary input device for embedded microcontrollers. The keypads actually consist of a number of switches, connected in a row/column arrangement as shown in Fig 2.8.1.

In order for the microcontroller to scan the keypad, it outputs a nibble to force one (only one) of the columns low and then reads the rows to see if any buttons in that column have been pressed. The rows are pulled up by the internal weak pull-ups in the 8051 ports. Consequently, as long as no buttons are pressed, the microcontroller sees a logic high on each of the pins attached to the keypad rows. The nibble driven onto the columns always contains only a single 0. The only way the microcontroller can find a 0 on any row pin is for the keypad button to be pressed that connects the column set to 0 to a row. The controller knows which column is at a 0-level and which row reads 0, allowing it to determine which key is pressed. For the keypad, the pins from left to right are: R1, R2, R3, R4, C1, C2, C3, C4

The Algorithm

Matrix-type keypads consist of a rectangular array of momentary push button. Each row and each column of push buttons is connected to a common rail. Suppose a four by four array of push button are used. A four by four array is often used to input hexadecimal numbers. There are four comun rails and four row rails. Each pushbutton has two terminals, one connected to its column rail and the other to its row rail. The row and column rails are connected to the microcontroller ports. The columns are driven low by output port. The rows are then read into the input ports. If no key is pressed, the rows read 1. When a row is detected to be 0, it indicates that a key in that row is pressed. the task now is to detect which key of the row is actually pressed. The microcontroller loops through each column, driving only one column low at a time as it inspects the row.The microcontroller needs to poll the rows to see if a key is pressed. Only when the column in which the pressed key resides is driven low is the row rail grounded, and thus the voltage is low. The rows and columns are interchangeable, that is, the rows may be driven low as the columns are read by the input ports.


Display Keypad 4 x 4 with 8x7 Seven Segmen


Continuing your sucsess, will try your knowledge with more complex experiment by read out the keypad 4 x 4 data with 8x7 Seven Segmen.
Figure 2.8.4.Keypad Connection to Microcontroller with 8x7 segmen

Step 1st
Build the circuit as shown in figure 2.8.4. As you seen on figure 2.8.4 P3.0 trough P3.7 is connected to keypad 4 x 4 and 8 x 7 Segmen to read keypad data, connected to P0.0 trough P0.7., P2.0 and P2.1 connected to RS and EN each.

Step 2nd
In this step, you must tipe the assembly program to scan your keypad data, we assume that you have already known the editor, we used RIDE-51 to edit the program. ( Download File asm : exp283.zip )

;the following experiment is used to scan
;keypad 4x4 and result of scan will be released
;to Display 7 Segmen
row1 bit P3.4
row2 bit P3.5
row3 bit P3.6
row4 bit P3.7
col1 bit P3.0
col2 bit P3.1
col3 bit P3.2
col4 bit P3.3
;
keydata equ 70h
keybounc equ 71h
keyport equ P2
org 0h
start: call keypad4x4 ;calling subrutine keypad4x4
Mov A,keydata ;A = keydata
Cjne A,#0FFh,Wr7Seg;
sjmp start ;LOOPING FOREVER PART 1
;
Wr7Seg:
;================================================
;I left the assembly instruction for you to learn
;=================================================
;
delay: mov R0,#0
delay1:mov R2,#50
djnz R2,$
djnz R0,delay1
ret
;
;====================================
; subroutine scan keypad 4x4
;====================================
Keypad4x4:
mov keybounc,#50 ;keybounc = 50
mov keyport,#0FFh ;keyport=P2= FF
clr col1 ;col1= P3.0 = 0
Detect:jb row1,key1 ;jump to Key1 if row=1
djnz keybounc,Detect
mov keydata,#00h ;Keydata =00h
ret
;
key1: jb row2,key2 ;jump to key2 if row2=1
djnz keybounc,key1
mov keydata,#04h ;Keydata = 04h
ret
;
key2: jb row3,key3 ; idem
djnz keybounc,key2
mov keydata,#08h
ret
;
key3: jb row4,key4 ; idem
djnz keybounc,key3
mov keydata,#0Ch
ret
;
key4: setb col1
clr col2
jb row1,key5
djnz keybounc,key4
mov keydata,#01h
ret
;
key5: jb row2,key6
djnz keybounc,key5
mov keydata,#05h
ret
;
key6: jb row3,key7
djnz keybounc,key6
mov keydata,#09h
ret
;
key7: jb row4,key8
djnz keybounc,key7
mov keydata,#0Dh
ret
;
key8: setb col2
clr col3
jb row1,key9
djnz keybounc,key8
mov keydata,#02h
ret
;
key9: jb row2,keyA
djnz keybounc,key9
mov keydata,#06h
ret
;
keyA: jb row3,keyB
djnz keybounc,keyA
mov keydata,#0Ah
ret
;
keyB: jb row4,keyC
djnz keybounc,keyB
mov keydata,#0Eh
ret
;
keyC: setb col3
clr col4
jb row1,keyD
djnz keybounc,keyC
mov keydata,#03h
ret
;
keyD: jb row2,keyE
djnz keybounc,keyD
mov keydata,#07h
ret
;
keyE: jb row3,keyF
djnz keybounc,keyE
mov keydata,#0Bh
ret
;
keyF: jb row4,Nokey
djnz keybounc,keyF
mov keydata,#0Fh
ret
Nokey:mov keydata,#0FFh
ret
;================================
;The end of Keypad 4x4 subroutine
;================================
end

Step 3rd
Safe your assembly program above, and name it with key3.asm (for example) Compile the program that you have been save by using MIDE-51, see the software instruction.

Step 4th
Download your hex file ( key3.hex ) into the microcontroller by using Microcontroller Laros ATMEL ISP software, see the instruction.After download this hex file you'll see the action of Keypad 4 x 4 ( of course if your cable connection and your program are corrected )

Displaying data ADC 0804 in 8x7 Segmen as a Decimal


In this lesson will be learn how to display data ADC on 8 x 7 segmen, for a simple task, we assume ADC have input ranges 0 - 5 volt, and then will display data as desimal that must be 3 digit 0 - 255, and each digit would be placed on 3rd, 2nd and 1st 7 segmen.

Figure 2.5.2. Connecting ADC and display to 7 segmen

Step 1st
Build the circuit as shown in figure 2.5.2. As you seen on figure 2.5.2. P3.0 trough P3.7 is connected to DB0 - DB7 ADC0804, and P2.0- P2.7. is connected to transistor driver, and P3.0 trough P3.7. is connected to 7 Segmen. Remember, that all we want to do with this lesson is write data ADC, to 8 x 7 Segmen.

Step 2nd
In this step, you must tipe the assembly program to make your 8 x 7 Segmen shown the data, we assume that you have already known the editor, we used RIDE-51 to edit the program. ( Download File asm : exp252.zip)

org 0h
hundreds equ 30h
tens equ 31h
ones equ 32h
start: call ADC
call Bin2Dec
call Display2SevenSegmen
sjmp start
;
;=================================================
;this subroutine is used to take data from ADC and
;keep to Accumulator
;=================================================
ADC: mov A,P0
nop
nop
ret
;
;========================================================
;this subroutine is used to convert binary data from ADC
;become decimal 3 digit
;========================================================
Bin2Dec:
mov b,#100d
div ab
mov hundreds,a
mov a,b
mov b,#10d
div ab
mov tens,a
mov ones,b
ret
;===============================================
;this subroutine is used to convert data ADC to
;8 x 7 segmen
;===============================================
Display2SevenSegmen:
Mov P2,#11111111b
mov A, Hundreds
mov DPTR,#Data7segmen
movc A,@A+DPTR
mov P0,A
clr P2.5
call delay
;
mov A,tens
mov DPTR,#Data7segmen
movc A,@A+DPTR
setb P1.5
mov P0,A
clr P2.6
call delay
;
mov A,ones
mov DPTR,#Data7segmen
movc A,@A+DPTR
setb P1.6
mov P0,A
clr P2.7
call delay
ret
;
delay: mov R0,#0
delay1:mov R2,#0fh
djnz R2,$
djnz R0,delay1
ret
;
Data7segmen:
db 11000000b,11111001b,10100100b,10110000b,10011001b
db 10010010b,10000010b,11111000b,10000000b,10010000b
end

Step 3rd
Safe your assembly program above, and name it with adc2.asm (for example) Compile the program that you have been save by using RIDE-51, see the software instruction.

Step 4th
Download your hex file into the microcontroller by using Microcontroller Laros ATMEL ISP software, see the instruction.After download this hex file you'll see the action of ADC ( of course if your cable connection and your program are corrected )