Run Multiple Compressors with Relay in C++

My team added a second compressor to our 2013 robot for demos. I’m trying to get the compressors to turn on, but I can’t figure it out. My googling has told me to do something like this:

Compressor *comp = new Compressor (Digital Input, Relay);

But when I enter this into my code, Eclipse tells me that Compressor can not be resolved. If I give it one input, Eclipse is fine, but that doesn’t seem to do anything when I enable.

Any suggestions would be much appreciated.

What control system are you using? 2013 used a cRIO with Netbeans as the development environment, while the roboRIO and Eclipse is used for 2015+. The documentation you’re referencing is from the cRIO, but it sounds like you might be using the roboRIO. See the current class documentation: http://first.wpi.edu/FRC/roborio/release/docs/cpp/classfrc_1_1Compressor.html

We have a roborio on the robot now. We are trying to use a pressure sensor to look at the pressure in the tanks and we are using one relay per compressor to switch the compressors on and off.

I have the compressors running when pushing a button, but I cant get them to run from the pressure switch being triggered. I have the pressure switch plugged into the PCM but I don’t know how to get that signal form the PCM to the roborio where I can use it in an ifelse statement.

Can you describe precisely how things are wired? You’ve mentioned both relays and PCM which are competing concepts.

Maybe you can only invoke one instance of “compressor”? WAG on my part. Sorry for any inconsistentcy of terminology . Write your own code for the 2nd compressor. Turn on the 2nd compressor’s relay when the 1st one is running.

According to the screenstepslive c++ compressor page, you can use the GetPressureSwitchValue() method to find the state of the pressure switch.

You don’t mention having the PCM CAN Bus connections made.

Yes. If for some reason you don’t want to use the PCM, you can wire the pressure switch to a DIO on the RIO. If you do this, wire and program it just like a normally closed limit switch; one wire to signal, the other to 0V (ground). You’ll normally get a 0V from the pin, pulled up to 5V when the pressure switch activates (and don’t create any compressor or solenoid objects in code, just DIOs and relays).

Also note that most 12V relay modules can be switched by DIO ports as well as relay ports; the DIO just needs to light a tiny LED in an optoisolator.