Go Down

Topic: Greater than but less than statement - PID sketch (Read 1 time) previous topic - next topic

FlyingSteve

Hi guys,

I'm working with a PID sketch and I want to setup trigger points for different PID settings depending on how far the input is from the setpoint.
The original code for this section looks like this and it works fine...

Code: [Select]
double gap = abs(Setpoint-Input); //distance away from setpoint
  if(gap<10)
  {  //we're close to setpoint, use conservative tuning parameters
    myPID.SetTunings(consKp, consKi, consKd);
  }
  else
  {
     //we're far from setpoint, use aggressive tuning parameters
     myPID.SetTunings(aggKp, aggKi, aggKd);
  }


However, I want finer control so I came up with this, but it does not work.
Quote
Cabinet.cpp: In function 'void loop()':
Cabinet:109: error: expected primary-expression before '<' token
Cabinet:113: error: expected primary-expression before '<' token


Code: [Select]
if(gap <= .5){
    seedHTxch.SetTunings(UconsKp, UconsKi, UconsKd);
    }

    if(gap > .5 && < 1){
    seedHTxch.SetTunings(consKp, consKi, consKd);
    }

    if(gap >= 1 && < 2)
    {
    seedHTxch.SetTunings(aggKp, aggKi, aggKd);
    }
   
    if(gap >= 2)
    {
    seedHTxch.SetTunings(UaggKp, UaggKi, UaggKd);
    }


I've tried all I can think of and used the reference guide to try and find the proper commands but nothing I can come up with works.

Please help

Thanks!

James C4S

gap > 1.0 && gap < 0.5


You need two comparisons...
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Jimmy60

Code: [Select]
if(gap > .5 && < 1)   // this is incomplete

if(gap > .5 && gap < 1)      // this is probably what you wanted

if (.5 < gap && gap < 1)     // this is how I'd do it only because that shows gap between the two values


You've repeated this little error.

johncc


Code: [Select]
if (.5 < gap && gap < 1)     // this is how I'd do it only because that shows gap between the two values



+1 !!!


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy