Spike Relay?

We’re using the spike relay between our PDB and Compressor, and trying to turn it on by switching the relay to on or off.

By default, when we turn the robot on, the relay doesn’t allow the current to flow and power the compressor.

To allow it to do so, and for the compressor to turn on, do we set the relay to kOn or kOff?

There is a class called compressor… it does this for you.


Compressor compressor = new Compressor(1,2); // 1 is your relay port and 2 is your pressure switch digital input


//then in your robot init just put 
compressor.start();

I was aware and tried to use Compressor, but it wasn’t working.

TBH, nothing is working.

I’m going to make a post on the tech forum to see if I did some pneumatics wrong.

Use kForward. that should do it.

You probably already know this, but just a reminder the robot has to be enabled for the compressor to turn on. In disabled state they will not run motors or relays.

How would one actually program the spike relay to control a motor? Can someone give us some current example code? Just some short code to show us what methods to use to get it to move forwards, backwards and to stop.

Page 37
http://firstforge.wpi.edu/sf/docman/do/downloadDocument/projects.wpilib/docman.root.c_and_java_documentation/doc1196

Any chance someone could show us documentation or example code for java? None of us know c++ sadly.

I don’t know how much you know or don’t know, so I’ll cover what I can.

First be sure you created the compressor object. The parameters should be the Pressure switch channel and the relay channel that you are using on your breakouts on the cRIO. Then turning the compressor on or off is as simple as calling the start and and stop methods. From what I recall, the compressor will need to have the start() method called to turn it on in the first place ( I’ve done this in the initialization code for autonomous and teleOp). You can also turn it on and off using buttons or timers as well. It will automatically turn off once the pressure switch detects the system is at pressure.

Code wise:


Compressor compressor = new Compressor(1,1);  // Creates the object.  Make sure the parameters of (1,1) relate to the pressure switch and relay channels.  

compressor.start();  // Start the compressor

compressor.stop();  // Stop the compressor

Again, you will usually want to put the compressor.start() in the initialization code for the robot so it starts automatically without user intervention (unless, of course, you want to manually start it).

I just struggled with that last night :wink: Remember, I’m a software guy - but here’s the list of problems I had with our I&T chassis, so maybe they’ll help you.

(1) Make sure there is a fuse in the power distribution panel port you have the relay wired to. When you power on the robot, the LED on the Spike should be glowing brightly.

(2) The PWM goes from the Spike to one of the Relay ports on the digital side car.

(3) We made a PWM cable with the connector to plug into one of the DIO ports on the digital sidecar and left the black and white wires stripped on the other end.

(4) Make sure you do the constructor to the Compressor in the right order (the WPI documentation text enumerates them one way, and the actual argument order is reversed).

(5) Make sure you call start() after creating the instance.

(6) Short the two wires to the DIO together and the compressor will run (simulates low pressure). Separate them and the compressor will stop.

If you are sending the data to the default Dashboard that comes with the NI install, you should see the appropriate lights on the GPIO and the Relay ‘LEDs’.