PDA

View Full Version : PIC 16F84A and 7segment LED dispay



select
- 20th November 2007, 11:13
hello,

I have one small problem with routine for PIC 16F84A. Program must drive 7 segment LED display with comm. cathode. On output B port are PNP transistors via 4k7 for each segment.
problem is following:
RS232 values are ok and display lighted only 0. What is wrong here?

porta.3 is serial input and value for B5 are 0-10. Var from LOOKUP are value for LED segment

here is rotine:

DEFINE OSC 16
INCLUDE "MODEDEFS.BAS"

dp var portb.0
c var portb.1
d var portb.2
e var portb.3
g var portb.4
f var portb.5
a var portb.6
b var portb.7
SDA VAR PORTA.3 'pin2
b0 var byte
b1 var byte
b2 var byte
b3 var byte
b4 var byte
b5 var byte

trisa=%11111111
trisb = %00000000

clear
START:

serin sda,0,b2,b3,b4,b5
lookup2 B5,[238,130,220,214,178,118,126,194,254,246,108],B1
PORTB=B1
GOTO START

end

Similar routine i have write for a LCD display. Instead LOOKUP command is LCDOUT $fe,$80, #b5 and working ok.

Thanks
Sam

mister_e
- 20th November 2007, 14:50
it's more a matter of how the data is sent. You may try to change b5 to #b5 in SERIN line.

doesn't work? comment out the SERIN line and use b5=3, it should display 3 on your 7 segment... right?

select
- 21st November 2007, 09:51
hi Steve,

I was trying with #b5 and display light allways 8 (all pins are low). The simple loop program, working ok and count normaly from 0 to 9

here is a this sample1 (B5 count on LED display 0-9)

start: for B5=0 to 9
lookup2 B5,[238,130,220,214,178,118,126,194,254,246,108],B1
pause 500
portb=b1
next B5
goto start

sample 2 Instead lookup2 command have lcdout command. (working ok. B5 count 0 to 9 on LCD)

start: serin SDA,0,b2,b3,b4,b5
lcdout $fe,1,$80,#b5
pause 100
goto start


sample 3. this sample show allways 0 on display. (B5 read lookup2 command and show 0 allways)

dp var portb.0
c var portb.1
d var portb.2
e var portb.3
g var portb.4
f var portb.5
a var portb.6
b var portb.7
SDA VAR PORTA.3 'pin2
b0 var byte
b1 var byte
b2 var byte
b3 var byte
b4 var byte
b5 var byte

trisb = %00000000

start: serin SDA,0,b2,b3,b4,b5

lookup2 B5,[238,130,220,214,178,118,126,194,254,246,108],B1
portb=b1
goto start


i was changed LOOKUP2 with LOOKUP and LED showing 8

I have not anymore ideas :(

regards
Sam

select
- 21st November 2007, 09:53
hi again,

How read ASCII value from lookup command?

regards,
Sam

Ioannis
- 21st November 2007, 11:25
How do you send the number to be displayed? By Hyperterminal for example and pressing the key '0'?

Ioannis

mister_e
- 21st November 2007, 21:01
i'll repeat what i told in previous post...

start: serin SDA,0,b2,b3,b4,#b5

lookup2 B5,[238,130,220,214,178,118,126,194,254,246,108],B1
portb=b1
goto start