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.
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.
07-10-2015 04:38 PM
Note: I realize this post may be considered off-topic, but I think my problem lies with how I'm trying to control my instrument (not the PID controller); hence, I posted my question here. Please correct me if I'm wrong.
Given: I have a dual channel programmable power supply, a rotary encoder, and a PID controller.
Find: With feedback from the encoder, I would like to use the PID controller to control my power supply's voltage outputs.
My solution
Using the VI below, I can read the encoder and adjust the power supply voltage without a PID controller. The left loop reads the encoder's data, and the right loop lets me "manually" set the voltages to channel 1 and channel 2. More specifically, an event structure inside the right loop sends the latest "desired" channel voltages (that I have entered into the respective controls) to the power supply.
My problem
However, the right while loop doesn't "react" when I replace this "manual" voltage control with a PID controller. The power supply simply doesn't do anything even though the PID is telling the power supply to do something.
Attempted fix
In "highlight execution" mode, I saw that my left loop would run numerous complete iterations, but the data in the right loop would only execute once--and even then the data stopped when it reached the event structure.
Questions
Solved! Go to Solution.
07-12-2015 12:23 AM
Well, the first problem is obvious. You are initializing the supply each time the event occurs. (DON"T DO THAT!)
Initiallize ONCE
Loop OVER
Read Response
Monitor feedback
Adjust stimulus
until exit is requested
Exit Control Loop
Close resource ONCE
07-12-2015 08:05 PM
The next problem is (lower code) that writing a value to an indicator (V2-PID) does not generate an event. Try using a User Event (whihc has nothing to do with the users) or a queue to tranfer the data to the right side loop.
Lynn
07-12-2015 08:28 PM
Okay, I put everything the encoder and power supply blocks into 1 loop and configured the power supply as you recommended. But now I have a different question: since I have two channels that both affect the system, should I have two PID loops?
For example, say you have a boat with two motors on each side and a single compass to provide bearing. You want to create a control system for the navigation: would you create a compass-feedback loop for each motor or a single compass-feedback loop for both motors?
If you chose the latter, wouldn't the two loops conflict?
07-13-2015 05:41 PM
The question is how many boats do you have?
How do the two outputs from the power supply interact? If they are completely independent form each other, then two PID loops is clearly appropriate. If it s a tracking power supply (negative output = -1*positive output), for example, and the load is across the two outputs, only one control loop would be needed.
Lynn
07-20-2015 05:55 PM
Jeff,
Do you have any idea what could be causing my 3rd problem where I can never get the latest voltage?
I've attached an example VI. The voltage reading on "actual voltage (V)" is always 1 iteration behind what it should be. Furthermore, the voltage reading by the very last block before the while loop isn't never right--which leads me to believe I'm not wiring it correctly.
Many thanks,
Farid