2
\$\begingroup\$

I am trying to use an SN74LS164 8-bit serial-to-parallel shift register with my Raspberry Pi, but I have some problems.

I connected:

  • VCC, A, B and CLR to +5V
  • GND to 0V
  • CLK to Raspberry Pi GPIO

schematic

simulate this circuit – Schematic created using CircuitLab

When I power-on the circuit, all the LEDs are off. Then I send a clock pulse from the Raspberry Pi (go high for 100ms then go low). However instead of having the just first output (QA) go high, the first 3 or 4 outputs go high (QA, QB, QC and QD).

What am I doing wrong?

I took some photos of the scope, the first is the clock from the GPIO (without nothing) and the second is the clock connected to the register.

Clock only

Clock connected to register

-- EDIT --

I added capacitors and MOSFETs to respect max output current. I re-added pull-down resitor on clock line because of the natural +1V offset (this offset come from the register not the pi)

\$\endgroup\$
  • 3
    \$\begingroup\$ Do you have an oscilloscope? You are probably getting multiple pulses instead of just one. Or, the pulse has a ragged edge(s) and the 164 is actually clocking several times. You should use a 74HCT164 instead of the LS version. You might simply have a logic level compatibility issue between Pi and the LS164 inputs. \$\endgroup\$ – FiddyOhm Aug 5 '16 at 22:59
  • 1
    \$\begingroup\$ Might be missing decoupling capacitors too. \$\endgroup\$ – Transistor Aug 5 '16 at 23:20
  • 1
    \$\begingroup\$ @FiddyOhm Reading the datasheet here, I can't find an issue with the logic levels. The thresholds are 0.8 and 2 volts, and it shouldn't draw enough current to sink the raspberry pi's output, even if it's just 3.3 volts. \$\endgroup\$ – pipe Aug 6 '16 at 0:08
  • 3
    \$\begingroup\$ @JamesMagnus - (c) Although this might not be causing your problem, your circuit has the LS164 sourcing current to the LEDs, targeting up to (5V-2V LED drop)/300 Ohm = 10mA per LED (though VOH will drop, also reducing the LED current). Look in the LS164 datasheet & notice recommended max IOH = 0.4mA (400uA), which is typical for totem-pole LS TTL outputs. See this answer to a previous topic, for more info. Better to use 1k resistors & use the LS164 to sink the LED current (i.e. connect the LEDs + resistors between the outputs and 5V rail). \$\endgroup\$ – SamGibson Aug 6 '16 at 1:06
  • 2
    \$\begingroup\$ You have an unexplained 1V offset. Perhaps this has something to do with your problem. Finding out where that offset comes from should be the absolute first priority here. \$\endgroup\$ – Scott Seidman Aug 7 '16 at 1:00
1
\$\begingroup\$

I resolved my problem. The register was clocking multiple times because the clock signal wasn't enough clean. So I added a schmitt trigger between the raspberry pi and the register clock input, and now it shifts exactly the number I want.

Thanks for all your advices and suggestions, have a nice day ;)

\$\endgroup\$
1
\$\begingroup\$

A Low power Schottky input typically sits at about 1.3V when open circuit, and sources ~0.25mA when pulled low (<0.8V). The Pi should have no trouble driving this load, but in your case it only managed to pull the clock input down to ~1.1V.

You got it down to 0V with a pull-down resistor, which suggests that the LS164's input is OK and your Pi's GPIO line is not pulling down properly. Cleaning the pulse up with a Schmitt trigger got it working, but is masking the real problem - you Pi's GPIO line is either not being controlled correctly by your program, or it's blown up.

\$\endgroup\$
  • \$\begingroup\$ I know there is a pull down and a pull up in the raspberry pi when you configure the GPIO as input, but is there a pull down when you are in output mode? \$\endgroup\$ – James Magnus Aug 8 '16 at 22:43
  • \$\begingroup\$ Output mode is push-pull with at least 2mA sink capability. scribd.com/doc/101830961/GPIO-Pads-Control2 \$\endgroup\$ – Bruce Abbott Aug 9 '16 at 0:17
0
\$\begingroup\$

Take a peek at the data sheet. This chip can't drive the kind of current you want it to. Thus exceeding operating conditions, all bets are off.

\$\endgroup\$
  • \$\begingroup\$ I use leds to see what happen. In real I will put mosfets to control a (big) led board. In the datasheet it's -400 µA so should the voltage be negative at the ouputs? \$\endgroup\$ – James Magnus Aug 6 '16 at 21:37
  • 1
    \$\begingroup\$ Negative seems to indicate source current, and positive sink current. You should test with the FETs in place. \$\endgroup\$ – Scott Seidman Aug 6 '16 at 21:44
  • \$\begingroup\$ Ok I m going to try with the FETs to respect the output current \$\endgroup\$ – James Magnus Aug 6 '16 at 21:50
  • \$\begingroup\$ You might even need to replace the shift register, but probably not. \$\endgroup\$ – Scott Seidman Aug 6 '16 at 21:54
  • 1
    \$\begingroup\$ Better yet, @JamesMagnus, you have a scope. Just disconnect the LEDs and use the scope to check outputs. You haven't shown code, so we're tang you're word that your clock is one pulse at a time, but you should certainly verify that you're not clocking more than once \$\endgroup\$ – Scott Seidman Aug 6 '16 at 21:57
-1
\$\begingroup\$

You likely have reflections on your clock line, causing it to be treated as multiple clock pulses. The length of your clock wire might be a factor in this. If your wires are already short, then consider adding a signal integrity resistor (20-50 ohms) in series with the clock pin (as close to the driver as possible).

\$\endgroup\$
  • \$\begingroup\$ That's a good guess, but the recent oscilloscope pictures (posted after your answer) looks pretty clean. \$\endgroup\$ – pipe Aug 6 '16 at 20:24
  • 1
    \$\begingroup\$ That's pretty far fetched, given the frequencies involved. \$\endgroup\$ – Scott Seidman Aug 6 '16 at 21:04
  • \$\begingroup\$ Looks pretty clean but you need to zoom way in to know for sure. Also, why does the scope only show 2Vpp in one picture? \$\endgroup\$ – kjgregory Aug 6 '16 at 21:22
  • 1
    \$\begingroup\$ The measurement (or what I think is the measurement) number in all the screen shots says 3.3 v. Have you ever had bounce problems using a simple microcontroller DIO, especially at low freq? Hasn't ever happened to me. When the asker is sourcing more than the chip can do by more than a factor of 10, I'd look there first. \$\endgroup\$ – Scott Seidman Aug 6 '16 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.