Shop OBEX P1 Docs P2 Docs Learn Events
Shift register help! — Parallax Forums

Shift register help!

log23log23 Posts: 6
edited 2013-12-11 14:57 in BASIC Stamp
Hello, I am trying to use a TPIC6B595 to control the drain on different rows of an LED matrix and I am not sure how to control it!

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-09 18:49
    log23, welcome to the Parallax forum!

    What micro are you using, and what have you tried so far?

    -Phil
  • log23log23 Posts: 6
    edited 2013-12-09 18:55
    BS2, I am working on an AudioVU meter and right now I just want to light all of the LEDS, and I want to light one row as a starting point and then move to cycling through them.
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    serialout PIN 1
    serialclk PIN 2
    serialclr PIN 3
    col       VAR Word
    col = 2
    HIGH serialclr
    main:
    DO
    HIGH 15
    HIGH 14
    HIGH 13
    HIGH 12
    HIGH 11
    HIGH 10
    HIGH 9
    HIGH 8
    HIGH serialclk
    PAUSE 10
    SEROUT 1, 396, [DEC 2]
    PAUSE 1
    LOW serialclk
    LOOP
    END
    

    thats my code so far, I want to light the row connected to Q1
    I am able to light the rows by jumpering the pin to ground.

    And thanks for the welcome :)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-09 19:19
    log23,

    attachment.php?attachmentid=78421&d=1297987572

    -Phil
  • log23log23 Posts: 6
    edited 2013-12-09 19:24
    Ha, sorry about that, I fixed it.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-12-09 21:21
    Those high power shift registers work pretty much like a regular '595 chips.

    There's a section of the StampWorks book which shows how to use the normal '595 chips. Hopefully it will give you an idea of how to use the high power version.

    Looking at your code now, I'd say you're not even close to controlling the chip. I don't see the data line being pulses at all.

    I used the TPIC6B595 to control some RGB arrays.

    How are you powering the anodes? The BS2 can directly drive one LED but you don't want to power a whole row of LEDs with a BS2 I/O pin.
  • log23log23 Posts: 6
    edited 2013-12-09 21:54
    I am driving one led per pin, and using the shift register to control the column selected.
    I with that chip that I am using, I'm not sure what to do with
    RCK, GNOT and SRCLRNOT
    here is some updated code
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    serialout PIN 0
    serialclk PIN 1
    serialclr PIN 2
    col       VAR Word
    col = 2
    LOW serialclr
    LOW serialclk
    main:
    DO
    HIGH 15
    HIGH 14
    HIGH 13
    HIGH 12
    HIGH 11
    HIGH 10
    HIGH 9
    HIGH 8
    PAUSE 200
    LOW 15
    LOW 14
    LOW 13
    PAUSE 200
    LOOP
    SEROUT 0, 1, MSBFIRST, [80]
    PULSOUT 3,1
    LOW 2
    END
    

    But I will take a loot at your tutorial
  • davejamesdavejames Posts: 4,047
    edited 2013-12-09 22:28
    log23 - any chance of providing a schematic so we can see what you're attempting to do?

    And, do you have the 595 datasheet?

    http://www.ti.com/lit/ds/symlink/tpic6b595.pdf

    The descriptions of the noted pins are on the first page.
  • log23log23 Posts: 6
    edited 2013-12-09 22:49
    using this code
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    
    
    
    Clock PIN 1 ' shift clock (74HC595.11)
    SerData PIN 0 ' serial data (74HC595.14)
    Latch PIN 2 ' output latch (74HC595.12)
    
    
    
    
    ' -----[ Constants ]-------------------------------------------------------
    
    
    'DelayTime CON 0
    HIGH 15
    HIGH 14
    HIGH 13
    HIGH 12
    HIGH 11
    HIGH 10
    HIGH 9
    HIGH 8
    
    
    ' -----[ Variables ]-------------------------------------------------------
    
    
    pattern VAR Byte ' zig-zag pattern
    
    
    
    
    ' -----[ Initialization ]--------------------------------------------------
    
    
    Reset:
     LOW Latch ' make output and low
     pattern = %00000001
    
    
    
    
    ' -----[ Program Code ]----------------------------------------------------
    
    
    Main:
     DO
     GOSUB Out_595 ' put pattern on 74x595
     pattern = pattern << 1 ' shift pattern left
     LOOP UNTIL (pattern = %01000000)
     pattern = %00000001
     GOTO Main
    
    
     Out_595:
     SHIFTOUT SerData, Clock, MSBFIRST, [pattern] ' send pattern to '595
     HIGH latch
     LOW latch ' latch outputs
     PAUSE 1000
     RETURN
    

    I was able to get it to cycle the way that I wanted, you've been a huge help so far!

    I will try to get schematics and hopefully show the complete project over the course of the next few days!
  • davejamesdavejames Posts: 4,047
    edited 2013-12-09 23:15
    Glad to hear you've been able to get things to work! :thumb:

    Looking forward to seeing the completed project.


    Do you feel successful enough to make this thread as "solved"?
  • log23log23 Posts: 6
    edited 2013-12-11 14:57
    I still have some issues.

    This is how the project is working so far.

    http://www.youtube.com/watch?v=1b6zmg6YLLY&feature=youtu.be

    I
    am using a MSGEQ7 to process incoming signals, but I am not seeing the outputs that I expected. With but with respect to the display shifting I am still having an issue with the columns turning off before I would like them too creating a "dim effect".
    ' {$STAMP BS2}' {$PBASIC 2.5}
    
    
    
    
    Clock PIN 1 ' shift clock (74HC595.11)
    SerData PIN 0 ' serial data (74HC595.14)
    Latch PIN 2 ' output latch (74HC595.12)
    
    
    
    
    ' -----[ Constants ]-------------------------------------------------------
    
    ' -----[ Variables ]-------------------------------------------------------
    
    
    pattern VAR Byte
    bittotal VAR Byte
    ' -----[ Initialization ]--------------------------------------------------
     'OUTH = 000000         ' OUTH initialized TO LOW.
     DIRH = 111111         ' Set P8-P15 to all output-low.
    Reset:
     LOW Latch ' make output and low
     pattern = 1
    
    
    
    
    ' -----[ Program Code ]----------------------------------------------------
    PULSOUT 4, 1
    Main:
     DEBUG ? IN5, CR
     DEBUG ? IN6, CR
     DEBUG ? IN7, CR
     DO
     GOSUB levelselect
     GOSUB Out_595 ' put pattern on 74x595
     pattern = pattern << 1 ' shift pattern left
     'LOOP UNTIL (pattern = 128)
     'pattern  = 1
     IF (pattern = 128) THEN
     pattern = 1
     PULSOUT 4, 1
     ENDIF
     LOOP
     GOTO Main
    
    
     Out_595:
     SHIFTOUT SerData, Clock, MSBFIRST, [pattern] ' send pattern to '595
    'HIGH Latch
    'LOW latch
    PULSOUT 2,10
    
    
     RETURN
    
    
     levelselect:
    
    
     bittotal = IN5 + IN6+ IN6+ IN6+ IN7 + IN7 + IN7 + IN7
     IF bittotal = 0 THEN
     OUTH = 000001
     ELSEIF bittotal = 1 THEN
     OUTH = 000011
     ELSEIF bittotal = 2 THEN
     OUTH = 00000111
     ELSEIF bittotal = 3 THEN
     OUTH = 001111
     ELSEIF bittotal = 4 THEN
     OUTH = 011111
     ELSEIF bittotal = 5 THEN
     OUTH = 111111
     ELSEIF bittotal = 6 THEN
     OUTH = 111111
     ELSEIF bittotal = 7 THEN
     OUTH = 111111
    
    
     ENDIF
    RETURN
    

    There are probably some timing issues that I am overlooking. Due to time constraints I may switch to an arduino to utilize a Fourier transform library to process the signal and simplify my A/D conversion process as well.

    I am able to adjust the bands using a potentiometer for now.
Sign In or Register to comment.