Shop OBEX P1 Docs P2 Docs Learn Events
Problem with 74HC595 shift register initializing with %11111111 — Parallax Forums

Problem with 74HC595 shift register initializing with %11111111

edlikestoboogieedlikestoboogie Posts: 71
edited 2010-06-26 04:20 in Propeller 1
I am using a 74HCT595 shift register to control some mosfets hooked up to water pumps. Problem is, the 74HCT595 turns on all parallel outputs on HIGH, for about 2 seconds when my project powers up. I was told these things turn on with all outputs on LOW. Is there any way, hopefully in software, to deal with this issue? I think the outputs source to HIGH once init() is called in Simple_74HC595.spin available in the obex, than finally sink to LOW.

Please help with this annoying problem, and thanks in advance.

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2010-06-13 05:53
    edlikestoboogie,

    Any way you can post a schematic? The 74HCT595 has a tri-state output and is in high impedance mode if the OE is low... without looking at a schematic it's hard to tell but a simple pull-up or pull-down in the right location during power-up might solve the problem.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-06-13 06:29
    Does the propeller boot up with pins in tristate?

    If so, then the OE input on the HC595 will be floating and picking up stray voltages, eg from nearby mains wiring and will randomly input data. Beau I think has the answer. If you want the outputs in tristate, pull OE high with 10k resistor.

    That still doesn't quite solve the problem if the mosfet is driven directly off the HC595 outputs, as the mosfet gate could also be picking up stray voltages if it is floating. But if you pull the gate of the mosfet low with another 10k resistor, that means all the tristates will default to the pump being off.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-06-13 08:12
    The 595 has a clear input on pin 10 which you can tie to the Prop's reset as this line is also an output from the Prop when BOE is tied low which is generally the case.

    Have you had a look at the TPIC6C595 and similar range? They are essentially a 595 shift-register and eight MOSFETs on the one chip suitable for driving solenoids etc. There is also the Allegro 5821 that are similar too. I have used both these devices with the Propeller.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-06-13 20:06
    Peter Jakacki said...
    The 595 has a clear input on pin 10 which you can tie to the Prop's reset as this line is also an output from the Prop when BOE is tied low which is generally the case.
    It would be so nice if that were true, but unfortunately it's not. /RST is pulled up when /BOE is tied low, but it's never driven low by the Prop [noparse]/noparse][b]edit:[/b][i] except during a brownout condition once Vdd has already been establised[/i, which means the '595 would not get reset at power on. You could, however, attach an inexpensive open-drain supervisor chip to the Prop's /RST pin to handle the power-on condition.

    -Phil

    Post Edited (Phil Pilgrim (PhiPi)) : 6/14/2010 12:55:50 AM GMT
  • edlikestoboogieedlikestoboogie Posts: 71
    edited 2010-06-13 23:19
    Hi guys,

    Sorry about the late reply.

    Here Is the schematic i am using on a PCB. I will read your posts and suggestions after I take an exam tomorrow.

    Thanks for all the help.

    Post Edited (edlikestoboogie) : 6/13/2010 11:25:24 PM GMT
    707 x 465 - 36K
  • StefanL38StefanL38 Posts: 2,292
    edited 2010-06-13 23:46
    OK there it is:

    quoting from the 595 datasheet:

    "The storageregister has 8 parallel 3-state
    busdriveroutputs. Data in the storageregister appears at
    the output whenever the outputenableinput (OE) PIN13 is LOW."

    You tied the outputenableinput to VSS = GND=LOW

    If you add a pullup-resistor from PIN13 to Vdd and connect the PIN13 to a prop-IO-PIN
    you can switch ON/OFF the output-stage by setting this prop-IO-pin to output and then set it to LOW

    By default all prop-IO-pins are defined as input at powerup

    If you don't want to use a prop-pin you could use a RC-circuit and a transistor which inverts the signal
    on powerup the capacitor starts to charce and after some time the transistor switches to enable the
    output-stage

    best regards

    Stefan
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-06-14 00:18
    Phil Pilgrim (PhiPi) said...
    Peter Jakacki said...
    The 595 has a clear input on pin 10 which you can tie to the Prop's reset as this line is also an output from the Prop when BOE is tied low which is generally the case.
    It would be so nice if that were true, but unfortunately it's not. /RST is pulled up when /BOE is tied low, but it's never driven low by the Prop, which means the '595 would not get reset at power on. You could, however, attach an inexpensive open-drain supervisor chip to the Prop's /RST pin to handle the power-on condition.

    -Phil

    Hmm, I just read the datasheet again and it is an output but I am guessing then that it is only an output during a brown-out rather than a power-up?

    Brown Out Enable (active low). Must be connected to either VDD or VSS. If low, RESn becomes a
    BOEn I weak output (delivering VDD through 5 kΩ) for monitoring purposes but can still be driven low to cause
           reset. If high, RESn is CMOS input with Schmitt Trigger.
    
    



    I haven't actually used /RST as an output so what is the datasheet saying then? Of course a simple capacitor to ground on the reset pin won't hurt and it will generate the reset required for the 595.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-06-14 00:51
    I just checked it with a scope, and /RST does get pulled low ahead of Vdd going to zero when power is removed. But there's no symmetrical behavior during powerup: /RST tracks Vdd almost exactly. Also, an internal software-generated reset does not affect this piin. (The datasheet really needs to be much clearer about the behavior of the /RST pin.)

    -Phil
  • edlikestoboogieedlikestoboogie Posts: 71
    edited 2010-06-14 22:43
    I'm still not sure what I should do.. the TPIC6C595 doesn't seem to be able to handle my 1 amp pumps.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-06-14 23:05
    edlikestoboogie said...
    ... the TPIC6C595 doesn't seem to be able to handle my 1 amp pumps.
    Well, no, given that the datasheet specs each output at 100mA and 250mA total for the whole chip, that's not too surprising. You will probably have to use a 75HCT595 to drive individual power MOSFET transistors to handle the one-amp loads. BTW, Parallax's Digital I/O Board Kit would be ideal for your app.

    -Phil
  • hover1hover1 Posts: 1,929
    edited 2010-06-14 23:05
    The TPIC6C595 can not handle 1 AMP per output. (I believe this is the first time the current came up). 1/10 Amp at best with all outputs on. 1/4 AMP with one ouptput on :

    Per Data Sheet:
    Continuous source-to-drain diode anode current 250 mA 
    Pulsed source-to-drain diode anode current (see Note 3) 500 mA 
    Pulsed drain current, each output, all outputs on, ID, TC = 25°C (see Note 3) 250 mA
    Continuous drain current, each output, all outputs on, ID, TC = 25°C 100 mA 
    Peak drain current single output, IDM,TC = 25°C (see Note 3) 250 mA
    
    

    If the original MOSFETS where handling the load, I would go back to them. It seemed you had the power licked, now to tame the logic.
    Jim
    edlikestoboogie said...
    I'm still not sure what I should do.. the TPIC6C595 doesn't seem to be able to handle my 1 amp pumps.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-06-15 02:29
    Yes, the 6595 handles up to 250ma continuous for each output even if all are on so that's a total of 2A for the chip. The 6C595 only handles 100ma per output. I forgot that you mentioned pumps and I was thinking about solenoids but I didn't have any indications as to the current requirements previously.

    If you use the 74HCT595 you could just drive two FDS6990A or similar dual MOSFETs which are packaged in tiny 8-pin SMD packs and these handle up to 7A for each output. So your total surface would be no more than the equivalent of two 16-pin SMD packs.
    search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=FDS6990ACT-ND

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • edlikestoboogieedlikestoboogie Posts: 71
    edited 2010-06-15 05:45
    The bigger problem is the HIGH start up that is annoying me to death. Anyone else with any bright ideas?
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-06-15 06:04
    I thought I answered that more than CLEARly enough. The 595 has a CLEAR input, just put a 1uf cap to from pin 10 to ground and add a pullup of around 10K or more as that will generate an automatic clear on power-up. (The Prop's reset line is not usable for this we established). I would always tie OE low so that the MOSFETs are driven and not left floating.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-06-15 07:09
    I would also add a diode in parallel with the pullup resistor "pointing" towards Vdd. That way, the cap will discharge more quickly on a power-down. Your program will have to account for the time that it takes the cap to charge before you start sending data to the '595.

    IMO, a better solution is to use an open-drain supervisor chip whose output is tied to both /RST and /CLEAR. That way, the Prop and '595 will reset at the same time on power-up, and you won't have to worry about capacitor charge delays.

    -Phil
  • StefanL38StefanL38 Posts: 2,292
    edited 2010-06-15 14:18
    to add again:

    the HIGH startup is NOT solveable with pure software changes. You have to change your HARDWARE as suggested above

    best regards

    Stefan
  • Bill HenningBill Henning Posts: 6,445
    edited 2010-06-15 16:45
    FYI,

    I have a module with SSR's capable of 500mA continous current on each of eight outputs at up to 60VDC; details in my Morpheus thread.

    See DIG-OUT-8-V on the bottom of page 10. It's designed to work with any Prop board [noparse]:)[/noparse]

    http://forums.parallax.com/showthread.php?p=818362

    I should be receiving the boards today! (according to UPS)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.mikronauts.com E-mail: mikronauts _at_ gmail _dot_ com
    My products: Morpheus / Mem+ / PropCade / FlexMem / VMCOG / Propteus / Proteus / SerPlug
    and 6.250MHz Crystals to run Propellers at 100MHz & 5.0" OEM TFT VGA LCD modules
    Las - Large model assembler Largos - upcoming nano operating system
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-06-15 17:18
    I just took another look at the '595 datasheet. The /SCLR pin is asynchronous for the shift registers but synchronous for the output registers. To clear the outputs, you have to assert /SCLR low then send a pulse to RCLK. This means that the cap and supervisor techniques will not work. So forget anything to do with /SCLR.

    Try this instead: Tie /SCLR high, and connect /G to a Prop pin along with a pull-up resistor to Vdd. All of the '595 outputs need to have pull-downs as well. But, if you're driving MOSFET gates, you'd do that anyway. With this configuration, any time the Prop pin driving /G is tri-stated (such as during a reset), /G will go high disabling the outputs, and the pull-downs on the outputs will inhibit the MOSFET drives.

    To start up after a reset, load the shift register with zeroes, pulse RCLK, then assert the /G pin low.

    -Phil

    Post Edited (Phil Pilgrim (PhiPi)) : 6/15/2010 5:24:04 PM GMT
  • edlikestoboogieedlikestoboogie Posts: 71
    edited 2010-06-16 00:35
    Hey Phil,

    I will try what you said tomorrow, but I am wondering, should I use the code Simple_74HC595.spin (which loads a cog and listens for commands), available in the obex, and modify it to do what you said, or should I start from scratch and use BS2 functions like shiftout and pulsout to completely start from scratch? What would you do?

    and is it necessary to use a cog to manipulate the '595? I would rather not use a cog and use shiftout and pulsout to control it ONLY when I want to turn a pump on/off. I am assuming the writers of the obex code were using a cog for fast speed?

    thanks and if anyone else has suggestions I should try tomorrow, please let me know.
    Ed.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-06-16 02:58
    You could do it all in Spin and not use an extra cog.

    -Phil
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-06-16 03:07
    @Phil: How about that, so the CLR is useless in other words for most things and you need an extra line just for the OE then. That makes that 4 I/O plus the shift-register for a few pumps, why bother with the shift register then.

    This is why it's easier to use the existing I2C lines and standard I2C chips or dedicate a cheap micro for these tasks. That way there is never an issue with losing I/O pins etc. However for simple I/O such as leds etc the shift register approach is fine and non-critical although it always requires I/O lines. In this regard I have found it convenient to always use the I2C lines as general-purpose CLOCK and DATA OUT so that even though shift-registers would pick up chatter from other I2C transmissions it is only when the output register is clocked that it is valid. So therefore a single output register chain would only need a single I/O pin plus the two existing I2C pins.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • edlikestoboogieedlikestoboogie Posts: 71
    edited 2010-06-16 04:50
    @Peter: I'm confused, 4 I/O pins extra plus the three for the shift register (sck, data, latch)? I thought phil just wanted me to connect two signals to my prop, on top of those three signals, /G and /RCLK. And he wants me to connect \SCLR to VDD. Wouldn't that be two extra prop pins on top of the three? You are right though, this solution is starting to be a bad idea, with all the pins used. What I2C chips were you suggesting, hopefully under $1? I have to output 5v since I am using the mosfets, before this I tried using a TTL hex inverter, but this also outputted HIGH on start up, should I have used a non-inverting TTL buffer?
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-06-16 05:48
    SCLK, SDAT, RCLK, OE are 4 outputs, not extra. The RCLK is the latch for the output register.

    Not sure what the go is with keeping it under $1 unless you are making lots and lots of these. How much is a cheeseburger and a can of coke these days?
    Had a quick look at Mouser and for around a buck you can have the PCA9670 plus there are many other devices besides. I use cheap PIC chips in the $1 to $2 range and program them for I2C I/O and more besides. The same with a few other breeds of micros as well.

    The MOSFETs that I mentioned earlier are very happy with 3.3V drive, no need for 5V at all.

    KISS - Keep It Sweet & Simple (censored version) - don't add more stuff and complicate what is simple to start with, take stuff away, you only need a single chip and the MOSFETs. I don't know how many outputs you need but if you need a few then the I2C is certainly a way to go and doesn't use any extra Prop I/O, just P29,P28.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • edlikestoboogieedlikestoboogie Posts: 71
    edited 2010-06-26 04:20
    I am just posting to confirm that the above solution given by Phil works. Thank you Phil.
Sign In or Register to comment.