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.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

PID control of power supply

Solved!
Go to solution

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.

noPID.png

 

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.

 

withPID.png

 

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

  1. Is my PID-controlled loop not working because the PID loop (on the left) is executing too quickly relative to my power supply loop?
  2. What would you recommend? Notifiers?
  3. (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.

 

 

0 Kudos
Message 1 of 6
(7,352 Views)
Solution
Accepted by topic author aeroAggie

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


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 6
(7,145 Views)

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

0 Kudos
Message 3 of 6
(7,038 Views)

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?

0 Kudos
Message 4 of 6
(7,034 Views)

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

0 Kudos
Message 5 of 6
(6,962 Views)

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

0 Kudos
Message 6 of 6
(6,906 Views)