09-03-2014 09:23 AM
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.
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.
09-03-2014 11:33 AM
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
09-03-2014 11:42 AM
@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.
09-03-2014 12:26 PM
Thanks for catching that, I am indeed controlling an analog out (that then is physically wired to the power supply)
09-03-2014 12:49 PM - edited 09-03-2014 12:51 PM
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?
09-03-2014 12:54 PM
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.
09-03-2014 01:24 PM
Then I would get a manual for the pwr sply and find out exactly what it needs before trying to develop the control method.
09-03-2014 01:57 PM
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?
09-03-2014 02:27 PM
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..
09-03-2014 02:31 PM
The waveform data goes to the queue, which is then read and written..