PID control

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
User avatar
andreeksteen
Posts: 12
Joined: Mon Jan 06, 2020 9:55 am
Has thanked: 4 times
Been thanked: 10 times
Contact:

PID control

Post by andreeksteen »

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
Attachments
FPLC.fcfx
PID program that will not give PWM output when loaded on hardware
(17.76 KiB) Downloaded 228 times
Andre Eksteen

Biotech Emporium cc
Reg: 2002/104664/23
P O Box 433
Oudtshoorn
South Africa
6620

User avatar
QMESAR
Valued Contributor
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

Post by QMESAR »

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
P1.jpg
P1.jpg (51.84 KiB) Viewed 2908 times

User avatar
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

Post by Benj »

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 :D

User avatar
QMESAR
Valued Contributor
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

Post by QMESAR »

The main deal breaker I beleive is the properties of the timer interrupt icon, currently set to no clock
great spot and catch Ben :oops:

User avatar
andreeksteen
Posts: 12
Joined: Mon Jan 06, 2020 9:55 am
Has thanked: 4 times
Been thanked: 10 times
Contact:

Re: PID control

Post by andreeksteen »

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!!
Andre Eksteen

Biotech Emporium cc
Reg: 2002/104664/23
P O Box 433
Oudtshoorn
South Africa
6620

Post Reply