free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

Go to page  [1] 2 3
Moderators: Ajay, Junied , abbas1707, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph
Author Post
priya123
Tue Apr 29 2008, 05:45PM
 User Offline
Registered Member #7113
Joined: Wed Apr 09 2008, 02:39AM

Posts: 48
Thanked 0 times in 0 posts
actually i want to see the display through ports of the microcontroller by connecting a 7-segment display to it,how will i connect this 7-segment display to port1 of the mirocontroller(8051),i am designing the circuit on a breadboard,what will be the program code???please helpme,its too urgent///



p
Back to top


pdi33
Tue Apr 29 2008, 07:12PM

 User Offline
Registered Member #1329
Joined: Mon Jun 04 2007, 09:28AM

Posts: 655
Thanked 144 times in 140 posts
How many digits are u planning to connect to the uC?. Are u planning to display only numbers or also some alpha numeric characters? Please clarify.

Actually, u need to interface a multiplexed LED display to the uC. If u clarify the above points, i can provide u a ciruit idea about the connection.

* inspired to develop,developing to inspire *
Back to top



This post has been thanked 1 time
 priya123 
priya123
Tue Apr 29 2008, 07:48PM
 User Offline
Registered Member #7113
Joined: Wed Apr 09 2008, 02:39AM

Posts: 48
Thanked 0 times in 0 posts
actually i want to display some numbers only. my project is somewhat like this: i have interfaced adc(0804) and microcontroller(8051) .on appling a voltage say 2volts adc displays 033h and display is seen through port1 of microcontroller.at first i saw the display through leds connected on my trainer kit but now i want to see the display through a 7-segment display.i am providing my program code ,please tell me what changes are to be made in the code?
setb p2.5
setb p2.6
intr bit p2.7
setb intr
adc_port equ p1
adc_val equ 30h
voltage_val equ r3
back: clr wr
setb wr
acall conversion
read: clr rd
mov a,adc_val
setb rd
mov r3,#00h
acall data_display1
mov r3,#01h
acall data_display2
mov r3,#02h
acall data_display3
mov r3,#03h
acall data_display4
mov r3,#04h
acall data_display5
mov r3,#05h
acall data_display6
sjmp back
data_display1: mov a,#00h
conversion: mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov p1,r7
acall delay
mov p1,r6
acall delay
mov p1,r5
acall delay
ret
data_display2: mov a,#33h
mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov p1,r7
acall delay
mov p1,r6
acall delay
mov p1,r5
acall delay
ret
data_display3: mov a,#67h
mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov p1,r7
acall delay
mov p1,r6
acall delay
mov p1,r5
acall delay
ret
data_display4: mov a,#97h
mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov p1,r7
acall delay
mov p1,r6
acall delay
mov p1,r5
acall delay
ret
data_display5: mov a,#99h
mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov p1,r7
acall delay
mov p1,r6
acall delay
mov p1,r5
acall delay
ret
data_display6: mov a,#0ffh
mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov p1,r7
acall delay
mov p1,r6
acall delay
mov p1,r5
acall delay
ret
delay: mov r4,#200
here: djnz r4,here
ret
end



p
Back to top


sashijoseph
Wed Apr 30 2008, 01:08AM

 User Offline
Registered Member #5870
Joined: Mon Feb 04 2008, 06:26PM

Posts: 552
Thanked 124 times in 117 posts
Hi Priya...
Plz do not make multiple posts of the same topic....you have posted the same question in 3 diff. threads!!
As for your problem...you would need to display 3 digits.So you need three multiplexed 7-seg displays as pdi33 pointed out.
In multiplexing what you do is connect all the 7-seg displays in parallel,to one uc port,ie P1 in your case. Now Vcc to each display is provided by a transistor controlled by a port pin.So when the transistor connected to a particular display is switched on,only that display(out of the 3) will work.Similarly the next display will be made to turn on and the remaining will be off.When this cycle continues at a fast rate (greater than 20Hz) you get the impression that all 3 displays are on at the same time.
Look at the attached ckt.The display is a common anode one.To switch any display on you'll have to write a 0 to the particular port pin(P2.0,P2.1 or P2.2).



Let there be music........
Back to top


sashijoseph
Wed Apr 30 2008, 01:19AM

 User Offline
Registered Member #5870
Joined: Mon Feb 04 2008, 06:26PM

Posts: 552
Thanked 124 times in 117 posts
For writing digits you'll have to send the fol. values to P1.

Digit........ P1value(in hex)
--------------------------------
0........... C0
1........... F9
2........... A4
3........... B0
4........... 99
5........... 92
6........... 82
7........... F8
8........... 80
9........... 98


Let there be music........
Back to top


pdi33
Wed Apr 30 2008, 04:56AM

 User Offline
Registered Member #1329
Joined: Mon Jun 04 2007, 09:28AM

Posts: 655
Thanked 144 times in 140 posts
here is a simple idea for writing the display routine: (w.r.t the hardware suggested by shashi)
first u define a byte say digit_count = 0. then folow the following steps

step1: disable all digits (p2.0=p2.1=p2.2 = 1)
step2: fetch seven-segment code for the particular digit corresponding to digit_count.
step3: output the seven-segment code to port1
step4: enable the selected digit (p2.0/p2.1/p2.2 = 0) depending upon the digit_count.
step 5: increment the digit_count and reset it if it is > = 3.
return.

this routine should be called in the main loop and should be called continuously in real time.( rate of execution should be > 60hz. as the full display will be shown only when the routine is executed three times for the three digits.)


* inspired to develop,developing to inspire *
Back to top


priya123
Thu May 01 2008, 04:21PM
 User Offline
Registered Member #7113
Joined: Wed Apr 09 2008, 02:39AM

Posts: 48
Thanked 0 times in 0 posts
sir, i have another doubt------ the thing is that actually for a certain voltage say 2volts ,adc is reading 033h ,this data i am sending to the microcontroller and it is displaying 033h.i want 2 see 033h on the ports of the microcontroller through seven segment display. but here the digits 0-9 doesnt correspond to the values i have provided in my program. please help me clear this doubt.

p
Back to top


sashijoseph
Thu May 01 2008, 05:29PM

 User Offline
Registered Member #5870
Joined: Mon Feb 04 2008, 06:26PM

Posts: 552
Thanked 124 times in 117 posts
Plz go through the previous posts.Your answer is there.
For displaying digit '0' in the 7-seg,you have to send 'C0'.
For displaying digit '1',you have to send 'F9'.....and so on.
Read the above posts........

Let there be music........
Back to top


Ajay
Thu May 01 2008, 05:40PM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 3745
Thanked 695 times in 654 posts
please provide your circuit...

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


Arun Kumar V
Thu May 01 2008, 07:50PM

 User Offline
Registered Member #426
Joined: Sun Jan 28 2007, 11:50PM

Posts: 445
Thanked 188 times in 158 posts
Hi,

From i want understand from your posts- the ADC value is displayed in Binary format

on 8 LEDs on a port ( 33H(hex) - 00110011 (binary) - led7. ........led0 (Display on port)

1) you need a "Hex2BCD" conversion routine to display hex value into BCD on a 7

segment display For Eg: 33H is displayed as 51Decimal (BCD) on 2-digit 7seg display

after conversion.

2) if you just need the 2 digit 7 seg to display - 33, then instead of sending the

processed ADC value to Port directly store it in some Register and make a look up table

containing patterns for generating numbers from 0 to 9. i think this is where you are

getting confused, i think you are aware of the segments in a 7 seg display - seg

a,b,c,d,e,f,g,h (decimal point) - to construct 0(zero) on a 7 seg display you have to

output the port with - 11000000b or #0C0H this will mean connecting segments "g"

& "h"(Decimal point) to + 5V and grounding all other segments. now lets try displaying

"3" , so you out put -10110000b or #0B0H to the port - you ground the segs which are

to be seen( by writing zeros-0) and connect +5V to the segs which have to be hidden(by writing 1s).

i hope you are using Common Anode (LTS542) 7 seg display , if you are using Common

Cathode (LTS543) then you have to do reverse logic with the binary number you want

to display.

you draw the numbers you want to display on a paper and construct patterns 8 bit for

each number.

Apart from having lookup table ready you should also have a Compare subroutine to CJNE the value

stored in a register( ADC value which is stored) to the look up table.

for eg: 33H is 00110011b which is a packed BCD number which is made up of two

numbers - 3H and 3H after unpacking(higher nibble and lower nibble) you will get -

00000011b and 00000011 now store these two values in 2 variables say HI_Byte and

LO_Byte. now compare Hi_byte in the sub routine with the Look up table and

display1st digit , same way compare Lo_byte in the lookup table and display 2nd digit.

you may have to mutliplex the digits or use CD4511 BCD decoders for each digit

hope this will solve your problem

ho boy it's been a lengthy Post - thanks to my patience

Arun
Back to top


Go to page  [1] 2 3  

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems