I’m thinking that I would be better off with a different relay board…
So, I purchased this Sainsmart 16 Relay board (12V) 16-Channel 12V Relay Module – SainSmart.com
It advertises that it works with the Arduino, so I figured it would work with the Panda II as well. Obviously I’m wrong… the Arduino must use 5V for its outputs. Either way, this board uses “low-level inputs”, which I’ve deciphered to mean ground=on… which isn’t fail-safe for what I’m doing. Even when I turn the Panda’s DOs on, it doesn’t kill the relay. Seems that 3.3V doesn’t bring the differential voltage low enough to turn the relay off.
- Is there any reasonably cheap (and without me having to solder on PCBs…) way to get this to work the way I want with the Panda? (ie Panda’s output on = relay on, off = relay off?)
- If not, can somebody recommend a board similar to this that can use 3.3V as a relay coil voltage?
Connect the 5v pin on your relay board to 3.3v and it should work.
You owe me a beer next time we meet
Sense direction of pins can be dealt with through a logic inverter chip. But, if failsafe is the concern you have, ie you want all relays to be a certain way when the system is first powered on but your app hasn’t yet initialised, you could simply use a pull-up or pull-down resistor to “set” that mode. You still need to know that when you write a TRUE to the pin you are turning it off, but that can be handled with a quick ENUM
Thanks for the replies!
Bear with me, as I’m new to these micro-controllers and I’m far from being an EE…
What would connecting the 5V and 3.3V pins do? Will this make the “common” output voltage from the Panda 5V? If so, this means that turning my DO on will produce voltage from the output and turning it off would be ~0V?
After more testing, it seems that when the controller is restarting (ie when I begin a new debug session from my PC), the relay is turned off anyway. My concern was that if my controller lost power that the relays would default to on, but it looks like this won’t be the case. Is this because there isn’t a completed circuit on the controller until it has booted completely?
I think Gus’ point was that if you connect 3v3 instead of 5v into the device, the logic chips are more likely to see the Fez high signal of 3v3 as an actual high.
Relays require power to hold them in one setting, but not in the other. When you reset a circuit controlling a relay, you want to set the control circuit to be in one particular way by default, so you know what the state of the circuit will be before your control application gets to the point where it can set the circuit up in how you want it. That may only be milliseconds or seconds, but those seconds can be important if you’re controlling a blender or something else. If your default state is fine for your purposes, then no problem.
Another way to think of this is if you think of power being like water in a hose, when you turn the tap on (power up the circuit) if you have the nozzle open then water will quirt out… otherwise, the hose just gets charged ready to go. If you have a relay controlling the nozzle and it’s default state is “open”, and in your application your first action is to close the relay, then once you power the circuit by turning the tap on, the water will come out the nozzle until your app initialises and closes it. So what you would do is “reverse” the default value by forcing the control to be closed when the power is first applied.
So does this latest update mean it’s all working as you expect?
The board has simple optical isolators, those are LED, not more. Those LEDs are connected to the 5V pin.
So 5V - 3.3V = 1.7V and this is enough to turn the LED on and so the LED will click.
If the pin is labeled 5V that doesn’t mean much in this case. If you analyze the traces, you can see that 5V si doing nothing but turning the “leds” (inside the isolator)
In short, bring an LED and connect it between 5V and 3.3V and it will light up, connect it between 5V and ground and it will light up too so there is no “off” state.
Connecting the 3V3 pin on the Panda to the 5V pin on the relay board is, apparently, exactly what needed to happen in my case. It is working like a champ now (although the states are still reversed – I’ll just write a function to read/write the opposite state that the rest of the logic dictates).
Thank you both for your help! Beers ARE in order.