PDA

View Full Version : 7 segment display



lerameur
- 12th January 2015, 03:16
Hello,

I have a 4x 7 segment display, with each segments displaying what I need.
BUT.... yes.. but. When I have a 1 second pause between the display of each unit , I have full brightness of the led module (LDS-AD16RI) but I of course I can see the number going off and on, Reducing the pause time does eliminate a lot of that roughness, but I can hardly see the numbers, they hardly light at all.
Anybody had this issue ?
Here is the code, I could also post a video if needed.

Mainloop

I2CRead SDApin,SCLpin,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCWDay,RTCDay,RTCMonth,RTCY ear,RTCCtrl]
Pause 20

TempVal=RTCSec 'Seconds , with temp1 on the left and temp 2 on the right
gosub bcd_to_bin

temp1_sec = temp1
n = temp1_sec
PortA.0 =1
gosub display
PortA.0 =0

temp2_sec = temp2
n = temp2_sec
PortA.1 =1
gosub display
'PortA.1 =0

PortA.2 =0
PortA.4 =0
PortC.0 =0
PortC.1 =0

goto Mainloop
end

bcd_to_bin:
temp2 = $0F & TempVal ' Clear off the top four bits
temp1= TempVal >> 4 ' Shift down four to read 2 BCD value

return

display:
Lookup n, [$3F, $06, $5B, $4F, $66, $6D, $7D, $07, $7F, $67], Segments
PORTB = Segments
pauseus 10
return

richard
- 12th January 2015, 04:18
basically your perceived led brightness is proportional to display pause / (loop time+ display pause*2) (for 2 digits)

you have not set a OSC define so I'm assuming 4mhz clock and that your loop time is some mS lets say 5 so each digit led is on for 10uS and off for 4990 uS . its going to be dull.

if you make the delay pause too big the led will blink , it a compromise between brightness and blinking
try 500uS , its a trial and error thing I think and may take a few tries

Demon
- 12th January 2015, 15:38
Richard is right, and there's also the resistor. Let's assume the common 330ohm resistor, that works fine for constant ON. But when you start blinking leds, you can get away with weaker resistors.

I was using 100ohm resistors when blinking 56 leds in charlieplex.

Robert

lerameur
- 12th January 2015, 22:07
I think both of you where right. I did play with the pause last night without much success, I replace the resistors with 50 ohms one, now it works better (still not perfect) but at pauseus 50, I still get flickering and a lot of ghosting, many segments of the display that should be off, fades on and off which do not occur at slower speed ( pause 10 lets say).
I raise the voltage to get light emission, but that problem seems worst !
any ideas how to eliminate this?

richard
- 12th January 2015, 22:31
your mainloop is unnecessarily long

firstly
I2CRead SDApin,SCLpin,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCWDay,RTCDay,RTCMonth,RTCY ear,RTCCtrl]
why read these when they are never used


second
Pause 20 why ????

third
all these never change why are they in the loop
PortA.2 =0
PortA.4 =0
PortC.0 =0
PortC.1 =0

and finally
you are reading the time hundreds of times a second when it can only change once a second


why not
count var word

count=1000

mainloop:
if count = 1000 then
I2CRead SDApin,SCLpin,$D0,$00,[RTCSec]
count =0
gosub bcd_to_bin
endif

count=count+1

temp1_sec = temp1
n = temp1_sec
PortA.0 =1
gosub display
PortA.0 =0

temp2_sec = temp2
n = temp2_sec
PortA.1 =1
gosub display

goto Mainloop
end

lerameur
- 12th January 2015, 23:06
Thank you for the help,
the pause after the I2Cread was screwing me up badly.
I get clear segments now.
I now have a different issue !!
Some of the segments not being used oare still being lit lighty !! I found that the dimm display on one display module was a pale mirror image of the display module next to it. I posted a picture to help understand what i'm talking about.
Basically i have a 1 and 6 I can see (barely) on the 1 module all the segments of the 6 in the 1 module. I guess thats what is called ghosting..

UPDATE: solved the problem by adding : PORTB = $00
Lookup n, [$3F, $06, $5B, $4F, $66, $6D, $7D, $07, $7F, $67], Segments
PORTB = $00
PORTB = Segments
pause 1
PORTB = $00

thanks for the really, very much appreciated

fratello
- 13th January 2015, 13:24
Nice job !
Please, can you post full code ? Maybe I try to build this clock.
Thanks !