Temperature Control
02 Apr 2024 22:38 #297475
by PCW
Replied by PCW on topic Temperature Control
Also adding some bias to the PID output or FF0 might help
(since at a fixed high temperature, this would better match the model)
(since at a fixed high temperature, this would better match the model)
Please Log in or Create an account to join the conversation.
04 Apr 2024 00:20 - 04 Apr 2024 00:21 #297552
by andypugh
Replied by andypugh on topic Temperature Control
A basic PID controller is very little code at all. Here is an off-the-cuff attempt in the .comp format.
I haven't actually tried to compile or run this (it's late here). But something very like this, with a few tweaks, would probably do all that is required.
Note that this implementation is absolutely _not_ robust against changes in the servo thread rate. If you change that setting it would need completely re-tuning.
component tpid "A pid component for temperature control";
pin in float command;
pin in float feedback;
pin out float output;
pin in float Pgain;
pin in float Igain;
pin in float Dgain;
license "GPL-2.0+";
author "andypugh";
;;
static double prev_error;
static double integ;
double diff;
double error = command - feedback;
integ += error * Igain;
diff = (prev_error - error) * Dgain;
prev_error = error;
output = error * Pgain + integ + diff;
if (output < 0) {
output = 0;
integ = 0; // Might be right, might be wrong.
}
I haven't actually tried to compile or run this (it's late here). But something very like this, with a few tweaks, would probably do all that is required.
Note that this implementation is absolutely _not_ robust against changes in the servo thread rate. If you change that setting it would need completely re-tuning.
Last edit: 04 Apr 2024 00:21 by andypugh.
The following user(s) said Thank You: lkavan
Please Log in or Create an account to join the conversation.
07 Apr 2024 18:48 #297760
by lkavan
Replied by lkavan on topic Temperature Control
Well, is it possible to create own HAL component? Then it can work, yes, I know PID algorithm. I will try to find how to compile and use. Will be nice to create such temperature control component also with temp_ok signal.
PCW: Thanx a lot, "near" is what I looked for!
PCW: Thanx a lot, "near" is what I looked for!
Please Log in or Create an account to join the conversation.
Time to create page: 0.086 seconds