LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I send one analog output from USB-6002?

Hello, I am now using LabVIEW 2013 and DAQmx9.9 with USB-6002.

I want to send analog voltage from AO0 and AO1 at the timing of trigger on PFI0

I have used DAQmx write (N channels, 1 sample)

because I want to send one voltage for each channel.

 

But the program just stops saying that buffer size should be set as 2 or larger.

Even if I use DAQmx write (N channels, N samples), it still does not work

showing the same error. It works if I give 2 or more samples.

 

I want to send out analog voltage at the timing of trigger coming on PFI0

with almost 5kHz rate, so I do not want to send out two same voltages

including one dumy data.

 

Thanks in advance for your kind advice.

 

 

0 Kudos
Message 1 of 9
(4,293 Views)

Hi, 

 

Have you tried having a look through the built in example finder in LabVIEW for something similar?

 

There are loads of examples online but is it something like this you're trying to achieve?

 

https://decibel.ni.com/content/docs/DOC-25374

0 Kudos
Message 2 of 9
(4,220 Views)

You failed to attach your code, so I cannot see what mistake you made, but from your comments, I'm guessing that you wired a single value to the DAQmx Write.  Note that if you set it up for N Channels, 1 Sample, that corresponds to a 1D array to hold the N samples.  If you want to send N Channels, N Samples, you need a 2D N by M array (I leave as an "exercise for the reader" to figure out if N is number of samples or number of channels ...).

 

Bob Schor

0 Kudos
Message 3 of 9
(4,208 Views)

Here I attach a code which I have used. (AO-single.vi)

I made this VI simplifying a VI example included in LabVIEW 2013.

 

Here is an error shown by this VI (in Japanese version).

So, I have translated meaning in the following.

The error message (error code-200077) says that SampQuant.SampPerChan

was set as 1 but it should be 2 or larger.

001-s.jpg

I guess that internal code of DAQmxTiming(Sampling Clock) requires

sample per channel to be 2 or larger. But this requirement conflicts

with usage of DAQmx Write (N channels, 1sample). 

0 Kudos
Message 4 of 9
(4,158 Views)

Hi yab,

 

I want to send out analog voltage at the timing of trigger coming on PFI0 with almost 5kHz rate, so I do not want to send out two same voltages including one dumy data.

What's the sense in defining a sample rate of 5kHz when you output just one (1) sample? You either output that sample or you don't - there is no reason to define a dt for outputting the next/2nd sample…

1) That beeing said: why don't you output 2 samples per channel? You might even output the very same value twice - it is a very simple solution I think.

2) What happens when you don't define a sample rate?

 

(What's the sense of using "N channel" mode at DAQmxWrite when your task only contains one (1) channel?)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 9
(4,150 Views)

Thank you for kind comments.

 

 

1)

It works if I send 2 samples per channel sending same voltage.

But in this case, it takes 1/5k*2=0.4[ms] for each operation.

I want to send different voltage at every 0.2[ms], so I cannot use this solution. 

 

2)

As you say, It might be nonsence to set frequency when I send out one analog output.

The result may not be dependent on the sampling frequency if it works.

If DAQmxWrite can run without using DAQmxTiming, it may solve the problem.

But VI shows an error if DAQmxWrite is used without DAQmxTiming.

The devise is now in use, so I will check the error code later.

0 Kudos
Message 6 of 9
(4,145 Views)

I think you need to either:

1) Remove the timing block altogether - you are configuring the timing to use hardware timing but if you only specify one point of data for each channel, it does not have any further points to 'time'

2) Set the timing configuration to 'implicit' - I believe this will have the same effect as the above but I might be wrong.

3) Make it a 2D array with N Channel M Samples for the DAQmx write

 


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 7 of 9
(4,135 Views)

Thank you for your advise.

 

1) If I remove DAQmxTiming, it shows the following error.

004.jpg

2) If I use implicit, an error comes out shown below. It may be because I have used DAQmxWrite with implicit setting for counter (not for analog output).

003.jpg

3) I have used N channels M samples sending 2D array, but the results (errors) are all same.

 

0 Kudos
Message 8 of 9
(4,117 Views)

Here is the error when I use DAQmxWrite without DAQmxTiming.

004.jpg

 

It seems that digital trigger requires to set sample clock (DAQmxTiming)

even though I do not know why there is such a requirement.

 

DAQmxTiming should set sample per channels to be 2 or larger

and this requirement sounds reasonable to make definition of timing (between samples).

 

Anyway, from above requirements, it is impossible to send 1 sample at each digital trigger.

0 Kudos
Message 9 of 9
(4,114 Views)