Go Down

Topic: Shift Registers (Read 1 time) previous topic - next topic

dannyn382

Feb 02, 2013, 05:44 am Last Edit: Feb 02, 2013, 06:01 am by dannyn382 Reason: 1
Hello all,

I am working on a project where I need more IO pins. I am using an Arduino Uno, but I need 16 IO pins. I am using a screen to select which test to perform, but this will also set up the pins so some pins will be inputs and others will be outputs. Some tests I will need many inputs and few outputs, but others I would need many outputs but few inputs.

I was wondering if there was a way that I could add more inputs that I could assign as either inputs or outputs at run time as I do with the native digital pins. The 74HC595 can only output. The only solution that I could come up with was, have each pin of the chip being tested connect to two shift registers (74HC595 and CD4021BE). When the pin needs to be an input pin then use the first shift register. When the pin needs to be an output pin, use the second shift register.

Is there any other way to do this?

Thanks,

Dan

CrossRoads

You can use a "universal shift register" such as
http://www.digikey.com/product-detail/en/CD74HC194PWR/296-12794-1-ND/475917
These are 4 bits, use as many as you need for the IO needed.
Big price jump for 8  bits
http://www.digikey.com/product-detail/en/CY29FCT520BTSOC/296-33177-5-ND/1508292

IO lines controlled such that you can parallel load & shift in, or shift in for a parallel output.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

dc42


I am working on a project where I need more IO pins. I am using an Arduino Uno, but I need 16 IO pins.


You have 20 I/O pins on the Uno, so what's the problem? The 6 analog pins can be used as digital pins too.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

holmes4

See also I/O extender or expander.

Mark

dhenry

Quote
The 74HC595 can only output.


You can make it read too.

strykeroz

Hi,

As dc42 pointed out, you sound like you have enough IO pins if you use the analog pins as digitals.  They're addressed as  A0=D14 through to A5 = D19.  If that's not enough for you, there are also other alternative to shift registers such as the MCP23008 or MCP23017 IO expanders which will give you 8 or 16 additional IO ports via I2C (using A4 & A5 on the Arduino, but you can have up to 8 of these without consuming any more than those two IO pins)

Quote
The 74HC595 can only output.

You can make it read too.
Are you certain?  I've always thought the 74HC165 was for shifting in (but I've been wrong often, and recently :) )? 

Cheers  ! Geoff
"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

dannyn382

First of all thanks to everyone who has replied. I really appreciate it!


Quote
The 74HC595 can only output.


You can make it read too.



How can you do that? This thread seems to suggest that is not true, but I could be completely wrong? http://arduino.cc/forum/index.php?topic=103087.0 Do you know how?

Crossroads, do you know if these come in the DIP package as well? So each of the IO pins on this register can be configured to either in or out? I am trying to have one PCB where I can put any of the chips on and it will test it. Some of the chips pin 1 and 2 is in and out is pin 3, where other chips pin 1 is out and pin 2 and 3 are in. I am going to use a display and buttons to select which test to run, then the Arduino will configure the pins appropriately for the test that is going to be ran.

DC42, that will not work unfortunately. I need them all to be digital, and be able to input or output. The analog on my board is in only. If I am off on the pins numbers I am sorry. I have a display also that is on a 595 so I could be off by a few pins. Bottom line, I need more digital IO pins than are available to me on the board.

Strykeroz and holmes4, those two chips look very interesting to me. That actually might be what I am looking for!

Again, thanks for all your prompt responses!



Grumpy_Mike


Quote
The 74HC595 can only output.


You can make it read too.



Now come on dear henry you can't and you know it, or at least you should know it.

holmes4

Quote
DC42, that will not work unfortunately. I need them all to be digital, and be able to input or output. The analog on my board is in only. If I am off on the pins numbers I am sorry.


Which board do you have?

Mark

Grumpy_Mike

dannyn382
In the first post you said:-
Quote
I am using an Arduino Uno,

So this is wrong
Quote
The analog on my board is in only.

It is not. If you address the pins Analog in 0 as pin 14, Analog in 1 as pin 15 and so on these can be used as digital inputs or outputs.

dhenry

Quote
This thread seems to suggest that is not true, but I could be completely wrong?


You are not wrong. People saying "no" in that thread are wrong.

Not only it can be used as input, in some cases, the same pin can be used as input and output at the same time.

And it is a pretty old idea for embedded programmers.

Grumpy_Mike


Quote
This thread seems to suggest that is not true, but I could be completely wrong?


You are not wrong. People saying "no" in that thread are wrong.

Not only it can be used as input, in some cases, the same pin can be used as input and output at the same time.

And it is a pretty old idea for embedded programmers.


Stop beating about the bush you old **** and say how you get signals into the arduino from a serial input parallel output shift register.
Otherwise shut up.

dannyn382


dannyn382
In the first post you said:-
Quote
I am using an Arduino Uno,

So this is wrong
Quote
The analog on my board is in only.

It is not. If you address the pins Analog in 0 as pin 14, Analog in 1 as pin 15 and so on these can be used as digital inputs or outputs.


Grumpy Mike and Holmes, I apologize for my misinformed first post. I have done some more research, and it looks if you are indeed correct. I will try this soon and wire it up and see if I have enough pins now.

Strykeroz, I still like your idea of the MCP23008 or MCP23017 chips, and I might try this just to learn something new even if I can solve this particular project with the analog pins.

Thanks for everyone's help and input!

PeterH


It is not. If you address the pins Analog in 0 as pin 14, Analog in 1 as pin 15 and so on these can be used as digital inputs or outputs.


This dual nature of the analog inputs is very handy. I was surprised (but very pleased) to discover yesterday that it's even possible to enable the internal pull-ups while using the pin as an analog input - which was very convenient to reduce the external part count. It makes sense that it works, but it's certainly not something I'd have taken for granted.
I only provide help via the forum - please do not contact me for private consultancy.

arduinoadrian

I just needed to add 3 more lines (Output) so I used a 74HC138 and a 74HC14, I already had in my shop. No need to go get anything else. The thing works just fine. I used the 74HC14 because I already had NPN transistors mounted on the board, but with PNPs I wouldn't need it. It can be used to add 8 (Output) lines at the expense of using 3 to send it the code.
Perseverance is 90% of the solution. The remaining 10% is more perseverance.

Go Up