Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with generating a waveform output and a DC voltage output on two separate pins on AO module (NI 9264)

I am using the NI cDAQ-9189 with an Analog Output module (NI 9264) with LabVIEW 2021 on windows for a project. I have also installed the DAQmx drivers to make use of the DAQmx pallet.

I want to generate a square wave on one pin where all parameters of the waveform are preset and fixed except for the frequency which the user can dynamically change and I also want to generate a DC voltage output on another pin where the user can dynamically change the output voltage between 0-5 volts.

In the block diagram, I created two different tasks constants through the DAQmx pallet for the two pins and used them to write, start, stop or clear task (also used from the DAQmx pallet). The issue I am facing is that when I generate the square wave on one pin, I am not able to generate the DC voltage output on the other pin simultaneously. An error with error code "-50103" occurs which says "The specified resource is reserved. The operation could not be completed as specified.". If I stop and clear the waveform task first and then start the DC voltage output task then It works and I do not get an error, but that just means I have to stop one of the tasks for the other to work. I am not able to run both tasks simultaneously.

 

Therefore my question is, can we generate a waveform and a DC voltage output on two different pins simultaneously on the same AO module (NI 9264) or do I have to get another AO module to avoid the "resource is reserved" issue?

0 Kudos
Message 1 of 8
(1,226 Views)

It is not about DC and waveform, it is about whether you can run two DAQmx tasks simultaneously.

 

IIRC, cDAQ chassis have only one Timing Engine for AO task type, this means, at any point in time, only one HW Timed AO task can run on the cDAQ. Since your second signal does not require HW timed output, you can skip the DAQmx timing configuration, this way the waveform will take up the Timing Engine and the DC channel will not need a Timing engine and thereby not hit the "The specified resource is reserved" constraint.

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 8
(1,217 Views)

Thankyou for the quick response.

I am not using the DAQmx timing configuration anyways for the DC channel. I am only using it for the Waveform task which as you correctly mentioned is a HW timed AO task. But I still get the resource is reserved error.

One thing that I tried is, I used the "DAQmx Control Task" vi to unreserve the resource right after I started the DC voltage task. Since the channel retains the last updated value, it worked for the DC channel. I was able to start the waveform task since the resource was unreserved explicitly in the DC voltage task. But this does not work for the Waveform task as unreserving the resource right after starting the waveform just stops the task and only the last updated value of the waveform is retained on the waveform channel and I don't get the continuous waveform. 

 

I hope you are able to understand what I am trying to say as it was a little hard for me to explain as well.

0 Kudos
Message 3 of 8
(1,209 Views)

Please attach the VI, attaching the VI will be easier than describing the implementation in words.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 4 of 8
(1,197 Views)

Code will help (preferably saved back several LV versions), but here are some other thoughts in the meantime.

 

1.  At least on the desktop DAQ devices I'm mainly familiar with, AO tasks can have their sample rate changed on-the-fly.  In theory, you could define a square "waveform" with a buffer of only 2 samples -- the low state and high state.  And then you'd set the sample rate to be 2x the desired square wave frequency.  By updating the sample rate "on the fly", you could change the freq of the output square wave.

   In practice you should probably define a bigger task buffer than that, maybe something more in the realm of 0.1 sec worth.

 

2. While you can run unclocked AO tasks simultaneously, any clocked AO task will reserve resources such that any other AO task (even an unclocked one) can't be started.

 

3. The only way to update your "static" channel while the waveform continues is to define both channels to be part of a single clocked task.  Write a full buffer worth of data containing both your square wave and your "quasi-static" output.  If, for example, your square wave was a DBL array of 10 AO values alternating between -5V and +5V, you can make another DBL array of 10 identical AO values for your static channel.  Write this new set of values to the task to continue your square wave uninterrupted while updating your static output.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 5 of 8
(1,187 Views)

I'm afraid I'm not at liberty to share the contents of the code for confidentiality reasons, hope you understand.

Thanks anyways for your inputs, although I have not found the solution to my problems, your inputs did help me understand the problem better.

0 Kudos
Message 6 of 8
(1,150 Views)

Thankyou for your inputs! 

The point that you mentioned in your point no. 2, I was worried that might be the case and you just confirmed it.

I am going to try what you mentioned in point no. 3. Hopefully it works. What I'm thinking is, to mimic the DC channel, I would generate a waveform with 100% duty cycle, this way I'm hoping the issue with resource being reserved would be mitigated. Would like to hear your thoughts about this idea.

0 Kudos
Message 7 of 8
(1,147 Views)

Square wave generation with 100% duty cycle seems like it ought to work and gives you the convenience of outputting a waveform type directly.   If somehow it doesn't work out, another option is to take a copy of your *other* real square waveform and substitute only the Y[] array with a simple array full of your DC value.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 8 of 8
(1,136 Views)