Spike relay only works in reverse

We have a window motor connected to a spike relay and our Labview code is able to manipulate it in both directions but when we flash the cRio and load our Java code, the relay only runs in reverse.

We have tried multiple scenarios trying to track down the issue and these have included: changing the constructor (new relay(1); new relay(1,1); new relay(1,1,kBoth);), we have changed the code and replaced the kReverse, which works, to kForward. We have even verified that kForward has a value of 2 by outputing the value to the dashboard.

When we watch the relay, reverse does turn the LED red but forward never changes to green.

Team 3224
Lion Hit Squad

What do the relay lights on the DSC do?

It is possible to have the relay only respond in one direction if the PWM cable is defective. The Spike is controlled by the two lines, not by PWM. It is only using the same cables for this connection. The DSC will have two LEDs for each relay output. If the indicators are correct, then replace the wire.

Please post code of your constructor, and code where you command the relay to change direction.

Have you tried swapping out the relay and the results are the same?

Are you running the test with the motor connected or disconnected? I would remove the motor from the relay and just verify voltage output from the relay terminals for now using a volt meter.

Regards,
Kevin

We usually instantiate our Spikes like so:


Relay spike = new Relay(1);

We do not even include the Direction in our instantiation of the object. Also, we also set the Spike to the off position right after instantiation:


spike.set(Relay.Value.kOff);

Alex Brinister

It looks to me (based on the javadoc) that the default constructor for the Relay objects defaults to allowing the Relay object to operate in both directions.

Hence your constuctor:

Relay spike = new Relay(1);

Should be the same as:

Relay spike = new Relay(1, Relay.Direction.kBoth);

This means you should be able to put your relay in 3 different states:


public void autonomous() {
  // SimpleRobot autonomous test code that transitions the relay through
  // all 3 states (2 seconds forward, 2 seconds reverse, then off).

  // +12 volts out (think this displays the green LED on DSC)
  spike.set(Relay.Value.kForward);
  Timer.delay(2.0);

  // -12 volts out (think this displays the red LED on DSC)
  spike.set(Relay.Value.kReverse);
  Timer.delay(2.0);

  // 0 volts out
  spike.set(Relay.Value.kOff);
}

So, from your previous posts: It sounds like you are constructing the Relay so that it will operate in all three states. But, it sounds like you are not seeing the green LED light up when you set the forward state. There are at least three possibilities:

  • Your code that sets the forward state is being reached, however after setting the forward state, another portion of your code is executed which immediately sets the relay back to the reverse or off state.
  • Your code that sets the forward state is not being reached.
  • There is a hardware failure in digital module, 37 pin cable or digital side car. You can try using a different relay channel or substituting parts to check this. Digital side cars do fail - our team has already had to replace one this season.

We have some relays that work fine, but the LEDs don’t work well as indicators. I’d use a meter to see if there’s actually output rather than going solely with the indicator.

Also, if the direction of the relay is set to kBoth, you can have a 4th state using Relay.Value.kOn. kOn puts 12v down both M+ and M- at the same time. We use it to control two separate items with the one relay… See the IFI Spike user’s guide: