Shop OBEX P1 Docs P2 Docs Learn Events
16 segment led, 74HC595, some weird behavour — Parallax Forums

16 segment led, 74HC595, some weird behavour

CuriousOneCuriousOne Posts: 931
edited 2013-03-29 08:02 in BASIC Stamp
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:
' {$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
RETURN
The 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

  • Igor_RastIgor_Rast Posts: 357
    edited 2013-03-27 03:57
    CuriousOne wrote: »
    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?

    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.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-03-27 08:54
    Another thing to mention is that when you reset the BASIC Stamp Module al the I/O pins become inputs, however you're not affecting the outputs of the 74HC595 necessarily. There is a Master Reset which can be connected to your system reset and that would allow you to reset the 74HC595 ICs.

    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.
  • CuriousOneCuriousOne Posts: 931
    edited 2013-03-27 11:12
    Stampworks #23 mentions usage of two 74HC595, so I'm also using two of them.and the segments remain lit even if I switch power button off. Only if I completely remove the power, segments reset then.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-03-28 08:37
    Is there a different power source for the displays? Once the 74HC595 ICs lose power they should not retain the previous data.
  • CuriousOneCuriousOne Posts: 931
    edited 2013-03-29 01:19
    No. All power is got from stamps in class board.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-03-29 08:02
    When you turn the power off there must be just enough latent voltage left to keep the shift registers in their current states. I would bet if you left the system powered down for a while it would not be in the same state.
Sign In or Register to comment.