Need help with If greater than less than newbie
first off, didn't write entire code. way on skill level. modified areas suit needs.
i in need of getting code want. i'm trying make code tell turbo open set position when drivepressure > boostpressure, , turbo close set position when drivepressure < boostpressure. need starting position of "740" when there 0 psi both sensors.
i have uploaded arduino file , here section i'm trying work with.
"
void loop()
{
// variables read sensors
int potentiometervalue = 0;
int exhaustpressure = 0;
int boostpressure = 0;
boolean switchposition = true;
// value send position
int desiredposition = 0;
// variables use within code
int jumpsize = 5;
// start loop read sensors , send position turbo
while(1)
{
// read switch
switchposition = digitalread ( switch );
// read sensors
potentiometervalue = readpotentiometer();
exhaustpressure = readexhaustpressure();
boostpressure = readboostpressure();
// determine mode
if ( !switchposition )
{
desiredposition = readpotentiometer();
}
else
{
if( exhaustpressure > boostpressure + 1)
{
desiredposition = desiredposition - 25;
}
else if( exhaustpressure < boostpressure - 1)
{
desiredposition = desiredposition + 25;
}
}
// set turbo position
sendturboposition( desiredposition );
// delay processor
delay(1);
}
}
"
any appreciated, , if didn't make whole lot of sense i'm trying let me know , i'll try explain better.
i in need of getting code want. i'm trying make code tell turbo open set position when drivepressure > boostpressure, , turbo close set position when drivepressure < boostpressure. need starting position of "740" when there 0 psi both sensors.
i have uploaded arduino file , here section i'm trying work with.
"
void loop()
{
// variables read sensors
int potentiometervalue = 0;
int exhaustpressure = 0;
int boostpressure = 0;
boolean switchposition = true;
// value send position
int desiredposition = 0;
// variables use within code
int jumpsize = 5;
// start loop read sensors , send position turbo
while(1)
{
// read switch
switchposition = digitalread ( switch );
// read sensors
potentiometervalue = readpotentiometer();
exhaustpressure = readexhaustpressure();
boostpressure = readboostpressure();
// determine mode
if ( !switchposition )
{
desiredposition = readpotentiometer();
}
else
{
if( exhaustpressure > boostpressure + 1)
{
desiredposition = desiredposition - 25;
}
else if( exhaustpressure < boostpressure - 1)
{
desiredposition = desiredposition + 25;
}
}
// set turbo position
sendturboposition( desiredposition );
// delay processor
delay(1);
}
}
"
any appreciated, , if didn't make whole lot of sense i'm trying let me know , i'll try explain better.
your loop( ) function executed repetitively, , frequently.
i doubt want keep increasing or decreasing "desiredposition" many times, indefinitely. become millions, in no time, or if arduino's not stuck 16 bit ints.
you attempting control device setting based on comparison between actual measured pressure , desired pressure. conceptually similar heating thermostat turning on off, several differences. the first issue, how want turn on, , off. annoying , destructive keep turning heat, or air-con, or refrigerator, on , off every few seconds. for reason, need understand word "deadband". google it. second issue trying set control value, rather "on" or "off".
initialisation should not problem. you set initial value in setup( ) function.
each time read sensor, need check value read sensible. if not sensible, don't use it.
the next thing should research, pid control. google it. that second-simplest option, after turning on , off, unlikely work application.
i doubt want keep increasing or decreasing "desiredposition" many times, indefinitely. become millions, in no time, or if arduino's not stuck 16 bit ints.
you attempting control device setting based on comparison between actual measured pressure , desired pressure. conceptually similar heating thermostat turning on off, several differences. the first issue, how want turn on, , off. annoying , destructive keep turning heat, or air-con, or refrigerator, on , off every few seconds. for reason, need understand word "deadband". google it. second issue trying set control value, rather "on" or "off".
initialisation should not problem. you set initial value in setup( ) function.
each time read sensor, need check value read sensible. if not sensible, don't use it.
the next thing should research, pid control. google it. that second-simplest option, after turning on , off, unlikely work application.
Arduino Forum > Using Arduino > Programming Questions > Need help with If greater than less than newbie
arduino
Comments
Post a Comment