Digitally switch from 5V to Ground

I have a series of shift registers that I want to clear out via code. Basically, I want to switch the input to the clear pin to be switchable between the ground line and 5V line.

How would I go about making this circuit so that if I digital pin to HIGH, the clear pin will get 5V but if I switch that digital pin to LOW, it would get wired to ground?

Connect them together with a wire? Am I missing something here?

[quote author=Nick Gammon link=topic=177619.msg1317375#msg1317375 date=1373929774] Connect them together with a wire? Am I missing something here? [/quote]

I don't think so. ;)

Lefty

With 5V logic, HIGH is nominally 5V and LOW is nominally 0V (ground).

You won't get exactly 5V and ground*, but you don't need 5V and ground... If you look at the datasheet you can find the minimum input/output voltages or logic HIGH, and the maximum output voltages for logic LOW. In general, the output specs are tighter than the input specs, so that an output connected to an input always reads correctly. (But, this is not always true if you mix-and-match logic families.) In this case, you would need to check the input specs for your shift register and the output specs for the Arduino. You didn't tell us which shift register you are using, but there is a 99% chance it will work.

On the Arduino, a logic HIGH output is at least 4.2V and an a logic LOW output is 0.9V or less.

DVDdoug: With 5V logic, HIGH is nominally 5V and LOW is nominally 0V (ground).

You won't get exactly 5V and ground*, but you don't need 5V and ground... If you look at the datasheet you can find the minimum input/output voltages or logic HIGH, and the maximum output voltages for logic LOW. In general, the output specs are tighter than the input specs, so that an output connected to an input always reads correctly. (But, this is not always true if you mix-and-match logic families.) In this case, you would need to check the input specs for your shift register and the output specs for the Arduino. You didn't tell us which shift register you are using, but there is a 99% chance it will work.

On the Arduino, a logic HIGH output is at least 4.2V and an a logic LOW output is 0.9V or less.

Ahha, ok I was reading that if I pull a digital pin to LOW then it would be grounded but whenever I pulled this pin LOW, my registers would not clear which was showing that it wasn't truly grounded.

I am using 2 types of registers, 1 to push the current and the other to sink it. The datasheets are here: http://arduino.cc/en/uploads/Tutorial/595datasheet.pdf https://www.sparkfun.com/datasheets/IC/TPIC6B595.pdf

Like I said, when I pull it low the registers do not clear anything, they remain in the same state as they previously were. If I physically connect it to ground then it clears it out perfectly. I am using a Micro for my project.

I figure what I can actually do it put a NPN and PNP transistor between the ground and +5 and use 2 digital pins from the Arduino to first set them both to LOW (transistors off) before setting the desired one to on. I will try this when I get home from work today.

shiznatix: Like I said, when I pull it low the registers do not clear anything, they remain in the same state as they previously were. If I physically connect it to ground then it clears it out perfectly. I am using a Micro for my project.

Did you connect all the grounds together? (Micro and shift registers)

shiznatix:
Like I said, when I pull it low the registers do not clear anything, they remain in the same state as they previously were. If I physically connect it to ground then it clears it out perfectly. I am using a Micro for my project.

Schematic attached. I have all the grounds and everything setup and the shift registers / what they are controlling (LED matrix) are working just fine but I am having another strange issue with a radio receiver (see post here: http://forum.arduino.cc/index.php?topic=176751.0 - 2nd page for latest findings) so maaaybe I am not doing everything correctly with my wiring.

If anyone could take a look at the schematic I would appreciate it a lot.

schmatic.sch (29.1 KB)

``````Loading /Users/nick/Downloads/schmatic.sch ...

Error:

line 1, column 1: Start tag expected.
``````

Sorry, attached is a jpeg of my circuit.

You are describing standard TTL signalling and it is WHY all these logic chips exist... because they all use a standard definition of a logic "1" and a logic "0".

It sounds to me like you need to spend a few minutes and become familiar with TTL logic in general. Setting an Arduino pin "HIGH" or "LOW" means making the pin be logic "1" or logic "0"... effectively... HIGH = Close to 5V potential or LOW = Close to GND potential.

And your drawing is somewhat non-standard in the way it is drawn... basically, it's the equivalent of someone coloring outside the lines of a coloring book. It's particularly tough on the eyes when all labels are written ON the signal line, for example.

@pwillard - Im not sure I follow you on my issue being a TTL signaling thing. Which issue are you talking about, the shift registers not clearing when I set the pin to LOW or the idea I had of using the transistors to control true ground/5V? As far as I understand, the clear pin on the register needs a actual ground, not a "close to ground" signal to actually clear.

Or, am I doing something obviously wrong there that you could elaborate on?

Sorry about the drawing, I don't have any actual training or anything like that, just what I can figure as the best ways by myself. Do you have any examples / tutorials on how it should be done?

As far as I understand, the clear pin on the register needs a actual ground, not a "close to ground" signal to actually clear.

No you understanding is incorrect.

You do not need a transistor.

If you are not seeing the shift register clearing then you have something else wrong, the concept of wiring an ardiuno output directly to a TTL chip is fine.

The clear line only clears the shift register. To see the cleared levels on the output you also have to strobe ( pulse ) the latch line.

Grumpy_Mike:

As far as I understand, the clear pin on the register needs a actual ground, not a "close to ground" signal to actually clear.

If you are not seeing the shift register clearing then you have something else wrong, the concept of wiring an ardiuno output directly to a TTL chip is fine.

The clear line only clears the shift register. To see the cleared levels on the output you also have to strobe ( pulse ) the latch line.

Can you explain a bit or give a link to what a TTL chip is / does? As I understand it is just 2 transistors in series that are either a AND or a OR if both signals exist but this doesn't help me too much to get a real ground instead of the almost-ground that I get from a ditigal pin. That is why I was thinking the transistors with 2 digital pins controlling each separatly.

As for the latch pin strobing - do you mean just turning it on/off?

to get a real ground instead of the almost-ground that I get from a ditigal pin.

You need a signal that is 0.7V or less into a TTL chip so it sees it as a logic zero. This is compatible with what the arduino puts out.

So you do not need a transistor.

Can you explain a bit or give a link to what a TTL chip is / does?

http://en.wikipedia.org/wiki/Transistor%E2%80%93transistor_logic

As for the latch pin strobing - do you mean just turning it on/off?

Yes

shiznatix: As for the latch pin strobing - do you mean just turning it on/off?

We prefer the terms "low" and "high"...

quick wiki result since I don't commit exact details to memory...

Logic "0" = from 0 V to 0.8 V Logic "1" = from 2 V to VCC

Note: VCC = 5 V ±10%

Ok, I got it working by switching the cleanPin to LOW then cycling the latchPin. I just didn't realize I had to cycle the latch pin first.

Could there any reason though that having the clear pin set to HIGH would cause other parts of a circuit to misbehave or slow down? That is the issue I am having in this thread (http://forum.arduino.cc/index.php?topic=176751.15) and I thought that by doing this it would fix the issue but alas, it did not help.