07-23-2014 01:30 PM
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
Solved! Go to Solution.
07-23-2014 02:06 PM
07-23-2014 02:14 PM - edited 07-23-2014 02:15 PM
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
07-23-2014 02:14 PM - edited 07-23-2014 02:18 PM
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.
07-23-2014 02:19 PM
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
07-23-2014 03:20 PM
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
07-23-2014 03:31 PM
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...
07-24-2014 08:46 AM
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
07-24-2014 09:10 AM - edited 07-24-2014 09:10 AM
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...
07-24-2014 10:21 AM
How to connect the two PGV?I attached my idea but definitely it's wrong.