Default code and the Compressor

We seem to be having a problem setting up the simple pressure switch and the compressor to allow the compressor to shut off when pressure reaches the 115psi. We have loaded the 2005 code and plugged in the the spike that controls the compressor to relay 8. The Pressure switch is placed on Digital IO 18 and it is set as input in the code. With this setup the compressor will not run even when there is no Pressure in the tanks.
We then loaded the 2004 default code we had from last year and the system worked.

Can anyone please point us in the correct direction and are there any other teams having this same problem?

Both the v2.2 and v2.4 default code have this line in Default_Routine:

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

It sounds like you have it wired properly. If you have changed the code, I would look closely at it to make sure that line is actually being executed.

I have checked the code and it looks like the default values. I have even downloaded the default code and loaded the default hex into the controller. Is there an error in the code I am not aware of that I need to change.

Your code is doing exactly what it is supposed to be doing…run when the switch is not set (i.e. pressure is below the threshold). It just so happens that the pressure switch has a cutoff of ~115 PSI. There’s a discussion of this here.

If you really want to get your system pressure to 120 PSI, you can run the pump for a fixed number of cycles after the switch was set (i.e. pressure is above threshold) before giving it the command to shut off. We’ve used this method for the past few years, and it works just fine.

Our pump is not running when the pressure is below 115psi using the 2005 default code. We have gotten the pump to work with last years code which I can not find the difference.

Misread your original post…I thought you weren’t getting it charged up to 120…

So your code from last year works with your current compressor/switch setup, but your new code doesn’t? And it is using the same dig in/relay?

Just throwing some blind suggestions out…

Have you tried using printfs to see the value of the switch? Does it change when the pressure reaches 115?

What happens if you hard code the value of relay8_fwd to 1? Does the compressor turn on?

How far away from the default code are you? If you want, you can send me your C file and I can take a look for anything out of the ordinary.

here is both this years default code (which doesn’t work for us), and the default code from last year which does work.

code.zip (9.08 KB)


code.zip (9.08 KB)

Well, the code you posted should work. Strange…

Maybe you’re reassigning relay8 in a different file, like user_routines_fast? Might do a search for relay8 in some other files, and see if you’re setting it equal to something.

We havent changed any of the other files, yet.

I diffed your 2005 code to the Default code released by FIRST and, as expected, it is identical.

This makes me believe that your compressor and/or pressure switch is wired incorrectly.

Try making the following modification and see what you see

 
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;
   
/******************/
/* THIS CODE IS ADDED */
printf("Switch %d  Relay  %d\r",(int)rc_digin18,(int)relay8_fwd);
/******************/

   /*---------- PWM outputs Limited by Limit Switches  ------------------------*/

In the case that the switch always shows 0, your compressor is wired incorrectly. If the relay is showing green, doublecheck the compressor’s connection to it. If the relay doesn’t change color, check the PWM connection between the relay and relay port 8.

If you see that the switch is always reading 1, then your compressor will never turn on. If that is the case, your switch may be wired incorrectly or defective. To verify this, remove the ! from the line that sets relay8_fwd. If the compressor runs and shuts off at 115 psi, then there’s some weirdness on why your switch is returning an inverted value. If the compressor never shuts off, doublecheck all connections between the switch and the RC.

Hopefully that helps…

It DOES work with the 2004 code. but does not work with the 2005. same wiring for both. but we cant find any real diffrence between them other than the camera stuff.

The version of user_routines_fast I just looked at DOES set relay8 = 0 inside of user_routines_fast.

Matthew, et al,

I was planning to hook up a compressor this afternoon anyway. I will try the 2005 default code and report my observations.

Mike

We finally got it to work. We changed this the code below and it worked. Please explain why this worked.


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


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

Matthew,

relay8_rev must have been initialized to 1 (or set to 1) somewhere in the code or possibly it was never initialized (an uninitialized variable is, by definition, undefined).

Anyway, congrats on getting it working…

Mike

Keep in mind that you’re not supposed to run the compressor backwards - make sure that, if you have the spike in reverse, you switch the leads on the compressor or something.

yeah, mine won’t work either. much more importantly, 2.4 won’t even take input from our joysticks, yet 2.2 will. these are both unmodified. any suggestions?