PDA

View Full Version : HYDRA RE: MCP23008 for relays


WindowMaker
01/21/2012, 10:45 AM
I know there are several people involved in the Hydra project on here. I have a few questions about the use of the MCP23008 to serial control a bundle of relays.
I have 8 of the opto relays from Futurlec that run fantastically on my mega. The problem is that They use up a lot of pins, and will be even more annoying when the relays are placed into their own external power bar. I would like to use either cat5 or db9 to send signal to the relays but that obviously wont work if I need to use 10 pins.

using an i2c controller like the MCP is a great idea! but I dont have much knowledge on i2c or how it is connected. The power bar page on the hydra site provided some insight but didnt go into where the .1uf cap is to be used or what reference the address pins will have depending on how they are connected.

Any insight here is greatly appreciated!

terahz
01/22/2012, 10:06 AM
Hi WindowMaker,

The MCP23008 is fairly straight forward to to hook up. The cap goes from power input (VDD - pin 18) to ground. The address is determined by the A0, A1 and A2 pins (pins 5, 4 and 3 respectively). It is a 7bit address 0100(A2)(A1)(A0). So if you set all the Address pins to 5V (1) the address will be 0100111.

I have written some code in my Hydra firmware for controlling the Futurlec relays using the same port expander:
https://github.com/TeraHz/Hydra/tree/master/Master (I2CRelay.cpp and I2CRelay.h). It is very simple but allows you to turn on/off individual pins, toggle the state and turn on/off the entire array. It requires the mcp23xx library as well.

Hope that helps.

P.S. You might get more answers if you use the Hydra thread or post it under the DIY forum directly.

WindowMaker
01/22/2012, 10:55 AM
Thanks for the input! I did get it working yesterday (the cap was what was confusing me). I found a library elsewhere for it, but the issue with that library is that I believe the addressing is done within the library, so I dont see the system being able to support multiple MCP units. Which I plan to do as my dosing pump system will be external as well. Ill check out those libraries you posted tonight, hopefully they will lead me to better luck with multiple units.

Thanks again!