Welcome to the forum! 100 relays is definitely a fair few, I would say that you would need a daughter board connected to the Pi, something like an Arduino Mega can potentially control up to 54 digital out pins. In theory you could connect two of these via USB serial to a Pi and use their GPIO pins to actually control the relays.
You can’t get a multiple relay hat for a Pi, but you can put a Pi on a multiple relay board.
But I have never seen stackable relay boards. You will be using multiple 16-channel boards. For instance:
Some form of multiplexing is going to be required. Using separate MCUs to each drive a subset of the required total and connecting them with a communications link of some sort is one way to go. The separate MCUs will ensure that each relay stays in the state it was set to while others are changing. This device
encapsulates that functionality into a single chip, using I2C as the communication link.
There is an example of a simpler arrangement here:
The chip used here is specifically designed to ensure that each output stays as it was set until all outputs are told to change at once. This is usually very important for robots where relays are often used to drive mechanisms that must work in unison. The drawback is that the controller is responsible for ensuring that each time any relay is changed the whole stream of setting information is correct. This is not actually difficult to do with a device such as the Pi that has ample memory.
I do have some concerns about managing the power, with 100 solenoids, it can really add up, do you think a 5v power supply for the common ground connection to the Pi is enough or do I need 12V?
If 12V is not enough, do you have any suggestions on how to ensure the Pi can effectively run 100 solenoids?
My suggestion.
The MCP23017 board (below) provides 16 GPIO pins from an I2C address. You can have up to 8 of these boards connected to the RPi I2C bus by setting the address pins. Each of these boards could then connect to a 16 Channel relay card you linked. This uses only the two I2C pins on the RPi, power and GND. I have used one of these boards on a model railway setup and it worked really well.
Cheers
Jim
PS @Jeff105671 has linked the same as a dual inline chip, if that is prefered.
About managing the power effectively, with 100 solenoids it can really add up, do you think a 5V or a 12V power supply is enough? If not, what would you recommend?
The MCP23017 chip has 3 address select pins, so it can be configured (using jumpers) to be at one of 8 different I2C addresses. This means you can have up to 8 of these devices on the one I2C buss, so there is no need for a I2C expander. There are other options, but a single I2C buss with up to eight devices each at a different address is by far the simplest.
The voltage of the supply needed for the relays will be determined by the type of relay module you choose - if it’s a 5V module then it needs 5V to operate and won’t work properly with a different voltage. Same for a 12V module. But the number of devices you are driving will determine the current capacity you will require in the power supply. If you anticipate that many of the relays could be active at the same time then that current requirement will be substantial. The data sheet for the selected relays will show how much current each draws in the active and inactive states. Note that this is not the same as the current requirement for whatever device the relay is switching - that is a different question and will be quite separate from the question of how to power the relays.
Note that your reference to the video you saw implies that you want to use mechanical relays to control the solenoids. Depending on what these solenoids actually require in order to operate, a MOSFET driver module might be more effective than mechanical relays.
Yes, the goal is to control those 100 solenoids simultaneously, switching multiple of them on and off at the same time consecutively accross the multiple relays, therefore all these relays will be active at the same time.
So it would in fact be a substantial current requirement like you said.
I’ve done some research on MOSFET driver modules, they indeed make more sense for power efficiency as well as speed, size, longevity, noise and less heat production.
They however seem a quite complex, I’ll have to do more research, find mosfets with more channels and with Voltage and Current Requirements that match my solenoid’s needs, how to connect them, power supply to provide adequate voltage and current for all 100 solenoids, and maybe something to protect against voltage spikes for each solenoid like some flyback diodes…
That can’t happen if you are controlling relays individually as there will be a time delay between each operate command.
This can only happen if you operate ALL of the relays with the ONE signal. Could be done with one big Mosfet or several all driven at the same time. This though might be a job for a dedicated Mosfet driver IC as the capacitance inrush current could be substantial.
Cheers Bob
I am strongly considering only using mosfets driver modules to connect all the solenoids to the Pi.
But that might be a good point, I am using a Raspberry Pi which all the mosfets, or relays will be connected to.
To ensure ONE signal, all of them would need to be connected to only ONE GPIO pin somehow…
I really don’t see how at the moment, but one GPIO pin cannot handle the total current needed, I think whether I end up using relays or not, we would need a buffer like a transistor or MOSFET to amplify the signal.
There are many alternatives to using a single GPIO pin, like using a Shift Register like the 74hc595c @Jeff105671 suggested and more, I’m still trying to find the simplest way to do this…
It’s starting to get a little complicated (for me), the best way to find out is to start testing, I’ll order all the neccessary hardware and try out the best possible and logical solutions after doing more research to understand every part and requirements better.
The GPIO will not be handling the load current, regardless of whether it is driving one solenoid or several. That’s the reason for using the relay or MOSFET - the GPIO has to drive the relay or MOSFET, and the relay or MOSFET drives the load. So for multiple devices from one GPIO you will use one relay or one MOSFET.
So the matching you have to do is:
Make sure the GPIO can drive the relay or MOSFET. A GPIO should not be loaded more than about 10~20Ma, depending on the MCU. For the relay, this means you will use a module that has either a small transistor or an opto-isolator as part of the input circuit to drive the relay coil. For a MOSFET that means the module has a suitable resistor at the input to limit the current into the MOSFET. A MOSFET might have an opto-isolator instead of just a resistor.
Make sure the relay or MOSFET has the capability to supply the current requirement for all the loads it is switching. For a relay, the contacts will be rated at a max current at a particular voltage, such as ‘10A @ 12V’ and within that limit it doesn’t matter what the load looks like. For a MOSFET it’s a little more complicated because there is more connection between the MCU voltage (3.3V or 5V), the load voltage and the maximum load current, and there is a large range of devices with different characteristics. In addition, a MOSFET might be an exception to the ‘one GPIO, one MOSFET’ rule, depending on the details. This is because the drive current for a MOSFET can be very small and it might be worthwhile (or necessary) to use multiple MOSFETS if you need to drive different types of loads from one GPIO.
Of course, with your setup you are interested in the characteristics of the MCP23017 rather than the MCU, but the rules are similar - the MCP23017 will have a logic voltage, a max current per I/O pin and a max current per device.
It is the gate capacitor charging current that is the problem. To handle this there are dedicated Mosfet driver ICs which are capable of currents up into the Amps range for a very short time. I used to have a couple but don’t know exactly where they are now. Quite inexpensive and come in 8 pin package I think. More than one device in one package which can be driven with the same logic signal. Very useful when you need to drive multiple Mosfets from one signal.
Cheers Bob
3 Likes
And you can get our latest projects and tips straight away by following us on: