Page 1 of 1

Help with PID code (does it work?)

Posted: Fri Jun 10, 2022 1:20 pm
by OderlandoAbril
I'm having some difficulties understanding. I've done a lot of research on the subject. I downloaded an example from the wiki and made some modifications.
Doubt 1: I'm trying to create a flowchart so that I can define the values of P, I and D through variables in which I can reset their values at any time (I used floating point variables. Any problem with that? Doubt 2: the way what I did in the flowchart is correct?).
Doubt 3: The flowchart uses the reading of an analog input as a setpoint, but I would like the setpoint to be defined by the value of the ADC variable, but I haven't found a way to do that. It's possible ?
I'm a little confused...

Re: Help with PID code (does it work?)

Posted: Fri Jun 10, 2022 1:54 pm
by BenR
Hello,

Yes that looks fine. Please can you check you're using the latest components by clicking on Help -> Library Updates. This might break your DSP connections so I've reconnected things with the latest components for you here. All seems to be working in simulation so hopefully should also work ok on hardware.
PID_Control.fcfx
(16.64 KiB) Downloaded 71 times

Re: Help with PID code (does it work?)

Posted: Fri Jun 10, 2022 5:44 pm
by OderlandoAbril
Hello Ben ! Thank you very much for your help. I'll test if it works in real life. I'm really glad you cared. Thanks

Re: Help with PID code (does it work?)

Posted: Fri Jun 10, 2022 6:32 pm
by OderlandoAbril
Hello again, Ben. I updated the library as you said. But now I can't make the component connections. I'm sending a screenshot of what it looks like for me. The checkbox for connections appears blank. Do you know what could be happening?

Re: Help with PID code (does it work?)

Posted: Mon Jun 13, 2022 10:38 am
by BenR
Hello,

When you do the library updates, please change the drop down at the bottom from files in use to fuill database.

Hopefully this should solve the issue for you.

Re: Help with PID code (does it work?)

Posted: Mon Jun 13, 2022 11:05 am
by OderlandoAbril
Hello Ben. This solved the problem. Thank you for this. But I still have a doubt: I would not like to use an analog input as a setpoint, but I would like to use the value saved in a byte variable to be my setpoint. Is this possible ?

Re: Help with PID code (does it work?)

Posted: Mon Jun 13, 2022 12:08 pm
by BenR
Yes that's possible just use a second Digital input to drive the setpoint and the value for this can be assigned from your control variable.

Re: Help with PID code (does it work?)

Posted: Mon Jun 13, 2022 3:11 pm
by OderlandoAbril
It worked very well. Thanks