Frc compressor 2020

I am the Lead Programmer for Team 3300 the Midwest_Warriors. I am wondering if anyone can help me with the Compressor code for this year? Me and my team cannot figure it out to make the compressor turn on using the PCM. I can attach my code if you need. Thanks!

Assuming everything is plugged into the PCM correctly (both pressure switch and compressor!), then you don’t need to do anything with the compressor in the code. Just get your solenoids set up, both physically (through the PCM) and in code, and the compressor will take care of itself - it’s all built in for you.

1 Like

Agreed. About the only reason you would need “compressor code” is if you want to shut the compressor down so that it doesn’t come on when the pressure drops.

3 Likes

One key is what CAN ID you gave the PCM. There are two constructors for the Solenoid, one that assumes the CAN ID is 0. In the past years, teams that have had problems activating their pneumatics have used the one that just has the channel, but their PCM didn’t have 0 for its CAN ID. Here are the two constructors for reference. The second one needs to be used if the CAN ID isn’t 0.

Solenoid (int channel)
Constructor using the default PCM ID (0). More…
Solenoid (int moduleNumber, int channel)
Constructor. More…
2 Likes

Do have any base code that i could use for it, (I would need C++ Code)

I do not (my team uses Java). However, there are great examples in the WPILIB docs (the replacement to screenstepslive):
https://docs.wpilib.org/en/latest/docs/software/actuators/pneumatics.html

From that page, a single solenoid can be addressed as follows:

frc::Solenoid exampleSolenoid {1};

exampleSolenoid.Set(true);
exampleSolenoid.Set(false);

For a double acting solenoid, you have:

frc::DoubleSolenoid exampleDouble {1, 2};
frc::DoubleSolenoid exampleDouble {/* The PCM CAN ID */ 9, 1, 2};

exampleDouble.Set(frc::DoubleSolenoid::Value::kOff);
exampleDouble.Set(frc::DoubleSolenoid::Value::kForward);
exampleDouble.Set(frc::DoubleSolenoid::Value::kReverse);

If you haven’t looked through the WPILib docs site before, I highly recommend it - there’s a lot of great information in there!

If you’re just testing to see how your system holds pressure and pressure switch works, do solenoids need to be wired in or is the code instantiation good enough?

Code is good enough. Those pins are outputs only, meaning there’s no way for the PCM to know whether there’s anything wired in or not. You’ll just see LEDs on the PCM toggle on or off

1 Like

Just in case you haven’t seen the docs on this yet:

From the compressor documentation:
The PCM will automatically run in closed loop mode by default whenever a Solenoid object is created. For most cases, a Compressor object does not need to be instantiated or used in a robot program. This class is only required in cases where the robot program needs a more detailed status of the compressor or to enable/disable closed loop control.

So, once you have followed the pneumatics guide to get it all physically setup, in software, just instantiate a Solenoid (or DoubleSolenoid) object and you’ll have your compressor running in closed loop control.

I also need to get my synoids working for tonights practice

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.