Currently, I'm working on a device that will control 25 different solenoids. As my little Arduino doesn't have enough pins to handle this many controls, I need to venture into the realm of Multiplexers. Using a multiplexer will allow me turn 4 of my I/O pins into 8 individually controllable signals for control. How does a multiplexer manage to do this? I assumed it was some sort of dark magic when I heard about this, but the logic behind the magic is pretty simple once you pull back the curtain. Each multiplexer takes in 4 different signals from 4 different pins on an Arduino. One of the signals is just a simple Off/ On signal, and the other 3 supply the logic behind the magic. For the 3 logic pins, it's a matter of mixing and matching the states of the 3 pins (High vs Low) to create multiple possible Output signals. Let's take a look at the board itself to help explain how this works. For this project I'm using SparkFun's Multiplexer Breakout board. The top half of the board contains the logic signals from my Arduino (S0, S1, S2), a common Off/ On signal (Z), as well as the connections for Ground and Power (GND and VCC). The bottom half contains the hookups for all 8 independent I/O signals (Y0-Y7). My solenoid controllers (MOSFETs) will be hooked up to these pins, allowing me to control 8 solenoids from each multiplexer. In order to send a control signal from one of the Y Out pins, you need to program the Arduino to do two things: 1- Set the Z pin to High (This is a basic Off/ On signal to turn the board on) 2- Send a specific permutation of High vs Low logic to the S0-S1 pins Using three different pin permutations, it is possible to get 8 different outputs. I've included the possible logic states from my code here below: /* Mux input/ Output matirx Input S0 = H S1 = H S2 = H Output = Y7 Input S0 = L S1 = H S2 = H Output = Y6 Input S0 = H S1 = L S2 = H Output = Y5 Input S0 = L S1 = L S2 = H Output = Y4 Input S0 = H S1 = H S2 = L Output = Y3 Input S0 = L S1 = H S2 = L Output = Y2 Input S0 = H S1 = L S2 = L Output = Y1 Input S0 = L S1 = L S2 = L Output = Y0 So as an example, if you set Z= HIGH, S0= LOW, S1=LOW, S2=LOW, the YO pin will be energized. If you set Z= HIGH, S0= HIGH, S1=LOW, S2=LOW, the Y1 pin will be energized If you set Z= LOW, SO= HIGH, S1=LOW, S2=LOW, nothing will happen because Z needs to be set HIGH to turn the board on. This little trick is nice as it allows you to control multiple multiplexer boards (which I will be doing), but keep the same 3 logic pins. **Note- For Rocket Scream pins A6 and A7 are analog input only and can't be used as output pins for this project In the above breadboard diagram, digital pins 0, 1 and 2 are being used as multiplexer logic pins for all 3 multiplexers. These pins are able to control the S0, S1, and S2 logic for all 3 boards. Digital pins 4, 6 and 8 are connected to the Z pins on each board, and control which of the 3 multiplexers are activated. And since this configuration only gives me 24 control signals, I need to add one extra which will be controlled by digital pin 10. **Note- Digital pins 0 and 1 are used by the hardware serial port on the Arduino Uno, and it's best not to use these pins as it can interfere with serial communications as well as uploading sketches. However this is not an issue with the Pro Mini's. This code is just a bare bones Arduino sketch outlining how to setup your multiplexer boards
0 Comments
Leave a Reply. |
AuthorAn electronics enthusiast looking for a place to gather his thoughts, ideas, diagrams, and code Archives
October 2016
Categories |