And yet, ANOTHER questions

I know you guys are thrilled to hear another question for me. But, forgive me, I’m truly not very good at this. And at the crucial moments, I am able to think even less…

I have this compressor code. If anyone can find something wrong with my syntax, or something else, please let me know.

Thanks!

high_pressure VAR rc_sw2
compressor VAR relay3_fwd

pressure_check:
If high_pressure = 0 THEN compressor_go_on
If high_pressure = 1 THEN compressor_go_off

compressor_go_on:
compressor = 1
goto end_pump

compressor_go_off:
compressor = 0
goto end_pump

end_pump:

The first thing I notice is that the pressure switch values are reversed. The pressure switch is normally closed, and opens when the system pressure reaches 115 psi. So I would change your code like so:


If high_pressure = 1 THEN compressor_go_on
If high_pressure = 0 THEN compressor_go_off

(I think I would also change the pressure switch alias to low_pressure instead of high_pressure.)

*Originally posted by cammie825 *
**
pressure_check:
If high_pressure = 0 THEN compressor_go_on
If high_pressure = 1 THEN compressor_go_off
**

pressure_check:
If high_pressure = 0 THEN gosub compressor_go_on
If high_pressure = 1 THEN gosub compressor_go_off

i believe you forgot the gosub command. i may be wrong though.

The team has a problem with blaming all mistakes on the programming. This time, my friend, it was the electrician’s fault… haha… Oh well.
Thanks anyway!

easier code (even though your’s does work)

compressor = high_pressure

*Originally posted by yangotang *
**pressure_check:
If high_pressure = 0 THEN gosub compressor_go_on
If high_pressure = 1 THEN gosub compressor_go_off

i believe you forgot the gosub command. i may be wrong though. **

Using the gosub command makes the label act as a subroutine. In otherwords, you are able to use the return command to go back to where you left off. In an if then statement, any label stated after the then is considered to be a goto statement. The goto command simply jumps to the corresponding label and does not allow usage of the return command.

*Originally posted by gwross *
**


If high_pressure = 1 THEN compressor_go_on
If high_pressure = 0 THEN compressor_go_off
**

if the pressure is high, why would on want to turn on the compressor? Subsequently, if high_pressure = 0, meaning the pressure was not high, wouldn’t you want to turn on the compressor, not turn it off? cammie got it right in the beginning. but joe ross does have a point on how to make the code easier, though i would change it to this:

compressor = ~high_pressure

~ being the symbol for NOT

-Kesich

the switch is closed (1) when it is below pressure and open (0) when it is full. See the pneumatics manual

we have switches provided by the Nason company. These switches are normally closed. The switches open at approximately 115 psi and will close again at approximately 95 psi

thus, compressor = high_pressure is correct. do not use the ~.

Like gwross said, the variable name high_pressure is a misnomer. It is a 1 when low pressure, and so should probably be called low_pressure

*Originally posted by cammie825 *
**I know you guys are thrilled to hear another question for me. But, forgive me, I’m truly not very good at this. And at the crucial moments, I am able to think even less…
**

Don’t get discouraged! Programming (like just about everything else) takes a lot of practice to become good at it. The more you do it, the more natrual the thought process and the more natrual the code will come. Places like this message board are great places for getting your code checked and for even some old(er) hands at this to learn something new :slight_smile: