LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to control voltage with my code?

I need to be able to control current and voltage of a power supply. What would be the best way to implement this with my code? I realize that I need to use a DAQmx Start and Stop task. I *think* I would like the task to start when the user runs the program. The voltage and current should be 0 when I start it, or a really low number.

 

Currently, the program I am working off of using TraditionalDAQ. It uses 'AO Write One Update.vi' to update the voltage and current. 

voltage_i_change.PNG

 

How can I use DAQmx to achieve the same? Is it possible to also have the DAQmx code in an event structure in the same way?

 

Can I do this in my event structure, in a new event? The code below shows my code. There are two loops, the bottom one handles acquisition and logging. The top one handles the events.

code_snippet.PNG

0 Kudos
Message 1 of 26
(3,150 Views)

There are an excellent series of NI Tutorials on DAQmx.  Not that they are easy to find, but start here:  DAQmx White Papers.  This is an especially useful White Paper:  The Top 10 DAQmx Functions.

 

Something that also helps a lot is to configure your device using MAX (and use MAX to run it to be sure it is working correctly).  Once you have it configured, save it as a Task, which encapsulates all of the "picky details" (such as channel names/numbers, sampling rates, clock sources, etc.).  When you go to write your code, simply right-click on the Start Task VI and create a constant, expand the Constant (which should show you MAX's Tasks), and choose the Task you just created.  No need for numerous confusing DAQmx Configuration VIs.

 

Bob Schor

0 Kudos
Message 2 of 26
(3,127 Views)

@belopsky wrote:

I need to be able to control current and voltage of a power supply. What would be the best way to implement this with my code?

 



 

Are you controlling an external power supply or an onboard analog out signal?  Your message says power supply but your code says analog out on the daq. Answer is differnent depending on which it is.

Doug

"My only wish is that I am capable of learning each and every day until my last breath."
0 Kudos
Message 3 of 26
(3,122 Views)

Thanks for catching that, I am indeed controlling an analog out (that then is physically wired to the power supply)

 

 

0 Kudos
Message 4 of 26
(3,106 Views)

In that case, do what Bob said.  Create the task in MAX and configure it as needed.  It appears you may also be supplying a PWM signal?  or is it a sine wave?  If a square wave signal, use an onboard counter.

 

What type of power supply takes an analog signal for a control input?

 

Also, if you are using an analog output voltage to control the power supply, why do you have an analog input in your diagram?

Doug

"My only wish is that I am capable of learning each and every day until my last breath."
0 Kudos
Message 5 of 26
(3,089 Views)

I dont have the model in front of me, but the power supply hassome sort of a 'program' input, as it was described to me.

 

The analog in you see is for something else, that is reading input from a different power supply.

0 Kudos
Message 6 of 26
(3,079 Views)

Then I would get a manual for the pwr sply and find out exactly what it needs before trying to develop the control method.

Doug

"My only wish is that I am capable of learning each and every day until my last breath."
0 Kudos
Message 7 of 26
(3,069 Views)

One unrelated question, but about your code:

What is that Queue good for?

Where are you closing the queue reference that you are opening in every iteration of the while loop?

Why compare a bolean to True? What do you get out of the = function ?

And the last one, why are you reading N channels when only one channel is selected and only one channel is used?

0 Kudos
Message 8 of 26
(3,061 Views)

Im not sure what you mean by, why am i closing the queue reference? i am not? i did not think I was..

 

The queu is being used for acquisition and logging. Somewhat a producer/consumer.

 

The = function being used is how i got the program to log only when the Digital line boolean is NOT true.

 

As for your last question, that is just sometihng I have yet to clean up..

0 Kudos
Message 9 of 26
(3,048 Views)

The waveform data goes to the queue, which is then read and written..

0 Kudos
Message 10 of 26
(3,042 Views)