Writing to LED Display
Newzed
Posts: 2,503
I have a four digit LED clock display which I drive with two 595s.· One 595
triggers LED segments, the other triggers the cathode via a transistor.
I want to display the time which is generated on the Stamp with a DS1302.· I have a list of constants that says
one con 192
two con 182
and so on.· These cons trigger the segments to display the desired number.
I can solve the problem by writing:
hrs1 var hrs.highnib
hrs2 var hrs.lownib
IF hrs1 = 0 THEN hrs0 = 252··· 'LED displays 0
IF hrs1 = 1 THEN hrs1 = 192··· 'LED displays 1
IF hrs1 = 2 THEN hrs1 = 182
shiftout dat, clk, lsbfirst, [noparse][[/noparse]dig1, hrs1]
and so on for hrs, mins and secs.· This is an awful lot of if/thens.
There must be a better way to do it.
Sid
triggers LED segments, the other triggers the cathode via a transistor.
I want to display the time which is generated on the Stamp with a DS1302.· I have a list of constants that says
one con 192
two con 182
and so on.· These cons trigger the segments to display the desired number.
I can solve the problem by writing:
hrs1 var hrs.highnib
hrs2 var hrs.lownib
IF hrs1 = 0 THEN hrs0 = 252··· 'LED displays 0
IF hrs1 = 1 THEN hrs1 = 192··· 'LED displays 1
IF hrs1 = 2 THEN hrs1 = 182
shiftout dat, clk, lsbfirst, [noparse][[/noparse]dig1, hrs1]
and so on for hrs, mins and secs.· This is an awful lot of if/thens.
There must be a better way to do it.
Sid
Comments
Lookup hrs1,[noparse][[/noparse]zero,one,two,three....],led1
. . .
(Something like that, its early).
Regards,
Al Williams
AWC
8 Channels of PWM on a PCB:
http://www.awce.com/gp6.htm
Are you saying:
lookup hrs1, (252, 192, 182), led1
lookup hrs2, (252, 192, 182, 230, 202, 110, 122,196, 254, 238). led2
The numbers are shiftouts to the 595 to display 0, 1, 2, 3, 4 etc.
Sid
lookup hrs1,(zero,one,two),hrs1· ' put back into hrs1 ought to work
lookup hrs2,(zero,one,two,three,four,five,six,seven,eight,nine),hrs2
shiftout....
I think that will work. We are an hour behind you Sid, plus I've never been a morning person. Unfortunately, the wife is so that means for the last -- what -- 20 years I have had to be an early riser and go to bed before midnight, but I've never learned to like it in all that time.
Al Williams
AWC
Floating Point for the Stamp or any Microcontroller
http://www.awce.com/pak12.htm
·
In past projects I've also used DATA statements to hold segment information; that way I can define them in binary and see which segments are going to be lit for a given value. Something like this:
Digit0·· DATA·· %00000000·· ' put your segment values here
Digit1·· DATA·· %00000000
.
.
Digit9·· DATA·· %00000000
Then....
Get_Hrs_Segs:
· READ (Digit0 + hrs.LOWNIB), segs01··· ' get 1's segments
· READ (Digit0 + hrs.HIGHNIB), segs10·· ' get 10's segments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Post Edited (Jon Williams) : 8/12/2004 1:46:15 PM GMT
Regards,
Al Williams
AWC
Kits
http://www.awce.com/kits.htm
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Anyways, I've got some questions.
1. whats a 595 and where can I get one?
2. where did you get your 4 digit display? Online?, Instore?, salvaged from a clock?
3. whats a DS1302 and where can I get one?
DS 1302 is a clock chip - Parallax
The LEDs are from eric.adams@verizon.net
Sid
Using 3 stamp pins, you have a net gain of 5 pins. But the device can be cascaded. So with 3 stamp pins you can get 8, 16, 24.......additional I/O pins.
The parallax websight has a good tutorial on using the device with BS2 code to control it.
Ken
Ill have to look for that tutorial you mentioned.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
USB-powered Stamp Board
http://hometown.aol.com/newzed/index.html
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
But im intrerested in using a 595 to expand my stamps·I/O abbilities.
Could you tell me where this document is located? I looked around but I couldnt find anything.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Also, Maxim will send a free sample of the very pricey MAX7219. The datasheet for this device can also be a little intimidating.
I posted code to control and hopefully a simple to understand explanation on using the MAX7219. In this forum t search on 7219.
As Jon mentioned, the 595's work really well, "set it and forget it"
The 7291 is a good alternative if board space is an issue.
Ken
I'll probobly end up using a max7219 to drive my 7 seg. LED's.
But im intrerested in using a 595 to expand my stamps·I/O abbilities.
"
Just to clarify, the '595 only expands outputs, not inputs· ...."I/O abilities"......
There is a 74LS299 (I think that is the number" that can be used to expand INPUT and OUTPUTs with one IC, or there are individual ICs to do output (595) or input. I think the 74LS166 does the input expansion. The Stampworks library on the Parallax sight should get you going in that direction.
Ken
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Thanks again for all the help, By the way I checked out the stampworks manual and it has lots of good (very helpful) info in it. Only problem is now that I've seen its·manual it makes me want to buy the kit .
Post Edited (jakjr) : 8/19/2004 3:37:46 AM GMT