NEED HELP with Delay loop for compressor relay switch

Posted by Erik at 03/12/2001 11:54 AM EST

Engineer on team #381, Trenton Tornados, from Trenton High School and Princeton University.

I am trying to write a delay loop in the default program for the robot controller, and I would like to know if anyone can help me understand how to turn off the relay switch by setting it to 1 or 0. what I really want to know is how to put in a delay using a conditional statement I suppose. Code snippets would be much appreciated. I think I have the idea but here is my pseudocode:

delay VAR word
delay = 0;

mainloop{

when switch opens up then{
delay = delay + 1;
if delay

Posted by Scott Strickland at 03/12/2001 12:01 PM EST

Engineer on team #21, ComBBAT, from Astronaut & Titusville High School and Boeing/NASA.

In Reply to: NEED HELP with Delay loop for compressor relay switch
Posted by Erik on 03/12/2001 11:54 AM EST:

Not sure exactly if this is a help and I am not the programmer on the team…

We wanted our compressor to be off when we first started the match so our arm would stay up. At the end of the match we wanted it to stay down. To do this we programmed it so the compressor would come on when the button for actuating the cylinders is first pushed. As soon as the operator pushes the button (at the start of the match) the compressor comes on and the arm goes down. After that, whenever the operator pushes the button it actuates the cylinders.

Hope this helps, it may be easier than putting in an if/than statement.

Scott

Posted by Joe Johnson at 03/12/2001 12:57 PM EST

Engineer on team #47, Chief Delphi, from Pontiac Central High School and Delphi Automotive Systems.

In Reply to: NEED HELP with Delay loop for compressor relay switch
Posted by Erik on 03/12/2001 11:54 AM EST:

pressure var rc_swX.bitX
pump_on var relayX.bitX
DELAY_COUNT CON 40
cnt var byte
'assumes delta_t is used

cnt = 0

mainloop:

'get data from master CPU

cnt = (cnt + delta_t) * (1 - pressure) MAX DELAY_COUNT
if (pressure = 1) or (cnt

Posted by Mike Gray at 03/12/2001 2:20 PM EST

Engineer on team HOT from Huron Valley Schools sponsored by GM Milford Proving Ground.

In Reply to: NEED HELP with Delay loop for compressor relay switch
Posted by Erik on 03/12/2001 11:54 AM EST:

Here’s one way to do it. Simple, and uses only one byte.

First declare a new variable and initialize it:

compdelay var byte
compdelay=1

Set the upper limit constant
complimit con 30

Increment or decrement the variable as a function of rc_sw1 (or whatever input you use).

compdelay=compdelay+rc_sw1 - (1-rc_sw1) min 1 max
complimit

Then add a LOOKDOWN table to the main loop:
lookdown compdelay,

Posted by Adrian Wong at 03/12/2001 9:06 PM EST

Student on team #596, Hopkinton Hillers, from Hopkinton High School and Zymark & Computer Associates.

In Reply to: NEED HELP with Delay loop for compressor relay switch
Posted by Erik on 03/12/2001 11:54 AM EST:

Does it trip at a certain PSI (on/off) or does it turn on at a ‘low’ PSI and then turn off at a ‘high’ PSI?

I recall reading some material on this, but I can’t remember the exact wording or the location of the document. It said something to the effect that the switch turns on when it hits a ‘low’ PSI, such as 110, and then turns off at a ‘high’ PSI, such as 120. The pressure can be adjusted, but the range between the high and low is the same.

Am I dreaming things up?

Posted by Joe Johnson at 03/12/2001 9:35 PM EST

Engineer on team #47, Chief Delphi, from Pontiac Central High School and Delphi Automotive Systems.

In Reply to: Question on Digital Pressure Switch
Posted by Adrian Wong on 03/12/2001 9:06 PM EST:

The switch is just a simple on or off based on the
pressure screw setting (set to approx. 110psi as
shipped as I recall).

The switch does not turn off if very low, then on if in
a mid-range, then off again for higher.

As I recall, the switch provides the PBASIC with a 1
when below XXX psi and turns to a 0 when above that
psi. There is a slight hysterisis (spelling?) which
means that it turns off at say 110 psi but then does
not turn on again until it gets below 105 psi. In many
cases this is a very anoying feature, but in this case,
it is nice because the pump not sit and cycle off-on
at the make-break point.

In fact, I wish there was MORE hysterisis in the switch
and then all this talk about a delay in the PBASIC code
would be unnecessary.

Joe J.

Posted by Adrian Wong at 03/12/2001 10:00 PM EST

Student on team #596, Hopkinton Hillers, from Hopkinton High School and Zymark & Computer Associates.

In Reply to: 1 if low pressure 0 if high pressure
Posted by Joe Johnson on 03/12/2001 9:35 PM EST:

: As I recall, the switch provides the PBASIC with a 1
: when below XXX psi and turns to a 0 when above that
: psi. There is a slight hysterisis (spelling?) which
: means that it turns off at say 110 psi but then does
: not turn on again until it gets below 105 psi. In many
: cases this is a very anoying feature, but in this case,
: it is nice because the pump not sit and cycle off-on
: at the make-break point.

Ah, this is exactly what I am talking about. Thanks! (Hysteresis, that was the word I was looking for to describe it.)

Thanks again!

(Note: Finally resolved the PBASIC code for triggering the air compressor to the following that uses an XOR logic to provide the operator with an override in case you’d want to conserve power when the compressor is on or need extra pressure for some odd reason -> relay3_fwd = rc_sw2 ^ p1_sw_top)

Posted by Gary Bonner at 03/12/2001 9:12 PM EST

Other on team #433, Firebirds, from Mount Saint Joseph Academy and SCT Corp., FMC Corp…

In Reply to: NEED HELP with Delay loop for compressor relay switch
Posted by Erik on 03/12/2001 11:54 AM EST:

We were going to put a delay in our program, but the compressor didn’t seem to cycle that much, so we didn’t bother. Anybody else do it this way?

Posted by Joe Johnson at 03/12/2001 9:48 PM EST

Engineer on team #47, Chief Delphi, from Pontiac Central High School and Delphi Automotive Systems.

In Reply to: How many teams are using a delay?
Posted by Gary Bonner on 03/12/2001 9:12 PM EST:

I had a very elegant delay code that used all kinds of
cool CS type stuff. Then we ran out of code space.

The code was commented out before you could say, “I am
downloading new code, wait… …okay, hit th robot
reset button” :wink:

Our pump code is the following line:

pump_on = pressure

where pump_on is an alias for the proper relay bit and
pressure is an alias for the proper robot controller
switch bit.

The code works fine as far as we can tell. It helps if
your pneumantics don’t have any leaks (it tends to
cycle on/off more as it shuts off if you have leaks).

Joe J.

Posted by Mike Gray at 03/13/2001 7:41 AM EST

Engineer on team HOT from Huron Valley Schools sponsored by GM Milford Proving Ground.

In Reply to: How many teams are using a delay?
Posted by Gary Bonner on 03/12/2001 9:12 PM EST:

We didn’t have a delay initially. We’ve blown two fuses at random intervals. My theory is that low battery voltage, coupled with starting the compressor against a pressure head, cause the 20A fuse to blow sometimes.

Adjusting the set point to 100psi didn’t help.

Posted by Gregory Ross at 03/14/2001 5:23 PM EST

Engineer on team #330, Beach Bots, from Hope Chapel Academy and NASA/JPL.

In Reply to: How many teams are using a delay?
Posted by Gary Bonner on 03/12/2001 9:12 PM EST:

Since the compressor draws a lot of current when it starts up, and our drive motors draw a lot when we are turning, we have both a turn-off delay AND some logic to prevent the compressor from starting up when the robot is turning.