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: 

PID control with a real plant

Hello, people of the NI community! My name is Alex and here is my problem: (a brief intro) I have a test rig with a rotor and two (Z and X) displacement sensors checking the position of the rotor, and a servovalve installed on the Z axis to control the pressure, which is measured by the pressure sensor, the liquid is water. So by means of the PID controller I want to check the response of the test rig to the displacement we cause by  manually affecting the rotor position. Attached you will find the vi I've produced which ofc is not working properly. Now there are a few things I would like to point out: the AO line is switched between manual control implemented by the slider and a PID control, which is just the way we yet want it. Default is manual control, when switched to automatic (button status true) the local variable of the z-axis displacement is taken as a process variable, set point is set manually and the output range is set to 0..10 as it occured it corresponds to the 0..10 V on my AO device. On the servovalve theres a display which can show the voltage on it and the problem is that when switched to automatic control, it still says the value that was left from manual control, and the control chart shows the following: there is some default dt and the value changes from some not equal to 0 to zero during the dt, and the chart does not normally run. I also used some hardware to measure the voltage when PID is on, and it still says the value which was left from manual control. When switched back to manual control, it carries on implementing correctly. So, guys, I ran out of ideas and yes I have checked out the examples, there just must be some thing that i completely miss. Thank you, any help will be appreciated!  

0 Kudos
Message 1 of 7
(2,913 Views)

Hi Alex,

 

reading a long text without any breaks/paragraphs is really hard… 😉

 

Problems:

- In your PID loop you build a waveform using the PID output AND the PID dt output. Why do you do so? What's the reason to put the dt value into the samples of your waveform?

- You wire a dt input into the PID but there is no appropriate timing in the PID loop…

- There's no need to configure your AO task with a sample rate when you want to output single values from your PID…

Best regards,
GerdW


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

Hey, GerdW!

 

Thanks a lot for the reply and sorry for no paragraphs 😉 now, what are the possible solutions that you could recommend? Thank you 

0 Kudos
Message 3 of 7
(2,889 Views)

Hi Alex,

 

what are the possible solutions that you could recommend?

Remove the problems I mentioned before…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 7
(2,883 Views)

So as far as I understood, I still need to build a waveform to connect to the input of the write task, but the dt value is taken from the PID's dt input? I think they should somehow correspond to each other. 

 

Then, should I remove the DAQmx Timing block? How do I make the PID loop's timing 'appropriate?' Thank you and sorry for being dumb 😄 

0 Kudos
Message 5 of 7
(2,873 Views)

Hi Alex,

 

I still need to build a waveform to connect to the input of the write task

No, you could set DAQmxWrite to accept a scalar value…

 

but the dt value is taken from the PID's dt input?

No, dt should NEVER put into the samples of the waveform!

 

should I remove the DAQmx Timing block? How do I make the PID loop's timing 'appropriate?

Yes, put a wait into the while loop.

 

sorry for being dumb

NI offers a lot of FREE online resources to learn each aspect of LabVIEW!

Best regards,
GerdW


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

GerdW, thank you for the tips, but some problems that occur are not covered by the manuals and stuff like that, so its just a process of trial and error... now that the one last question, I think: why do I change the input of the write task to scalar when it only allows when 1 sample is written? Wait doesnt solve the problem...Thank you

0 Kudos
Message 7 of 7
(2,859 Views)