I am using an arduino uno to make a decently large project (for me, anyways). Bottom line is, I'm going to need way more than 14 inputs. At least 34 separate inputs, maybe more, are for sure necessary. Also, I plan on using a ton (100?) of LED's, and would like to be able to individually control them.
I will only need access to one of these input/outputs at the same time, so I'm thinking an 8 input decoder should do the trick. Is there any way I can simply purchase one? Or will I have to make one myself? In any case, does anybody have access to a schematic or an example of using a decoder with an arduino board? Or am I looking at this in the totally wrong way?
2 x 74HC4067s (16 channel analogue muxs) will give you 32 inputs, you'll need 6 OPs (or 5 OPs and an inverter) to drive them + 1 to read the value.
Also, I plan on using a ton (100?) of LED's, and would like to be able to individually control them.
13 x 74xx595 shift registers. They'll need another 3 pins although they could share the mux control pins. There are examples in the playground I think.
Here's an example of using the 4067s
4 pins to select the channel, 1 to select the chip, and 1 more to read the input. (NOTE: just quietly, you don't have to use a Picaxe ;))
How about looking at a monome http://monome.org/ they come in various sizes and 100+ LEDs and switches is no problem. The problem with using lots of shift registers for inputs is that you have to constantly trad them to see if anything has changed. Where as with a port expander like the MCP23S17 there is an output that changes if any one of the 16 inputs change. These chips can be easily set to have 8 connected the arduino at once giving you 128 inputs or outputs or any mix of the two.
Ok so now a MUX seems to be the best way to go... I'm kinda new to this, so let me run this idea by you guru's out there and tell me what you think:
Say I have 25 inputs. Each of these inputs are going to be a switch of sorts (actually, a sensor, but thats unimportant- it will either return yes or no). Each of these inputs are expected to stay at whatever state they are in for a decent amount of time (ie, I won't need to worry about one of the switches rapidly changing state, and by decent amount of time, I mean probably over a minute). I could use one of the inputs on the arduino board to connect to the mux's output, and 5 outputs (2^5 = 32 > 25) as input to the mux to decide which input I want to check at a certain time. I can code the arduino to perpetually cycle through all inputs, one at a time, and store a variable for each one, and update all of them as it checks them.
I can then use ANOTHER mux, with one output as the output of the mux, and 7 outputs as the inputs to the mux (2^7 = 128 > 100) to set the state of the 100+ LED's I will be using. 1+5+1+7 = 14 = How many I/O's I have to work with.
Questions/Concerns:
Can I use a multiplexor in the way described above?
Can I use a multiplexor in reverse- (in the 100 LED example) where I SET values through it rather than just read them?
Given that I will be using arduino uno, how quickly do you think it could cycle through all of the inputs? All of the outputs?
Am I mistaken on how arduino I/O works? Can any individual port be treated as either input or output, however I specify it, or is there a set amount of input ports and a set amount of output ports?
I plan on being able to constantly be checking the inputs while updating the outputs by alternating a check on an input with a function call to something along the lines of update_LED() that will take one step every time it is called (each step being a "frame" aka configuration of lights in the "animation" that they LED's will be doing). I think this is the only way to simultaneously perform these functions with a single arduino. I'm assuming, but I figure it can't hurt to ask, that arduino does NOT have support for fork() system calls and the like, as there is no OS to run a scheduler?
These mux's (NOT decoders as I had mistakenly specified in my first post) are purchasable from stores? Any stores in mind, ie- radioshack? Anywhere good online to get good ones cheap?
Reeeaaaaalllly long post haha, so I appreciate whomever took the time to read all of it. Any help is appreciated!
EDIT
Lol, just realized I did not address the two previous responses...
First off, thank you for responding
Next,
That schematic is awesome, and made me realize what I wanted was a mux, and not a decoder. But, is there a way I could make it into one mux, rather than 2 with a chip select bit? Actually... I guess they are pretty much the exact same thing... haha so.. nevermind! That works awesome. But I do not know what a "shift" thing is (that you were saying in response to the 100 LEDs)... so my above questions still stand as to how to do that...
And to the next guy,
I'm making the inputs myself, and although that interface is sweet, I need a very specific one for this project, so thanks anyways!
Can I use a multiplexor in the way described above?
Yes.
Can I use a multiplexor in reverse- (in the 100 LED example) where I SET values through it rather than just read them
You can but the it will not work like you expect. They will flicker as they are only on for the time they are addressed. An with there being 100 of them they are only on 1/100 th of the time making them very dim.
Can any individual port be treated as either input or output,
Yes
hat arduino does NOT have support for fork() system calls and the like, as there is no OS to run a scheduler?
Haha wow, very simple, and very to the point. That's awesome!
And with the LED's, we plan on having all of them attached to a switch-type-thing that is connected to external power, so by referencing them, I'm not directly turning them on, I'm just changing the switch to open or closed, thus allowing me to have multiple LED's on at once!
...right? haha
Anyways, thanks for all of your help! I plan on referencing this community more in the future! ;D
EDIT
OK so a few questions still remain:
Given that I will be using arduino uno, how quickly do you think it could cycle through all of the inputs? All of the outputs?
Are these mux's (NOT decoders as I had mistakenly specified in my first post) purchasable from stores? Like a full on chip with 7 control inputs, and 128 outputs? Is that realistic? Any stores in mind, ie- radioshack? Anywhere good online to get good ones cheap?
Like a full on chip with 7 control inputs, and 128 outputs
Not that I've ever seen. The chips I drew are 74xx4067, they are the largest muxes I know of. But the good news is that you can buy them anywhere and if you want to use 7 then you finally get a chance to use a decoder.
The 74xx138 3-to-8 decoder will do.
OTOH if you have 7 free inputs on the Arduino you don't need any decoding, wire all the 4067 address pins in parallel and read 7 inputs at a time.
Anywhere good online to get good ones cheap?
Digikey, farnell, mouser
how quickly do you think it could cycle through all of the inputs?
So quick you won't even notice. For this application I don't think that's an issue, but a wet-finger-in-the-air guess would be well under 1mS.
B and C are just Picaxe terminolgy for port B and port C. Nothing sinister
is there support for two of them at once?
Normally with shields you can't use two of the same because, pretty much by definition, they use the same pins, but it depends on the design and I'm not sure about the Centipede.
Two Centipede shields are automatically supported by the library but there's a mechanical problem to overcome when stacking them...with connectors attached, you need really long pins on the top shield or a second tier of female passthrough headers.
The real power of the shield is reconfigurable I/O though, so I would recommend the already-described shift register approach instead, unless you are against building up your own hardware for time or skill reasons.
Ok I think I'm going to stay away from buying the centepides (for budget reasons), and go with the mux's. But I have one more question regarding your schematic-
you said those were the biggest mux's you could find, but you essentially doubled the size by creating a "chip selector" bit, essentially creating the exact equivalent functionality of a single mux with one more control input. Could I not then buy four of these mux chips, and add ANOTHER chip selector bit, doubling the amount of input by using one bit to decide between which set of two chips, and then another to decide to use either the first or the second of the specified group, thus making it the equivalent of a mux with two more inputs, and four times the output?!?!
Haha huuuuge run on sentence. Basic idea:
add another input, and use logic gates to AND the two "chip selector bits" to select chip one; NOT one and AND them both to select chip two; NOT the other and AND them both to select chip three; OR both and not the output to select chip four.
All of this to add the exact functionality of an n+2 input MUX as opposed to an n input.
Can I buy these logic gates? fyi- I have a small amount of experience working with logic gates in theory, and 0 experience in actually creating them...
Below is a site that shows how to individually control a lot of outputs from a parallel port. The parallel port probably could be replaced with two serial shift register chips in series. A similar setup could be used to interface with a lot of analog input MUX chips. In the past I've tinkered with the 74HC259 latching mux/demux chips for controlling things via the parallel port.
you said those were the biggest mux's you could find
That's right.
but you essentially doubled the size by creating a "chip selector" bit, essentially creating the exact equivalent functionality of a single mux with one more control input.
Also right, but the individual muxes are still the largest I know of
Could I not then buy four of these mux chips, and add ANOTHER chip selector bit, doubling the amount of input by using one bit to decide between which set of two chips, and then another to decide to use either the first or the second of the specified group, thus making it the equivalent of a mux with two more inputs, and four times the output?!?!
add another input, and use logic gates to AND the two "chip selector bits" to select chip one; NOT one and AND them both to select chip two; NOT the other and AND them both to select chip three; OR both and not the output to select chip four.
All of this to add the exact functionality of an n+2 input MUX as opposed to an n input.
You could do all this, but fortunately companies like Texas Instruments have already done it for you. If you go back a couple of posts you'll see I referred to the 74xx138, it's a 3-to-8 decoder. This will take 3 signals from your uC (in binary format) and lower one of its 8 outputs according to the pattern on the three inputs. So connect these outputs to as many as 8 muxes and you have up to 128 inputs.
If you don't need 8 then just connect as many as required.
Of course all this is only good for your inputs, not the outputs.
DO need to access one output at a time, so it SHOULD work, for both in and output... right?
Maybe, depending on exactly what you have to do.
You talked about 100 LEDs and 34 inputs in the OP. Do you monitor the inputs then turn on a single LED for a while based on those inputs then go back to monitoring the inputs.
I plan on having all of the LED's connected to a power source at all times. The only thing in between the LED and the power source will be a switch of sorts. I will use the output mux not to access the LED's directly, but to access the switches, one at a time, instead; either turning them on, allowing current to flow through, or turning them off, stoping current from flowing through. I SHOULD be able to turn all of them on by one cycle through the outputs of the mux's, turning all of the switches on. Then they should all stay on until I flip the switches off. This should work... right?
Ha sorry about being so unsure about all of my plans, but I figure since I'm very new to this, I can't get to confident before rigging up a huge project, and you guys would be the ones to ask!
While I'm asking...
Is there a specific multiplexor serial number you guys suggest? Is that number you listed on the schematic something I could tell a radio shack guy and he would be able to point me to exactly what I need?