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
- Is my PID-controlled loop not working because the PID loop (on the left) is executing too quickly relative to my power supply loop?
- What would you recommend? Notifiers?
- (Slightly unrelated) How should I get the latest voltages from my power supply?
The two "read output" blocks in the power-loop should enable me to display the actual voltage of a channel. However, This data is always one "step" behind the actual reading.
For example, I will set V1 = 12V. The power supply reacts and displays 11.998V on its LCD screen. However, my LV code displays 0V (or whatever value V1 previously held). If I change V1 again, say V1 = 7.9V, then the power supply will display 7.989V but the LV code will display 11.998V. What am I doing wrong?
Notet that if I set V1, and then set V2, my LV code will display the correct V1 value but not the latest V2 value.