Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   General Forum (http://www.chiefdelphi.com/forums/forumdisplay.php?f=16)
-   -   Pressure switch code (http://www.chiefdelphi.com/forums/showthread.php?t=25742)

kingpin3787 21-02-2004 14:31

Pressure switch code
 
under which heading do we put the pressure switch code!!!!!!!!!!!!!!!!!?????????????!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!! :yikes:

steven114 21-02-2004 15:21

Re: Pressure switch code
 
Quote:

Originally Posted by kingpin3787
under which heading do we put the pressure switch code!!!!!!!!!!!!!!!!!?????????????!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!! :yikes:

I don't quite understand your question - do you mean which function should it go in? It really doesn't matter too much, although I think that ProcessDatafromMasterUP is the preferred place.

Robert Hafner 21-02-2004 21:18

Re: Pressure switch code
 
Let me see what I can do. . .

Our pressure switch code is wicked simple:

The pressure switch is on digital input 8, and the compressor is on relay 8.

in the initialization routine

relay8_fwd = 1; //Start with compressor on


In the default routine:

if(!rc_dig_in18)
{
relay8_fwd = 1; // If low air pressure, turn on
}else{
relay8_fwd = 0; // If high air pressure, turn off
}

jacob_dilles 21-02-2004 22:14

Re: Pressure switch code
 
if your not a fan of bulky code:

relay8_fwd = !rc_dig_in18;
relay8_rev = 0;

from there, the RC has a built in pull up on the (s) line. soo you connect the white to one side of the switch and the black to the otherside of the switch. that is, if your using a pwm style color coded cable. you dont need the positive at all. the pressure switch is N.C. meening that with this setup the normal signal will be 0 and when it closes it will be 1. therefore !rc_dig_in18 yeilds 1 when it is normal and 0 when it goes over. no if statment needed.

Robert Hafner 21-02-2004 22:16

Re: Pressure switch code
 
Quote:

Originally Posted by jacob_dilles
if your not a fan of bulky code:

relay8_fwd = !rc_dig_in18;
relay8_rev = 0;

bulky? I was just trying to keep it simple. . . :(

jacob_dilles 21-02-2004 22:25

Re: Pressure switch code
 
every "if" statment is at least 4 lines in ASM. add an "else" and that adds 6 more lines. a boolean assinment is only 2 lines. but whatever

Chris Bright 21-02-2004 23:34

Re: Pressure switch code
 
correct me if i am wrong but isn't the code for the pressure switch already in the default as long as you hook up the switch to digital input 18 and the pump to relay 8?

velocipenguin 21-02-2004 23:48

Re: Pressure switch code
 
Quote:

Originally Posted by Chris Bright
correct me if i am wrong but isn't the code for the pressure switch already in the default as long as you hook up the switch to digital input 18 and the pump to relay 8?

Yes. The default code contains the following lines, I believe:

Code:

relay8_fwd = !rc_dig_in18;
relay8_rev = 0;

Connect the pressure switch to the white and black wires of a cable plugged into digital input 18, and you should be all set (assuming you've connected the compressor's relay to relay output 8).

Joe Ross 22-02-2004 10:20

Re: Pressure switch code
 
Quote:

Originally Posted by jacob_dilles
every "if" statment is at least 4 lines in ASM. add an "else" and that adds 6 more lines. a boolean assinment is only 2 lines. but whatever

There is a difference between it being easy for a human to read, and easy for a computer to understand.

Personally, I choose what is easier for me to understand, and in the 2% of cases where it needs to be fast, I write well commented assembly.

Robert Hafner 22-02-2004 21:38

Re: Pressure switch code
 
Quote:

Originally Posted by Joe Ross
There is a difference between it being easy for a human to read, and easy for a computer to understand.

Personally, I choose what is easier for me to understand, and in the 2% of cases where it needs to be fast, I write well commented assembly.

If people ask a question, I'll give easy to understand code. I just wrote that up real quick, and didn't bother to shove it in as few lines of code as possible.

As far as four lines, six lines, or two lines in ASM- this isn't ASM.

jacob_dilles 22-02-2004 21:46

Re: Pressure switch code
 
Quote:

Originally Posted by Robert Hafner
If people ask a question, I'll give easy to understand code. I just wrote that up real quick, and didn't bother to shove it in as few lines of code as possible.

As far as four lines, six lines, or two lines in ASM- this isn't ASM.

but it is compialed as such :cool:

Alan Anderson 22-02-2004 21:52

Re: Pressure switch code
 
Quote:

Originally Posted by jacob_dilles
every "if" statment is at least 4 lines in ASM. add an "else" and that adds 6 more lines. a boolean assinment is only 2 lines. but whatever

Check out the listing of what the compiler produces. An "if" produces a bunch of assembly, but so does an assignment of bit-sized values.


All times are GMT -5. The time now is 17:57.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi