RGB Led Controlled by DIO on Rio

I have checked voltage from the 5 volt power supply and it is putting 5 volts to the relay board, but nothing is going to the relay outputs either in NC or NO mode.

And the roboRIO relay pins are outputting 5V when turned on? Do you hear the relays switching?

I can hear the relays switching when I trigger them via the Rio. I’m not sure what voltage the Rio relay ports are outputting.

I got the LEDs to power via the relay and they can be triggered via the Rio. Can someone explain this to me:

Why do I have to set the relay to kOn to turn them off? Why do I have to trigger kReverse when the wire is connected to the forward pin of the Rio?

Glad to hear it’s working. What did you change to make it work?

It sounds like somehow you’ve connected the relay between signal and + instead of signal and ground. So when the signal pin is set to on (high) it’s at the same voltage as the + pin so there is no voltage differential and the relay is off, and when signal is off (low) there is a voltage differential between it and the + pin, so the relay is on. A picture of your wiring might be helpful if you want to solve this issue, or you can leave it as-is if it’s working and you’d rather not mess with it.

I’m not sure what you mean by between signal and ground. On the the Rio the relay ports are labeled forward, reverse, and ground. I have the relay board input pins hooked to the forward relay pins on the Rio.

The relay board is getting power from the 5 volt transformer, not the Rio. Am I not doing the relay pins correctly?

Right…ignore that, I forgot you are using the relay ports not the DIO ports.

The documentation for the relay you linked earlier shows there are two output options for each relay channel: normally opened and normally closed. Make sure that your LEDs are plugged into the normally open output. (Because you want the circuit to normally be open or off, unless power is applied to the relay to close it or turn it on)

Many relay boards are “negative logic”. That is, high voltage is “normal” and low voltage is “switched”. This one is that way: see the “Principle” paragraph of the page you linked. This is probably the cause of your on/off reversal.

Note that you also have to provide 5V to the Common input (center screw port) for each relay to get any voltage out of the NO and NC ports on either side. The switch side of those three relays is electrically isolated from all of the control and coil circuitry unless you connect them (reference the schematic diagram).

The LEDs I have share a common positive rail, so I had to put ground to the common port on the relay, the color leads to the NO port, and then connect the positive rail to 5 volts+.
When I first turn on the Rio some of the relays on the board turn on while others do not. Is there a reason some would be on and others not? Also, why, if the signal wire is connected to the forward pin, why would I have to call the kReverse code for the relay to work?

That sounds right. Have you tried a meter and tested continuity across the relay output ports with no LEDs in place? Perhaps obvious, but the normally open should be open and the normally closed should be closed with the power off; these should be reversed (NO=closed, NC=open) when the relays are turned on.

Not sure what you mean by “the forward pin”.

Assuming you have 5V at both VCC and JD-VCC and 0V at the GND inputs, each of the relays should be in the “normal” position if the LEDs are dark, caused by the IN# pin being HIGH or disconnected. Each of the relays will be in the “active” position if the IN# pin is LOW.

IIRC, the relay ports’ signal lines are “normally” (kOff) both low, which will cause the LEDs to light and the relays to connect common to NO. I expect this is what will happen if you create a relay in code but do not set the state; not at all sure what will happen with an uninitialized relay port.

By “the forward pin” I mean the pin labeled fwd (I assume this means forward) at the relay port on the Rio. I have the blue LED signal wire that goes to the relay board wired to this pin, but I have to code kReverse to turn the blue LEDs on.

I have 5 volts going to the VCC pin and ground to ground. Then I have a wire connected between the Rio’s relay pins and the input pins on the relay board. When I first power the Rio, the blue LED and Red LED are both “on” (giving me purple). To turn them off I have to run kOn for both relay ports I am using on the Rio (0 and 1), which turns all of the LEDs in my strip off. Then I run kReverse on relay port 0 to turn the blue LEDs on. I’m just not sure why everything seems to have to be coded backward to work.

Did you check this?

Yes. The LEDs are all connected to the NO side of the relay board. What I’m saying is that when I power the Rio it is sending a signal to the relay board instantly without bcode running.

What happens when you power the relay but not the rio? If the LEDs turn on (my guess), you must somehow have the LEDs hooked up to NC because there’s no signal coming from the rio (ie normal) and the circuit is closed. If they don’t turn on until you give the rio power, there’s something wrong with your code/rio.

With no code, the RoboRIO’s relay output ports are driven LOW*. In the case of the relay module you have, this means that the relay will be enabled. To turn the relay off, you have to declare that relay port and explicitly set it high.

  • While I couldn’t find this explicitly, it is implicit in the fourth bullet of the stage 2 brownout on page 7 of the RoboRIO User Manual. In the case of Spike relays, this will turn the relays and any devices properly powered by them off.

Referring to the part of the quote I underlined, isn’t that only true if they’re using the NC outputs? If they’re using the NO outputs, then the circuit should only be closed when the roboRIO relay signal is driven HIGH. When it is low (e.g. when the rio is disabled), the circuit would be normally open, i.e. off.

I was referring to the state of the relay, whether it’s armature is in the “normal” or “enabled” position. Assuming JD-VCC and GND are appropriately powered, this will be the same state as the LED for that channnel on the relay module.

I see what you’re saying. I went back and reread the manual, and it turns out I had misread it, causing the confusion.

The input pin must be driven LOW to “enable” the relay, and HIGH or floating is “normal”. A bit of research shows that relay boards like these are probably designed for Arduino-like microcontrollers, whose outputs float HIGH until pulled LOW by the user program, the opposite of the roboRIO.†

To the OP,
I would suggest using the roboRIO’s DIO ports instead of the relay ports for driving the relays. You want the relay to be driven HIGH* most of the time, including when the robot is not enabled. All relay outputs (forward and reverse) are automatically driven LOW** during disable for safety reasons. If you use the DIO ports, you can give a +3.3V signal during disable, which should be sufficient to drive the relays HIGH and turn off the LEDs. The LEDs will probably be purple (both red and blue on) while the rio is starting up until user code loads, but that actually might help with on-field debugging to ensure the user code starts before the match starts.

† Putting this here for anyone who made the same misreading as I did

  • driven HIGH means the pin has some positive voltage relative to GND (i.e. kOn or kForward/kReverse)
    ** driven low means the pin has the same voltage as GND (i.e. kOff)

I changed the signal wires from the relay ports on the Rio to the DPIO ports on the Rio, but I still have to code it “backward” to make it work. To turn the lights on I have to set the pin to false. Is this simply a result of the relay board I have purchased? Does the one referenced earlier in this post require the same type of “backward” coding?

Yes. It goes on with a low input voltage, off with high. A majority of relay modules, particularly those with opto-isolators, work this way. There isn’t really any intrinsic reason for opto-isolater relay modules to work this way, it’s just that they usually wire the isolators like the LEDs you have, with a common positive pin and separate negative pins.

If I’m reading the schematiccorrectly, yes. This one does not have an opto-isolator, but is basically using an NPN transistor as an electronic switch to actuate the relay. A positive voltage at the base (input) allows current to flow into the collector, enabling the relay.