query regarding seven segment display
PORT PIN NO(8051): SEVEN SEGMENT DISPLAY
(SP5503)
P3.0-------------------------------------------------------------------A (PIN NO 7)
P3.1-------------------------------------------------------------------B (PIN NO 6)
P3.2--------------------------------------------------------------------C (PIN NO 4)
P3.3--------------------------------------------------------------------- D (PIN NO 2)
P3.4--------------------------------------------------------------------- E(PIN NO 1)
P3.5--------------------------------------------------------------------F (PIN NO 9)
P3.6--------------------------------------------------------------------G (PIN NO 10)
P3.7--------------------------------------------------------------------DP (PIN NO 5)
As the chip i am using is a common cathode configuration so at the common pin(PIN NO 3)i have provided a 330 ohmresistor and grounded it.
[ Edited Wed May 28 2008, 04:19 am ]
there are few things you need to know :
1) Micros like 8051 are good at sinking Current than sourcing current (2 mA); so its better to use Common Anode type rather than c.cathode, still if you want to use C.cathode type then the display will turn on very dim ( if directly connected to port pins - which you are doing right now)
2) the hex values for each number are correct with respect to Common cathode display - but your assembler/compiler may show error "undefined symbol" for those hex values- so you have to Use them in Binary form for eg: for displaying Number 9, instead of 67H use 01100111b in your program.
3) there is one more problem with Common cathode type - at the time of power on since all the ports are inputs i,e logic 1's your display will show '8." so the first instruction in your main program should be MOV P1,#00H
4) Use non inverting octal Buffer like 74HC244 - between Port pins and the display for more current
5) use of single Common Resistor is wrong, when more segments are "ON" the display looks feeble, when number like "1" is displayed it looks bright- so use independent resistors for each segment so that the segment LEDs don't have to fight for Current share
All the best
Arun
setb p2.5
setb p2.6
intr bit p2.7
setb intr
adc_port equ p1
adc_val equ 30h
voltage_val equ r3
org 0h
start: acall read
acall conversion
mov a,adc_val
sjmp start
conversion: clr wr
setb wr
read: clr rd
mov a,adc_val
setb rd
mov r3,#00h
mov a,#00h
cjne a,#00,over1
over1: acall data_display1
mov r3,#01h
mov a,#33h
cjne a,#51,over2
over2: acall data_display2
mov r3,#02h
mov a,#67h
cjne a,#103,over3
over3: acall data_display3
mov r3,#03h
mov a,#97h
cjne a,#151,over4
over4: acall data_display4
mov r3,#04h
mov a,#99h
cjne a,#153,over5
over5: acall data_display5
mov r3,#05h
mov a,#0ffh
cjne a,#255,over6
over6: acall data_display6
data_display1: mov a,#00h
mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov a,r7
acall disp_7segment
acall delay
mov a,r6
acall disp_7segment
acall delay
mov a,r5
acall disp_7segment
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 a,r7
acall disp_7segment
acall delay
mov a,r6
acall disp_7segment
acall delay
mov a,r5
acall disp_7segment
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 a,r7
acall disp_7segment
acall delay
mov a,r6
acall disp_7segment
acall delay
mov a,r5
acall disp_7segment
acall delay
ret
data_display4: mov a,#99h
mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov a,r7
acall disp_7segment
acall delay
mov a,r6
acall disp_7segment
acall delay
mov a,r5
acall disp_7segment
acall delay
ret
data_display5: mov a,#97h
mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov a,r7
acall disp_7segment
mov a,r6
acall disp_7segment
mov a,r5
acall disp_7segment
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 a,r7
acall disp_7segment
mov a,r6
acall disp_7segment
mov a,r5
acall disp_7segment
acall delay
ret
disp_7segment: mov p1,#00h
cjne a,#0,d1
mov p1,#03fh
d1: cjne a,#1,d2
mov p1,#06h
d2: cjne a,#2,d3
mov p1,#5bh
d3: cjne a,#3,d4
mov p1,#04fh
d4: cjne a,#4,d5
mov p1,#066h
d5: cjne a,#5,d6
mov p1,#6dh
d6: cjne a,#6,d7
mov p1,#7dh
d7: cjne a,#7,d8
mov p1,#07h
d8: cjne a,#8,d9
mov p1,#7fh
d9: cjne a,#9,d10
d10: mov p1,#67h
delay: mov r4,#200
here: djnz r4,here
ret
end
[ Edited Wed May 21 2008, 06:22 am ]
3) there is one more problem with Common cathode type - at the time of power on since all the ports are inputs i,e logic 1's your display will show '8." so the first instruction in your main program should be MOV P1,#00H
clearly i have mentioned about this problem and solution for that, " MOV P1,#00H"wasn't this supposed to be your first instruction in your code
THINK BEFORE YOU INK
Arun
[ Edited Fri May 16 2008, 08:31 am ]
i have connected an ADC with the microcontroller& then at port1 i have connected this 7-segment display.data lines of ADC are also connected with the port p1 of microcontroller
1) Why in the world did you connect ADC & 7 seg display to the same PORT 1 ? use the ADC on some other free port
2) Why do you want to Multiplex data bus lines?
3) In which mode are you using AD 0804 - Free running mode or microcontroller master mode ?
4) use MOV P1,#00H just after your variables ; the idea is to Blank out the display during power-ups.
Arun
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 read: clr rd mov a,adc_val setb rd
Plenty of mistakes in this ADC code.What is 'rd' ,'wr'...? Where are you reading the ADC value from adc_port?
First thing go through this... http://www.8051projects.net/adc-interfacing/adc0804-8051-programming.php
and correct your adc routine.
What Vref/2 value have you chosen?
You have 'hardcoded' your display routine to display some values(33,67 etc).Where is the comparison with the adc value read in?
For eg. if you want to display 33 if input voltage is 1V,you'll have to read the adc and compare the value read with 51 decimal(assuming you have left Vref/2 pin open,which gives a step size of 19.5mv thus giving a digital value of 51 for 1000mv input(adc value=Vin/step size)).
If adc value is 51 then you call the data_display1 routine.
Similarly for other Vin values.
So make the necessary changes and get back to us.
i have already mentioned earlier and would like to repeat that please mention the definition of various variables like rd/wr.etc. and also the hardware connections as that would help us understand exactly what logic u have applied in our code. it is always good practice to add comments whereever possible so that we can understand ur code better and provide some useful feedback. now, as far as ur problem is concerned, follow the following procedure, if possible:
first temporarily remove the code which reads ur ADC.u can do that by just adding a semicolon before the ADC read instructions. and check the display code if it is working properly by outputing some fixed values to the display. Once it shows the correct values, reintroduce the adc value and put the values in the display routine.
step by step troubleshooting would always save u a lot of time.
good luck.
P.S. look back in some posts by arun and shashi and u will find some really useful hints on how to correctly interface the LED display. read them carefully (note them down preferably as i understand u have a very slow internet connection) and try correcting the errors by urself. Please understand that if u can correct ur logical errors,( as far as possible) than that would benifit u the most and that is the sole intention of all of us here.
FOR ADC(0804)
PIN 20: supply voltage +5 volts
PIN 18---PIN 11:these are the data lines and are connected in the following way
PIN 18 CONNECTED TO PORT P3.0(microcontroller 8051)
PIN 17 CONNECTED TO PORT P3.1
PIN 16 CONNECTED TO PORT P3.2
PIN 15 CONNECTED TO PORT P3.3
PIN 14 CONNECTED TO PORT P3.4
PIN 13 CONNECTED TO PORT P3.5
PIN 12 CONNECTED TO PORT P3.6
PIN 11 CONNECTED TO PORT P3.7
PIN 1: CS is grounded
PIN 2 :RD IS CONNECTED TO P2.5(PIN NO:26 OF MICROCONTROLLER 8051)
PIN 3: WR IS CONNECTED TO P2.6(PIN NO:27 OF MICROCONTROLLER 8051)
PIN 4: here i have provided external clock
PIN 5: INTR IS CONNECTED TO P2.7(PIN NO: 28 OF MICROCONTROLLER 8051)
PIN 6: here i have provided a variable input at which i am varying the voltage value
PIN 7: grounded
PIN 8,PIN 10: grounded separately
PIN 9: OPEN
Vref: 1.28 volts
FOR MICROCONTROLLER(8051):
connections with ADC (0804) are already mentioned
PIN 40: power supply +5 volts Vcc
PIN 31: EA/VPP connected with pin 40
here also i have provided external clock and build the reset circuitry with capacitors and pull -up-resistors
PORT PIN P1.0: segment A of seven-segment display (SP5503)
PORT PIN P1.1: segment B of seven-segment display
PORT PIN P1.2: segment C of seven segment display
PORT PIN P1.3: segment D of seven-segment display
PORT PIN P1.4: segment E of seven-segment display
PORT PIN P1.5: segment F of seven-segment display
PORT PIN P1.6: segment G of seven-segment display
PORT PIN P1.7: segment H ofseven-segment display
SP5503 is a commoncathode chip so i have used common cathode configuration
sir, this is my entire hardware connection,i have also tried to correct my code and so edited the post please go through it once.
theanking u
[ Edited Wed May 28 2008, 04:18 am ]
PIN 18 CONNECTED TO PORT P1.0(microcontroller 8051)
PIN 17 CONNECTED TO PORT P1.1
PIN 16 CONNECTED TO PORT P1.2
PIN 15 CONNECTED TO PORT P1.3
PIN 14 CONNECTED TO PORT P1.4
PIN 13 CONNECTED TO PORT P1.5
PIN 12 CONNECTED TO PORT P 1.6
PIN 11 CONNECTED TO PORT P1.7
PIN 1: CS is grounded
PORT PIN P1.0: segment A of seven-segment display (SP5503)
PORT PIN P1.1: segment B of seven-segment display
PORT PIN P1.2: segment C of seven segment display
PORT PIN P1.3: segment D of seven-segment display
PORT PIN P1.4: segment E of seven-segment display
PORT PIN P1.5: segment F of seven-segment display
PORT PIN P1.6: segment G of seven-segment display
PORT PIN P1.7: segment H ofseven-segment display
in my last post i asked a question :
1) Why in the world did you connect ADC & 7 seg display to the same PORT 1 ? use the ADC on some other free port
Arun