Skip to content

Navigation Menu

Sign in
Sign up

Using PID_V1 with Servo to Control Gas flow to a grill. Does STune work for non SSR fully proportional operation? #42

Unanswered
eliteTek850 asked this question in Q&A
Discussion options

I think the title states my question well. I am using an ESP32 along with a MAX6675 to control the temp in a gas grill by controlling the propane flow. I would like to use stune to get better PID values. Is it possible to use it where the output is a servo position, not relay timed values?

Thanks!

You must be logged in to vote

Replies: 1 comment

Comment options

I thought I would take a stab at creating a new function called servoPwm that would be used in place of softPwm. Not sure I fully understand softPwm, so let me know what I got wrong. :-)

`float sTune::servoPwm(Servo &myServo, float input, float output, float setpoint = 0, uint8_t debounce = 0) {

// servo optimum position controller
static float optimumOutput;
static bool reachedSetpoint;

if (input > setpoint) reachedSetpoint = true;
if (reachedSetpoint && !debounce && setpoint > 0 && input > setpoint) optimumOutput = output - 8;
else if (reachedSetpoint && !debounce && setpoint > 0 && input < setpoint) optimumOutput = output + 8;
else optimumOutput = output;
if (optimumOutput < 0) optimumOutput = 0;

// PWM servo output
if (!reachedSetpoint && optimumOutput > 0) {
myServo.write(optimumOutput);
}

// static bool servoStatus;
// if (!servoStatus && optimumOutput > (msNow - windowStartTime)) {
// if (msNow > nextSwitchTime) {
// nextSwitchTime = msNow + debounce;
// servoStatus = true;
// ESP32Servo.write(servoPin, optimumOutput);
// }
// } else if (servoStatus && optimumOutput < (msNow - windowStartTime)) {
// if (msNow > nextSwitchTime) {
// nextSwitchTime = msNow + debounce;
// servoStatus = false;
// ESP32Servo.write(servoPin, optimumOutput);
// }
// }
return optimumOutput;
}`

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /