Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Power Supply Control with Smart Voltage

I am attempting to develop a VI for the Xantrex XHR 300-3.5 Power Supply to accomplish the following:

Given a desired voltage endpoint, the VI should gradually increment the voltage to prevent a high current which will burn the sample.
My control flow goes like this:
Start voltage at 0, increment by 1V.
Measure the voltage, if this voltage is less than the setpoint, a while loop is entered with Vmeas>=Vset as the exit condition.
Inside the while loop, the current is measured.  If the current is < max current, the voltage is incremented by 1.
If the current is >= max current, the voltage is decremented by 1.  This current comparison and voltage increment/decrement is accomplished with a case structure.
I've inserted timing loops to wait a few seconds while the sample current/voltage respond, since the current tends to peak immediately after a voltage increase then gradually fall.

The problem I'm having is that the program will run once and nothing happens to the power supply.  I can't see where the problem is occuring. 
Please take a look at the VI I've attached to see where I'm going wrong.  I've also attached the .zip file containing the Xantrex XHR library and other pertinent files.

Thank You
-Andrew
Download All
0 Kudos
Message 1 of 6
(4,066 Views)
The logic for stopping the while loop looks backwards. If the setpoint is greater than the actual voltage, the loop stops.
0 Kudos
Message 2 of 6
(4,065 Views)
Thanks for the proofreading, I worked with that for about a week and didn't see that bug.  The program works as desired now.  What would be the easiest way to generate voltage vs. time and current vs. time graphs in this VI?
-Andrew
0 Kudos
Message 3 of 6
(4,030 Views)
You will want to use a chart (or two charts) and place the terminal inside the while loop. If you want to use a single chart, you use the bundle function and wire the current and voltage measurements to the inputs of the bundle and wire the output to the chart. Create a duplicate scale and assign the voltage to one scale and current to the other. For multiple charts, you just wire the measurment directly to the chart. For the x axis, to accurately represent the actual time, you would want to something like the shipping example called Real-Time Chart. Open the Example Finder and do a search for 'chart'. What this does is wwrite the start time and loop rate to a property node of the chart.
0 Kudos
Message 4 of 6
(4,024 Views)
What about if I just want to use elapsed time, instead of actual time?
Also, when the final voltage condition is reached and the while loop exits, how would I continue to input the measured voltage and current values to the same chart?

I would like to produce a graph displaying all voltage and current measurements from when I start the program to when I come back a day later and stop the program.
0 Kudos
Message 5 of 6
(3,998 Views)

The x axis can be set for absolute or relative time. To initialize it to 00:00:00, just wire a 0 to the XScale.Offset property. To continue writing to the same chart, there are a couple of ways. If, after the ramp loop, you proceed to another loop, just place a local variable of the chart in the second loop.

You also need to be aware of how the chart works. If you right click on the chart, you will see an option called Chart History Length. This is the number of points the chart will maintain before dropping old data and replacing them with new. If you intend to run the program for an extended period of time, you would need to calculate the size of the history based on how often you are acquiring data. When I've used a chart with frequent readings, I will write the data to a file and when the program finishes, read from the file and display the entire file with a graph and not a chart.

0 Kudos
Message 6 of 6
(3,993 Views)