need help with compressor code

my team is having trouble with getting our compressor running. We have tried several different ways to program it, we have tried just the basic code like people have been posting on other threads like this and none of them have worked.

I’ll try to get some screenshots of the code up in a little bit.

Along with your code, please describe in detail how you have the compressor and pressure switch electrically connected to the control system. There are half a dozen ways to get it subtly wrong, and any number of ways to do it completely wrong.

C++ or LabView???

For C++, you need three lines of code:

// put as part of your robot class or global, not in function
Compressor *compressor;

// in constructor [alter Compressor() parameters to match your setup]
compressor = new Compressor( PressureSwitchChannel, CompressorRelayChannel );
compressor->Start();

If you have this in, you should see the green LED for the compressor relay light on the Sidecar. If lit, the compressor relay should be energized and the compressor should run. Also, the PressureSwitch digital input needs to be wired up correctly. Make sure port numbers are correct for both relay and pressure switch.

Two things to check:

  1. Make sure you have a good PWM cable going to the compressor relay. They are notoriously bad.
  2. Make sure the PWM cables are plugged in correctly. With the new digital sidecar, it is very easy to plug them in one pin off.

If the Relay LED on the sidecar that matches your compressor relay is green and the compressor is not running, a PWM cable issue is usually the problem.

Even if you have LabView (I can’t help you there) all the non-code issues I mentioned are still valid.

Steve C.

here is a link to an image of the code, sorry it’s a link and not an attachment, it was the fastest way for me to get the whole thing up.

http://www.firstwiki.net/media/2/2d/1737_robot_code.jpg

now for the way we have the compressor and relay electrically connected: we have the main power connected to the “12v” side and the output is hooked up to the m+ and m- side of the spike. the pwm cable is plugged in with the black wire (ground) closest to the fuse on the spike. we have the pressure switch wired with a pwm cable, the signal (white) and the ground (black) with the red (power) not connected to anything, that cable is plugged into the 1st slot on the digital sidecar “Digital I/O” section.
The spike is plugged into the 1st relay spot on the digital sidecar.

we are sure that me have the spike wired correctly, if we take the pwm cable from the spike and place it in the DIO as apposed to the relay spot it will allow the compressor to run and keep filling until you remove the wire. also when we fill the tanks when it gets up to about 115-120psig you can see the pressure switch close on the main dashboard.

…and thanks for the help on this problem, Team 1737 is very grateful for it. :smiley:

ok, well, as far as i can see you are doing it right (at least if i followed those messy wires correctly), but im sorta baffled why you didnt use the enums to specify the dio, the slot, and the relay port. I think that may be where your problem is stepping in.

See all those red dots on your Compressor Open VI? They’re telling you something. You can’t always use an integer when an enumerated type is expected. Something is probably off by one from what you think you’re telling it.

Delete those integer constants (remembering what they are, of course). Right-click on each input of the VI and choose “Create constant” from the pop-up menu. Then you can choose the correct relay number and module number and Digital I/O number from the enumerated constants that appear.

replacing the integers with the constants worked, thank you very much for your help.