16 segment led, 74HC595, some weird behavour
CuriousOne
Posts: 931
Hello. I had 16 segment led indicator laying around, so I decided to hook it to BS2, to see how it works. For that, I've used schematics from stampworks #23 - expanding outputs, but instead of 16 discrete leds as provided, I've hooked 16 segments of indicator (my indicator is common anode, so pattern should be inverted, but that does not pose large problem I believe). I've took the sample code from the same file, and slightly modified it to fit my needs:
Also, I tried to individually address the segments, but often, 2 of them are lit same time, I believe this is because pattern variable is only 8 bit wide, when I need 16 bits. How should I "add more bits?" take double variable, split it into lsb and msb and then feed to shift register?
' {$STAMP BS2p} ' {$PBASIC 2.5} ' -----[ I/O Definitions ]------------------------------------------------- Clock PIN 8 ' shift clock (74HC595.11) SerData PIN 7 ' serial data (74HC595.14) Latch PIN 6 ' output latch (74HC595.12) ' -----[ Constants ]------------------------------------------------------- DelayTime CON 500 ' -----[ Variables ]------------------------------------------------------- pattern VAR Byte ' zig-zag pattern ' -----[ Initialization ]-------------------------------------------------- Reset: LOW Latch ' make output and low Main: pattern = %00000001 GOSUB Out_595 ' D PAUSE DelayTime ' hold pattern=pattern <<1 GOTO Main ' -----[ Subroutines ]----------------------------------------------------- Out_595: SHIFTOUT SerData, Clock, MSBFIRST, [pattern] ' send pattern to '595 PULSOUT Latch, 5 ' latch outputs RETURNThe program works as it should work, but, when I press reset, or switch the power (I'm using "stamps in class" board), the digits on led indicator remain lit, so I have to unplug battery and usb, to make it work again. This is very annoying. What I'm doing wrong?
Also, I tried to individually address the segments, but often, 2 of them are lit same time, I believe this is because pattern variable is only 8 bit wide, when I need 16 bits. How should I "add more bits?" take double variable, split it into lsb and msb and then feed to shift register?
Comments
Well I would try connectig a second 595 after the first one , so serial out of first 595 goes to seria in of second 595. and the 2 control lines are tied together
thisway you have a 16 bit output at the 2x 595. and there will be a 16 bit number shifted in . So you can adress only segment at a time. Could be expended to max 4 conected after each other.
As a note, I have used two 74HC595 ICs to control a 16-segment display before. Actually there were two ICs per digit and I had multiple digits. I created a table in EEPROM using DATA statements that was a lookup table for the patterns for the entire printable ASCII set. These values were looked up and shifted out to each digit as needed.