Greater than but less than statement - PID sketch

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…

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.

Cabinet.cpp: In function ‘void loop()’:
Cabinet:109: error: expected primary-expression before ‘<’ token
Cabinet:113: error: expected primary-expression before ‘<’ token

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!

gap > 1.0 && gap < 0.5

You need two comparisons…

 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.

Jimmy60:

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

+1 !!!

Thanks so much!