Shift Register Problem

Author
precesh
New Member
  • Total Posts : 21
  • Reward points : 0
  • Joined: 2008/10/20 12:35:16
  • Location: 0
  • Status: offline
2010/11/17 08:49:40 (permalink)
0

Shift Register Problem

Hi all,

I'm using 2 x 14 pin 74HC164Ns, cascaded together, to operate an LCD, 3 LEDs and a Piezo sounder. Controlled by a PIC16F874. Running at 4MHz.

My problem is: when I write to the shift registers, I get a clicking sound on the Piezo, and flashing on the LEDs. The LCD is unaffected as I'm driving the en input directly from the PIC.

The PCB has already been designed and manufactured, so I am a bit stuck. Even toggling the clear input on the shift register doesn't solve the problem.

Ideally I should have used a shift register with tri state outputs such as the 595. However I am stuck with making what I have here work.

Possible solutions:

a) run the PIC at a higher speed?
b) fit a small filter to my LED and Piezo outputs (which are on flying leads) so they ignore these very short signals?

I'd appreciate your comments on the above - many thanks.

Phil
#1

9 Replies Related Threads

    DarioG
    Scheisse Menschen
    • Total Posts : 52256
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: hi there
    • Status: offline
    Re:Shift Register Problem 2010/11/17 11:08:29 (permalink)
    0
    Hmm, dont those Shift Registers have a "Latch" pin that allows avoiding the glitches?

    Maybe the 595 do...

    Dario Greggio
    --
    Wouldn't it be wonderful, if you lost one son for every promise you don't keep?
    #2
    BradLevy
    Starting Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2007/10/23 15:21:30
    • Location: Kansas
    • Status: offline
    Re:Shift Register Problem 2010/11/17 12:54:53 (permalink)
    0
    Shifting more quickly (either through faster processor clock or more efficient code) can help, but depends in part on the structure of your code. Strategy depends in part on how often you are outputting data to the LCD  I am presuming (since you mention an enable) that your LCD is a module with a controller chip, not just a non-mulitplexed display. Thus, updating the LCD may involve a series of output transactions.

    If you are updating the LCD at a fixed interval (for example, once per second, based on an interrupt, not on how fast the processor is executing), then shifting more quickly can help. But if your code is structured such that doubling the processor speed doubles how often you generate data out to the LCD, the speedup will not help the LED and piezo problem, because the duty cycle of ones to zeroes through the shift register will be the same as at the slower processor speed.

    An analog filter could help if you are only shifting data out in infrequent bursts (relative to processor speed). If you are doing frequent data transmission via the shift register (such as drawing lines on a graphic LCD), the duty cycle of [time the LED bits are wrong] to [time the bits are right] will be too high, and the filter will not help. A digital filter (sensing when the outputs have been unchanging for more than the time it takes to shift 16 bits through the register, and latching the data on when that threshold passes) would solve it (as long as you made sure to enforce a corresponding dead time in your code after outputting to the LED and piezo data). But implementing the digital solution might cost more than re-spinning your original board.


    -Brad Levy
    #3
    Ian.M
    Super Member
    • Total Posts : 13030
    • Reward points : 0
    • Joined: 2009/07/23 07:02:40
    • Location: UK
    • Status: offline
    Re:Shift Register Problem 2010/11/17 13:52:20 (permalink)
    0
    You may be able to alleviate things if you split the two shift registers and clock them separately.  Assuming you have a PIC pin spare, you just need to cut the track to the second one's CP and the track linking Q7 of the first and whichever DS pin you are using on the second one, wire the DS pin to the corresponding pin of the first one and wire the CP pin to the spare PIC pin.  Assuming the LCD is on one chip and the sounder and LEDs are on the other,  at least LCD writes will no longer cause flashes and clicks.
    #4
    K8LH
    Super Member
    • Total Posts : 1871
    • Reward points : 0
    • Joined: 2004/03/26 05:12:34
    • Location: Michigan, USA
    • Status: offline
    Re:Shift Register Problem 2010/11/17 14:36:24 (permalink)
    0
    Ouch!  A single 74HC595 could have been used as the LCD interface (4-bit mode) and to drive four LEDs (or three LEDs and a piezo) and to drive four push button switches and/or jumpers.

    Cheerful regards, Mike


    post edited by K8LH - 2010/11/17 14:40:47

    Attached Image(s)

    #5
    sborden
    Super Member
    • Total Posts : 1932
    • Reward points : 0
    • Joined: 2010/08/05 02:12:53
    • Location: 0
    • Status: offline
    Re:Shift Register Problem 2010/11/17 14:58:38 (permalink)
    0
    The tri-state is not what is killing you.  It is the fact that you have no memory on the outputs, which a 595 does.  Doing a master clear will only make your problems worse since it forces even another write  to the outputs.

    If you have flying leads, then consider a small PCB with something like a CD4508 that can latch your outputs between shifts.
    #6
    DarioG
    Scheisse Menschen
    • Total Posts : 52256
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: hi there
    • Status: offline
    Re:Shift Register Problem 2010/11/17 16:45:29 (permalink)
    0
    glad I pointed to the right path Smile

    Dario Greggio
    --
    Wouldn't it be wonderful, if you lost one son for every promise you don't keep?
    #7
    precesh
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2008/10/20 12:35:16
    • Location: 0
    • Status: offline
    Re:Shift Register Problem 2010/11/18 01:48:26 (permalink)
    0
    Guys, thanks for your help - you are abolutely right. I have just raised the PIC speed from 4MHz to 8MHz, and the problem has reduced but not gone away.

    I am shifting data out infrequently, so an analogue filter may be a good workaround.

    Could anyone suggest a simple filter circuit for the LEDs and sounder? Filters not my strong suit! The LEDs and sounders are running at 12v. There is already a 220R resistor in series with each of the 3 LEDs. The piezo sounder is running straight off the 12v. I am using a the shift registers to drive a ULN2003 darlington IC. Each of the LEDs and sounders gets 12v, then I pull the other side down to 0v via the darlington.

    Ideally I would like to run the PIC back at 4MHz so as to leave my other timings unaffected. It takes me approx 12 - 13 clock cycles to clock a bit down through the shift register.

    Many thanks,

    Phil
    post edited by precesh - 2010/11/18 01:49:53
    #8
    1and0
    Access is Denied
    • Total Posts : 6614
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re:Shift Register Problem 2010/11/18 10:17:40 (permalink)
    0
    precesh
    Guys, thanks for your help - you are abolutely right. I have just raised the PIC speed from 4MHz to 8MHz, and the problem has reduced but not gone away.
    ...
    Ideally I would like to run the PIC back at 4MHz so as to leave my other timings unaffected. It takes me approx 12 - 13 clock cycles to clock a bit down through the shift register.

    Have you also tried unrolling the code for the shift register?
     
            bcf     DS          ;set data bit
            btfsc   databyte,7
            bsf     DS
            bsf     CP          ;clock it
            bcf     CP
    ;
            bcf     DS          ;set data bit
            btfsc   databyte,6
            bsf     DS
            bsf     CP          ;clock it
            bcf     CP
    ;       ...
    #9
    BradLevy
    Starting Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2007/10/23 15:21:30
    • Location: Kansas
    • Status: offline
    Re:Shift Register Problem 2010/11/18 12:11:51 (permalink)
    0
    > There is already a 220R resistor in series with each of the 3 LEDs.

    If these are garden variety LEDs, not specifically ones with a high forward voltage or designed for high power operation, you are operating them at 36 to 50 milliamps, which is may be more than their rated continuous forward current. Increasing the series resistor will help reduce the visibility of the unintentional illuminations as well as improve the lifespan of the LED. 

    For the filtering, try about a 1 uF capacitor across each LED, so you have the (LED || Cap) in series with the resistor.

    You can put one across the piezo, too, but you'll want to add a resistor in series with the piezo, like with the LED.

    -Brad Levy
    #10
    Jump to:
    © 2017 APG vNext Commercial Version 4.5