Hi guys
I'm trying to understand how to do the PID processing in V9, in the ProcessPID macro in the attached file I'm doing the following
DSPInput::AddByte(feedback)
then I'm not sure how to process
ProcessPID=DSPControl::GetPIDPortions(Setpoint)
DSPControl1::Process()
Control=DSPOutput1::Getint()
PWM1::SetDutyCycle(Control)
I have looked at the help file on the PID Control in WIKI and the example is the same as the V7 which dose not work as there is no DSPSystem1 component in V9 so really not sure what to do here.
DSP PID control
-
- Posts: 136
- http://meble-kuchenne.info.pl
- Joined: Mon Mar 08, 2021 11:25 am
- Location: Cape Town South Africa
- Has thanked: 41 times
- Been thanked: 12 times
-
- Matrix Staff
- Posts: 1952
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 510 times
- Been thanked: 698 times
Re: DSP PID control
Hello,
Many thanks for letting us know. I've reworked the examples for both PID and OnOff control and hopefully the wiki pages are now more up to date.
Having a look at your project file now.
Many thanks for letting us know. I've reworked the examples for both PID and OnOff control and hopefully the wiki pages are now more up to date.
Having a look at your project file now.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Matrix Staff
- Posts: 1952
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 510 times
- Been thanked: 698 times
Re: DSP PID control
I've reworked your example file a bit and hopefully it now makes a bit more sense.
At the moment the setpoint and feedback will be fed into the DSP chains as bytes with integer type numbers and so your 0.25 degree increments will be lost. If you want higher precision then one way would be not to multiply the feedback by 0.25 and instead have all your units based on 0.25 degree integers. So a setpoint of 4 would be asking for a temperature of 1 degree.
Hopefully that makes sense
At the moment the setpoint and feedback will be fed into the DSP chains as bytes with integer type numbers and so your 0.25 degree increments will be lost. If you want higher precision then one way would be not to multiply the feedback by 0.25 and instead have all your units based on 0.25 degree integers. So a setpoint of 4 would be asking for a temperature of 1 degree.
Hopefully that makes sense

Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Posts: 136
- Joined: Mon Mar 08, 2021 11:25 am
- Location: Cape Town South Africa
- Has thanked: 41 times
- Been thanked: 12 times
Re: DSP PID control
Hi Ben
Thanks for the reply, if I'm understanding you correctly what I should do is take RawData * 0 .25 out and multiply the setpoint by 4 this should give me the correct value to process. After processing then divide setpoint by 4 again for it to display the correct setpoint temp value on display and multyply the fedback by 0.25 so i can display the feedback temp.
Thanks for the reply, if I'm understanding you correctly what I should do is take RawData * 0 .25 out and multiply the setpoint by 4 this should give me the correct value to process. After processing then divide setpoint by 4 again for it to display the correct setpoint temp value on display and multyply the fedback by 0.25 so i can display the feedback temp.
-
- Posts: 136
- Joined: Mon Mar 08, 2021 11:25 am
- Location: Cape Town South Africa
- Has thanked: 41 times
- Been thanked: 12 times
Re: DSP PID control
Hi Ben
I"m having a problem with the PWM and the accuracy of the temp its out about 5 degrees which is quite a lot, I think I have done this correct (So a setpoint of 4 would be asking for a temperature of 1 degree) plus the PWM only starts to work when the temp gets close to the setpoint. It is off before the setpoint (so how dose it heat) and after the set point it switches off again which is correct (if it over shoots elements are off). So not sure what is wrong with PWM
I"m having a problem with the PWM and the accuracy of the temp its out about 5 degrees which is quite a lot, I think I have done this correct (So a setpoint of 4 would be asking for a temperature of 1 degree) plus the PWM only starts to work when the temp gets close to the setpoint. It is off before the setpoint (so how dose it heat) and after the set point it switches off again which is correct (if it over shoots elements are off). So not sure what is wrong with PWM
-
- Matrix Staff
- Posts: 1952
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 510 times
- Been thanked: 698 times
Re: DSP PID control
Hello,
You had some problems with data truncation you were passing values as bytes but your initial setpoint of 78 *4 = 312 which was then passed as a byte which truncated the value to 56.
Here is a program with the bytes replaced with UINTs and hopefully it behaives a bit better for you.
You had some problems with data truncation you were passing values as bytes but your initial setpoint of 78 *4 = 312 which was then passed as a byte which truncated the value to 56.
Here is a program with the bytes replaced with UINTs and hopefully it behaives a bit better for you.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel