This post is more about a cool Arduino Shield I made for the Arduino Uno, I was working with some CD4051BC chips on a project and figured I would breadboard and use an arduino to test a few ideas. Curious I thought someone might have come up with an analog expander shield or similar but alas I couldn’t find one, maybe I didn’t look very hard! In any case I threw together a Shield for the Arduino and you can see it here http://blueberryde.com/shop/24-channel-analog-expander-shield/
The plan was to achieve an expansion of 24 Analog Inputs with a minimal loss of Arduino onboard I/O / ADC. I chose to use the i2C bus which on the Uno (ATMEGA 128 and 328 chips) is A4 and A5. This allowed me to drive 3 8ch mux chips using only pins A4 and A5 that are talking to a MCP23008. The MCP23008 in turn controls pins A, B and C on the Mux CD4051BC chips, then we just needed to control the Enable pins of each of the 3 Mux IC’s to give us complete control over the entire 24 inputs of the 3 CD4051BC’s. Then we needed to utilize one more pin to allow us to check the Analog signal from the Mux chips, A3 was chosen for this.
The Code / Library
To make things easier ladyada/Adafruit had already written a library to utilise the MCP23008, so we where left only to do something about handling the selections of which pin to read from and when! I wrote a library that makes this VERY easy! Much like reading a standard arduino Pin IE val = analogRead(PIN);
We simply load the library BlueberryDE_Mux and begin an instance if much like any other library. Then we can simply communicate with the library like this val = mux.AXread(PIN); where the pin value is a number from 0 – 23 relating to inputs AX0 – AX23.
The Shield, library and more information can be gained from visiting my other site BlueberryDe.com !
In an effort to have the shield play well with other shields long legged headers are used so the pins are repeated on the top side, a i2C Address header is placed on the top side where an alternate i2C address can be chosen to facilitate other i2C hardware. Along with this I’ve also produced the board on a 2mm thick PCB instead of the standard 1.6mm providing a bit more rigidity. All components are quality SMT and are reflowed. All Components are placed on the underside for added safety while in use and the AX0 – AX23 inputs are placed on a single 24 pin header slightly away from the standard analog Inputs of the Arduino. The header is provided with the shield un-soldered for those of you who may want to join wires directly instead and don’t want the annoying task of de soldering 24 pins on a 2mm PCB!