programming pneumatics

hi, we are using mplab default code, so basically we can drive two cim motors so far with speed controllers.
we are trying to have the compresser turn on.
what shoul we write or do with the relays to have the compresser always on?
which relay output # ?

can someone copy paste their code about the compresser turning on?

as for the nason pressure switch, after we connect it to a digital port, then what?..

thanks.

With the switch connected to a digital INput (other side to ground), you write code like

If (Dig_In_x) equals 1
Set (Spike_Relay_X) to ON
ElseIf (Spike_Relay_X) is OFF

And check it every loop.

DO NOT SET THE COMPRESSOR TO ALWAYS ON, you’ll exceed a safe pressure and pop the release valve. You MUST control the compressor, inspectors look for this.

(You need to write real code for this)

In the default code there is an area that shows how to map out the relays pretty well.


 /*---------- Buttons to Relays----------------------------------------------
  *--------------------------------------------------------------------------
  *  This default code maps the joystick buttons to specific relay outputs.  
  *  Relays 1 and 2 use limit switches to stop the movement in one direction.
  *  The & used below is the C symbol for AND                                
  */
  relay1_fwd = p1_sw_trig & rc_dig_in01;  /* FWD only if switch1 is not closed. */
  relay1_rev = p1_sw_top  & rc_dig_in02;  /* REV only if switch2 is not closed. */
  relay2_fwd = p2_sw_trig & rc_dig_in03;  /* FWD only if switch3 is not closed. */
  relay2_rev = p2_sw_top  & rc_dig_in04;  /* REV only if switch4 is not closed. */
  relay3_fwd = p3_sw_trig;
  relay3_rev = p3_sw_top;
  relay4_fwd = p4_sw_trig;
  relay4_rev = p4_sw_top;
  relay5_fwd = p1_sw_aux1;
  relay5_rev = p1_sw_aux2;
  relay6_fwd = p3_sw_aux1;
  relay6_rev = p3_sw_aux2;
  relay7_fwd = p4_sw_aux1;
  relay7_rev = p4_sw_aux2;
  relay8_fwd = !rc_dig_in18;  /* Power pump only if pressure switch is off. */
  relay8_rev = 0;

Follow the format that they show there except with whatever you are doing. The cable that you have from the pressure switch goes in whichever port is here

relay8_fwd = !rc_dig_in18;  /* Power pump only if pressure switch is off. */
  

So with it in the default format you would have your compressor in port 8 and the pwm cable that you have on your pressure switch to digital IO 18. Also I found out that with us, only relay_fwd did anything with the pistons. I don’t know if that will be different for you or not.

Hi all,
This is 2199’s first year working with pnumatics. Yesterday we put our “pnumatics board” on last years robot for testing purposes. Prior to yesterday, we had been testing the the compressor and such directly off the battery (of course with fuses etc. so we didn’t fry anything) so we know it works. We wired things up with a spike according to the code:

relay8_fwd = !rc_dig_in18; /* Power pump only if pressure switch is off. */

We have Relay 8 for powering the compressor (and plugged into relay 8 on the board) and Pressure sensor plugged into Digital I/O 18 for turning the spike on and off. We measured the voltage with a multimeter and saw 12 volts go into the spike and not coming out to power the compressor. We even told the spike to always be on, but 12 volts still never came out of the spike. We even moved the wires over to another spike and the same thing happened.

Can you tell us what we are missing? Thanks

Did the LED on the Spike do anything?

You did have an OI connected via tether or radio, right?

Did you check the fuse on the Spike or better yet replace it with a 20a snap-action breaker?

Did you set relay8_rev = 0 somewhere?

To Alan Anderson,
The LED on the spike stayed orange the whole time. We inserted a printf statement to look at what was being sent out to the spike and we kept the programming cable on the robot and watched the terminal window. A 1 was sent to relay8_fwd. (1 is on 0 is off right?) Still, Nothing happened to the spike.

To Mark McLeod,
We did check the fuses and they were perfectlly fine.
Yes, right under the

relay8_fwd = !rc_dig_in18; /* Power pump only if pressure switch is off. */
was the
relay8_rev = 0;

Is there any other place other than user_routines.c in the default code that relay8_rev or relay8_fwd would change?

Thanks!!!

It sounds like your robot controller is disabled. Again, do you have an OI attached, either by tether or by radio? Do you have a disable switch connected to the competition port that’s turned on by mistake?

What do the lights on the Robot Controller show you?

Alan Anderson,
Actually, we have two ways to disabel our robot.
When we were improving our one stick driving code earlier, we put in a failsafe to stop the robot to neutral (and it came in handy on several occasions needless to say). We have to hold down one of the buttons on the joystick to enable the robot to move.

We also recently made a dongle for “emergency stop”, “autonomous”, and “regular driving”.

I’m very sure we enabled the robot through the dongle, but not sure about our origional failsafe. I am very sure the failsafe was only for the drive motors and our failsafe would have shown up on our teminal because we put a printf statement that would have indicated that it was disabled. I don’t remember without looking at the code and/or the robot.

I have been constantly emailing with the rest of the team and, after seeing some diagrams on wiring, they are also thinking the thing is wired incorrectly. Tomorrow the team will be figuring out why the pnumatics arn’t working, and I’ll bring the failsafe up. When we figure this out I’ll obviously write to tell ya’ll about what the problem was.

Hi all,
I found the problem. Some how the “relay8_rev = 0;” was deleted. I put it back in the code and the compressor and preasure switch are now working flawlessly! Thanks for the help!