LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hardware-timed square wave analog output on USB-6002

Solved!
Go to solution

Hello,

 

Im trying to generate a hardware-timed analog square wave output on my USB-6002 DAQ-card.

Below Ive attached my first try. Im using the Square Waveform.vi, which is connected to an DAQ-assistant.

The analog output pin is connected to an analog input pin on my DAQ to validate the output. The sample number is set to 1k with dt=1ms, frequency=5Hz, amplitude=0V with an offset of 2V. One should see 5 squares of 0 to 5V with this setting. Nonetheless, the graph of the input just shows 2V over the whole 1s measured. Where is my mistake?

 

For now the specifications of the waveform do not matter to me. I just want to get any square wave output. In the final version I need a 1ms pulse length and 5 Hz repetition rate. According to the specs of the USB-6002, this should be possible, right?

 

Secondly, Ive read a topic, where its stated that the USB-6002 is all software-timed: https://forums.ni.com/t5/LabVIEW/Making-a-square-wave-analog-output-with-a-Daq-6008-is-it/td-p/20473...

This contradicts the specs http://www.ni.com/pdf/manuals/374371a.pdf and this page https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019QYGSA2&l=de-DE

Is the analog output of the USB-6002 hardware-timed or not? Im quite confused.

 

Thank you very much for every help!

0 Kudos
Message 1 of 5
(143 Views)

Hi Godeko,

 

Ive read a topic, where its stated that the USB-6002 is all software-timed

You referred to an old thread, written when the USB6000-6003 didn't exist (or just were presented).

The manual of the 6002 states:

Maximum update rate 5 kS/s simultaneous per channel, hardwaretimed

 

Where is my mistake?

You are using ExpressVIs.

You don't obey to THINK DATAFLOW!

 

Did you look at the example VIs coming with LabVIEW? There is a huge list of example on how to use DAQmx devices!

 

One should see 5 squares of 0 to 5V with this setting.

Nope. You should see all "2" values in the waveform!

Why don't you wire the generated signal to a waveform graph for visualization?

(Setting an amplitude of "0" will result in a signal with zero amplitude and just your offset value…)

Best regards,
GerdW
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

Message 2 of 5
(135 Views)

Hi Godeko,

 

the 0 V amplitude and the 2 V offset together are equivalent to a constant 2 V signal.

 

Set both the offset and the amplitude to 2.5 V, then you get +2.5 V + 2.5 V = 5 V and -2.5 V +2.5 V = 0 V for the high and low levels, exactly as you planned.

 

Best Regards,

NI TSE

0 Kudos
Message 3 of 5
(98 Views)

Thank you very much to both of you.

 

I have tried looking into an example vi, but it was way to overcomplicated. Also, I dont quit understand what you mean by dataflow.

 

Nonetheless, I have managed to get it working! I feel stupid for setting the amplitude to zero.

Connected to an oscilloscope, the pulse length of 1ms fluctuates. Most of the pulses show precisely 1ms, but some show a longer pulse lenght. This increase in the pulse length is dependent on the sample rate as I found out. At 1kS/s some pulses show 2ms pulse length and 1.2ms at the maximum value of 5kS/s. Is there a way to get rid of this fluctuation or is it a hardware-limitation?

 

Thanks again!

0 Kudos
Message 4 of 5
(89 Views)
Solution
Accepted by topic author Godeko

Hi Godeko,

 

This increase in the pulse length is dependent on the sample rate as I found out. At 1kS/s some pulses show 2ms pulse length and 1.2ms at the maximum value of 5kS/s.

At a samplerate of 1kS/s the delay between two samples is exactly 1ms, at 5kHz it's 0.2ms.

When the waveform generator creates those samples it (maybe) has to "round" the sample to the next time step…

 

Example1:

You want a pulse length of 1.1ms:

- at 1kHz most often you get pulses of 1ms, but sometimes a pulse of 2ms

- at 5kHz you get pulses of 1ms and 1.2ms

 

Example2:

You want a pulse length of 1.9ms:

- at 1kHz most often you get pulses of 2ms, but sometimes a pulse of 1ms

- at 5kHz you get pulses of 1.8ms and 2ms

 

Best regards,
GerdW
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

Message 5 of 5
(78 Views)