Please help me. I am new to Flowcode and I am having issues with my PID program that I want to use in an automated process. In Flowcode the simulation looks great and everything seems to be working. When I upload to the Adruino Uno R3 I do not get any PWM output. I tried finding the problem in my code, but I cannot seem to pin it down so I decided to ask for help.
I wrote a simple test program that uses two 10K pots on A0 and A1 with a PWM output to D3 and that works perfectly when uploaded to the same hardware, so my problem must be within my coding of the PID.
I apologise if someone else also ha the same problem and I am duplicating that post, but I could not find an answer reading through the other PID issues in the forum
I am using Flowcode 8 with all the latest updates
PID control
Moderator: Benj
- andreeksteen
- Posts: 12
- Joined: Mon Jan 06, 2020 9:55 am
- Has thanked: 4 times
- Been thanked: 10 times
- Contact:
PID control
- Attachments
-
- FPLC.fcfx
- PID program that will not give PWM output when loaded on hardware
- (17.76 KiB) Downloaded 232 times
Andre Eksteen
Biotech Emporium cc
Reg: 2002/104664/23
P O Box 433
Oudtshoorn
South Africa
6620
Biotech Emporium cc
Reg: 2002/104664/23
P O Box 433
Oudtshoorn
South Africa
6620
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: PID control
Hi Andre,
I am not a big help with Arduino however Looking at your Flowchart I did notice you are using 8 bits for ADC and PWM Settings
which is OK I guess (but make sure you apply antiwindup it happens easily with 8 bit numers )
Then the issue I see is that the Control Output variable is defined as a UINT(16bit but you write to the PWM with the 8 bit function This can cause issues,not saying it is in your case but could easily be the Problem.
Fix it up and try again and let us know how you get along
I am not a big help with Arduino however Looking at your Flowchart I did notice you are using 8 bits for ADC and PWM Settings
which is OK I guess (but make sure you apply antiwindup it happens easily with 8 bit numers )
Then the issue I see is that the Control Output variable is defined as a UINT(16bit but you write to the PWM with the 8 bit function This can cause issues,not saying it is in your case but could easily be the Problem.
Fix it up and try again and let us know how you get along
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PID control
Another thing I noticed is your I coeffient is greater than 1, ideally this should be less than 1.
The main deal breaker I beleive is the properties of the timer interrupt icon, currently set to no clock
The main deal breaker I beleive is the properties of the timer interrupt icon, currently set to no clock
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: PID control
great spot and catch BenThe main deal breaker I beleive is the properties of the timer interrupt icon, currently set to no clock
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- andreeksteen
- Posts: 12
- Joined: Mon Jan 06, 2020 9:55 am
- Has thanked: 4 times
- Been thanked: 10 times
- Contact:
Re: PID control
Thank you guys so much for the help.
Benj, thank you for pointing out my rooky mistake with the "no timer"! Now that I have that corrected the program runs perfectly on the Arduino.
QMESAR, thank you for the advice about antiwind up and I will definitely do that if I do use the program in an actual process with this board.
Again thank you guys for he help. It's really nice to be able to get help when one gets into a corner and cannot see what you are doing wrong. Highly appreciated!!
Benj, thank you for pointing out my rooky mistake with the "no timer"! Now that I have that corrected the program runs perfectly on the Arduino.
QMESAR, thank you for the advice about antiwind up and I will definitely do that if I do use the program in an actual process with this board.
Again thank you guys for he help. It's really nice to be able to get help when one gets into a corner and cannot see what you are doing wrong. Highly appreciated!!
Andre Eksteen
Biotech Emporium cc
Reg: 2002/104664/23
P O Box 433
Oudtshoorn
South Africa
6620
Biotech Emporium cc
Reg: 2002/104664/23
P O Box 433
Oudtshoorn
South Africa
6620