From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to make setpoint dynamic for PID control

Solved!
Go to solution

Hi all, 

 

Here I have a question about setpoint of PID control. Now I've built a program in which the setpoint of the PID vi. can only be a constant. But I want to improve the program by allowing the setpoint to be dynamic, by saying dynamic I mean the setpoint keeps changing with time, it could be like a sine wave, or better could be a custom shape. Could anyone tell me how to fulfill that?

Thanks,

CJ

0 Kudos
Message 1 of 17
(6,018 Views)

Hi CJ,

 

Solution: replace your constant by either a control or a function!

 

What kind of answer do you expect for such a question?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 17
(6,007 Views)

Hi GerdW,

 

Could you please show me how to use control or functions to repleace a constant setpoint? I attached a simple PID vi. 

 

Thanks,

CJ

0 Kudos
Message 3 of 17
(6,001 Views)

If your constant is outside the PID loop simply changing it to a coontrol or function won't make it dynamically settable because with the way dataflow works it will only be read one time. Likewise simply moving a control inside the loop may not help a lot because unless you are doing something with VI Server to dynamically change the control value, the setpoint will, again, be effectively a constant.

 

What you want is something like a FGV (functional global variable) that can be read inside the loop, but can be set from anywhere in your applications.

 

Mike...

 

PS: just saw you VI posting. If you run this VI by itself so you can manually change the setpoint, a control will work fine. However, if (as I suspect) this is going to be just one part of a larger application, you will need to replace the control with a FGV, or something similar. Also, you are using the wrong wait function. You should use the Wait (ms) function.


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 17
(6,000 Views)

Hi Mike,

 

I think you are right, I've tried control and functions,the results are just like what you said. I will learn FGV, if I have further problem, hope you could give me some instructions.

 

Thanks,

CJ

0 Kudos
Message 5 of 17
(5,996 Views)

Hi Mike,

 

I just learnt FGV, from my point of view, I think it's a register of a while loop which can only cycle one time. So here is my question, if I want the setpoint to be dynamic, I will need to assign a value to the setpoint every once in a while, my plan is to use an array(could come from the wave function) and to use the FGV to read one value of the array each time, but I still don't figure out how to achieve this? Do you have any idea about this?

 

Thanks,

CJ

0 Kudos
Message 6 of 17
(5,975 Views)

You will need to have a separate loop in your application that reads the list of setpoints and at whatever interval you want, writes a new setpoint to the FGV.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 7 of 17
(5,964 Views)

I am not very clear about what you said, it seems what you said is using a seperate while loop to assign a value to the FGV each time, but the data flow out of a while loop will be an array rather than one data point. I am stuck in here, the purpose of using FGV is that it can store data and cycle only one time, so there won't be any problem making the FGV inside another while loop which is used to complete PID control, but since it can only cycle one time, it can't realize "index" function. What do you think?

 

CJ

0 Kudos
Message 8 of 17
(5,939 Views)

You have a second while loop that has the FGV inside it also. Each time this second loop iterates it updates the FGV with a new value. Then each time the original loop iterates it will read the last value that the new loop wrote into the FGV.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 9 of 17
(5,929 Views)

How to connect the two PGV?I attached my idea but definitely it's wrong.

0 Kudos
Message 10 of 17
(5,913 Views)