Page 1 of 1

PID control

Posted: Thu Jan 30, 2020 6:31 pm
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

Re: PID control

Posted: Fri Jan 31, 2020 8:11 am
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 3333 times

Re: PID control

Posted: Fri Jan 31, 2020 11:28 am
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

Re: PID control

Posted: Fri Jan 31, 2020 11:31 am
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:

Re: PID control

Posted: Fri Jan 31, 2020 1:38 pm
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!!