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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx changing channel

Hi,

 

I’m trying to generate 4 audios on 4 different channels of a PXI using DAQmx. In particular in my vi I create the desired audios by adding different components. Then I need that the best signal shift after each iteration from the first channel to the second one and so on. I obtained that with a case struct controlled by the value of the for-loop iteration i. The problems arise at the second loop showing a message of unnamed task or error on the DAQmx start task. I have tried everything, placing the creating, closing and clear task Vis inside and outside the Case struct and the for loop, but I can’t understand the reason behind these errors. Can anyone help me?

 

Thank you for everything!

 

Best Regards,

Zuc

0 Kudos
Message 1 of 14
(1,164 Views)

Which error code and message are you getting?

0 Kudos
Message 2 of 14
(1,149 Views)

Please attach the VI in an earlier version (preferably 2016)

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 3 of 14
(1,145 Views)

Some general comments:

  • If you are going to do Continuous Waveform Generation, you want to start the AO Task before the While loop containing the DAQmx Write, and generate the next batch of points while the first buffer is being written, ensuring you'll have continuity from one set of data points to the next.  Note that this means that you can't "instantly stop" the output.
  • If you want your Waveforms to be offset-in-time from each other, one way would be to run them in separate (but parallel) loops, each with an appropriate delay before Starting the Task and subsequent While Loop.
  • Have you tried doing a single channel without worrying about multiple channels?  That should have shown you the problem I noted in the first Bullet Point.
  • I noticed you are reading a Sound File.  Are you trying to shove the entire Waveform down the DAQmx Write all-at-once?  You might end up with some monstrous Waveforms.  Notice that the Sound Read function allows you to specify how many samples long the Waveform(s) should be.  Let's say you are doing "ordinary Audio", with a sampling rate of 44.1 kHz (I think that's the Magic Number).  If you specify a Waveform length of 4410 samples, and your sound file is 10 seconds long, your Sound Read will return an Array of 10 (seconds) x 44100/4410 (samplings/second) = 100 Waveforms, each of which takes 0.1 second to play.  So you feed this Array into your For Loop (through an Indexing Tunnel), take the (next) Waveform, sending to the DAQmx Write, and immediately wire the Task and Error Lines to the far edge of the For Loop, with nothing else, no Waits, no Stops, nothing.  Just "write the Next Waveform", over and over.  Let DAQmx and the D/A converter be your "clock" -- it will take exactly 0.1 seconds for each "chunk" of data to be written.  The output will, in fact, be "continuous"!
  • Note that having delays between your various Channels argues in favor of putting the Delays before 4 individual "Play" For Loops.

Hope this is helpful.

 

Bob Schor

Message 4 of 14
(1,109 Views)

Bob's recommendation to start with a single channel will help you get started. In that same spirit of getting started, try the DAQmx analog output examples. Note that the DAQmx examples do not use the Wait Until Done function for continuous tasks. Start your task once.

 

For the case of multiple ao channels, I suspect you are selecting analog output channels on the same device. Unless that device supports multiple timing engines, you need to add all output channels on the same device to the same task.

 

But overall, start simple and build upon success. When you do get an error, turn on retain wire values and rerun your VI. Find out which error was thrown first and which VI returned that error. Help>>Explain Error... should give you details that will help in debugging.

Doug
NI Sound and Vibration
Message 5 of 14
(1,100 Views)

Hi,

 

Thank you for your answer here the error codes that I have obtained:

  • -200292:

EnavBSSvi_4Ch_ver2.vi<append>

<B>Property: </B>RelativeTo

<B>Requested Value: </B>Current Write Position

<B>Property: </B>Offset

<B>Requested Value: </B>0

<B>Task Name: </B>_unnamedTask<DD>

 

  • -200560

DAQmx Wait Until Done.vi:3580004<append>

<B>Task Name: </B>_unnamedTask<E1>

 

The first one It’s seen at the end the vi, he second it’s shown at the second loop.

0 Kudos
Message 6 of 14
(1,085 Views)

Hi.

 

Thank you for the answer. Here the vi in a previous version!

 

Best Regards,

Zuc

0 Kudos
Message 7 of 14
(1,079 Views)

I butchered your VI, but here is a revised version that runs two iterations with two channels. I switched the timing mode to Finite so that each iteration of the For Loop is essentially a separate run of the task. Remember, a task is a group of channel and timing configuration, so it doesn't make sense to delay a single channel in a task by inserting a delay. Hope this helps!

Doug
NI Sound and Vibration
Message 8 of 14
(1,057 Views)

Hi,

 

some of the problems are solved, for now the last one remained seems to be linked to the presence of the DAQmx Write.vi followed by the DAQmx Start Task.vi. From what I can tell, the default value of the Write.vi Auto start property is true so it’s an error to put the start task after it with that Boolean set to true. This fact can be related to the error -200479 “Specified operation cannot be performed while the task is running” which occurs at the start task vi. But I can’t figure out why this problem arises only at the second loop of the for loop.

Hereafter I attach the link of the NI paper which help me together with your help:

 

https://zone.ni.com/reference/en-XX/help/370469AP-01/daqmxprop/attr1826/

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P6VkSAK&l=it-IT

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000PA1PSAW&l=it-IT

 

A last question the DAQms Stop Taswk.vi must be included in the for loop for avoid problem with the task or a shift resister can be enough?

 

Thank you for the help!

 

Best Regards,

Zuc

0 Kudos
Message 9 of 14
(1,055 Views)

Hi,

 

I have observed your vi and it was helpful for some of my doubts bout the DAQmx. One thing is still bothering me, if a single task has inside itself different channels how I can select which signal goes on the corresponding channel? In my vi I need that each of the four channels generate 4 different audios at the same time.

Moreover, it's possible that with the waveform data passed in the for loop the sound is cut before its end after the first round?

 

Thank you very much for the help!

 

Best Regards,

 

Zuc

0 Kudos
Message 10 of 14
(1,043 Views)