Help with PID code (does it work?)

For general Flowcode discussion that does not belong in the other sections.
Post Reply
OderlandoAbril
Posts: 10
http://meble-kuchenne.info.pl
Joined: Tue Apr 06, 2021 6:06 pm
Has thanked: 2 times
Been thanked: 1 time

Help with PID code (does it work?)

Post 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...
Attachments
DSP2.PNG
DSP2.PNG (82.22 KiB) Viewed 1915 times
DSP.PNG
DSP.PNG (79.68 KiB) Viewed 1915 times
PID_Control.fcfx
(16.43 KiB) Downloaded 55 times

BenR
Matrix Staff
Posts: 1707
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

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

Post 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 68 times

OderlandoAbril
Posts: 10
Joined: Tue Apr 06, 2021 6:06 pm
Has thanked: 2 times
Been thanked: 1 time

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

Post 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

OderlandoAbril
Posts: 10
Joined: Tue Apr 06, 2021 6:06 pm
Has thanked: 2 times
Been thanked: 1 time

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

Post 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?
Attachments
Print.PNG
Print.PNG (80.94 KiB) Viewed 1894 times

BenR
Matrix Staff
Posts: 1707
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

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

Post 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.

OderlandoAbril
Posts: 10
Joined: Tue Apr 06, 2021 6:06 pm
Has thanked: 2 times
Been thanked: 1 time

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

Post 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 ?

BenR
Matrix Staff
Posts: 1707
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

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

Post 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.

OderlandoAbril
Posts: 10
Joined: Tue Apr 06, 2021 6:06 pm
Has thanked: 2 times
Been thanked: 1 time

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

Post by OderlandoAbril »

It worked very well. Thanks

Post Reply