Closed SkyNet26 closed 6 years ago
Can you provide example code?
double Kp=0, Ki=0, Kd=1; uint16_t deadband = 0; int output_bits = 1; bool output_signed = false;
FastPID myPID(Kp, Ki, Kd, deadband, output_bits, output_signed);
void setup() { Serial.begin(9600); }
void loop() { int setpoint = 500; int feedback = analogRead(PIN_INPUT); int output = myPID.step(setpoint, feedback); analogWrite(PIN_OUTPUT, 255 - output); Serial.print("sp: "); Serial.print(setpoint); Serial.print(" fb: "); Serial.print(feedback); Serial.print(" out: "); Serial.println(output); delay(100); }
sp: 500 fb: 256 out: 0 sp: 500 fb: 258 out: 0 sp: 500 fb: 260 out: 0 sp: 500 fb: 275 out: 0 sp: 500 fb: 327 out: 0 sp: 500 fb: 361 out: 0 sp: 500 fb: 379 out: 0 sp: 500 fb: 297 out: 1 sp: 500 fb: 276 out: 1 sp: 500 fb: 261 out: 1 sp: 500 fb: 253 out: 1 sp: 500 fb: 251 out: 1 sp: 500 fb: 224 out: 1 sp: 500 fb: 199 out: 1 sp: 500 fb: 149 out: 1 sp: 500 fb: 111 out: 1 sp: 500 fb: 124 out: 0 sp: 500 fb: 133 out: 0 sp: 500 fb: 145 out: 0 sp: 500 fb: 159 out: 0
Please tell me why the library does not work, values do not increase more than 1.
Hi, It's a bug in the example code! Sorry! There's a new version of the example that works with the latest release. The example you have will work if you change this line:
int output_bits = 1;
to this:
int output_bits = 8;
Sorry for the confusion!
Thank you!
сб, 21 апр. 2018 г., 19:24 Mike Matera notifications@github.com:
Hi, It's a bug in the example code! Sorry! There's a new version of the example that works with the latest release. The example you have will work if you change this line:
int output_bits = 1;
to this:
int output_bits = 8;
Sorry for the confusion!
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mike-matera/FastPID/issues/2#issuecomment-383310398, or mute the thread https://github.com/notifications/unsubscribe-auth/AR1vNETWBYguwU7irdOeCIvMWXYP4_Cyks5tq11BgaJpZM4TcicD .
Help with the FastPID library. When the feedback changes, the output changes between 0 and 1.