Relay question

So, we’ve been having problems with some of our relays not working. I’m using the code that they give you for an example, because if it ain’t broke, then don’t fix it, right? Anyway, It seems like our relay is on (solid orange light all the time), and when I push the button to activate it in TeleOp, we hear it click, but nothing happens. Just to make sure that I’m not going insane, setting a relay to go forward, such as " example_relay.Set(Relay::kForward) " will also turn it on, right? I don’t have to have an " example_relay.Set(Relay::kOn) " block nested with it, right? And for the record, it’s quite possible that the issue is wiring. I just want to make sure everything is okay on my end. Here’s the code, for those of you who need to see it:


bool forward = stick.GetRawButton(button2);
bool reverse = stick.GetRawButton(button3);
if (forward && reverse) {
	arm_rotator.Set(Relay::kOn); }
else if (forward == true) {         //Do I have to set it on in here, as well?
	arm_rotator.Set(Relay::kForward); } 
else if (reverse == true) {                         //And here?
        arm_rotator.Set(Relay::kReverse); }
else {
	arm_rotator.Set(Relay::kOff); }

The orange light indicates the relay has power but is ‘off’, no output. It will turn green when forward and red when reverse. ‘kOn’ is only used when you initialize a relay with a defined direction, Relay::kForwardOnly for example, instead of kBothDirections.

So you would either use kOn, or you would use kForward and kReverse, depending on how you initialized the relay. kOff is used in both cases to turn off the relay.

So assuming you initialized the relay with kBothDirections, your code would look something like:

bool forward = stick.GetRawButton(button2);
bool reverse = stick.GetRawButton(button3);

if (forward == true) {
	arm_rotator.Set(Relay::kForward); } 
else if (reverse == true) {
        arm_rotator.Set(Relay::kReverse); }
else {
	arm_rotator.Set(Relay::kOff); } 

How did you initialize the Relay? Did you use just Relay(x) where x is the number staring at 0? That should initialize a relay that can turn on in both forward and reverse.

I only included the relay port on the roboRIO when I initialized it. Should I add kBothDirections? Could that be my problem? Or perhaps it’s that first “if” statement. Would skipping the “on” block, and starting with the kForward block like ghead make a difference? Ugh. I wish I could drive to my school, unbag our robot, and run some tests, right now!!!