LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Inaccurate Analog Waveform

Solved!
Go to solution

Hello all,

I am trying to create analog square signals and transmit them via analog output in an NI-DAQ device (USB-6009/6008) (I need it to be analog since the amplitude will be a variable).
For the waveform generation I simply use the SquareWaveform.vi function and I take just what it produce and write it to the NI-DAQ port.

Then I connected the Analog Output (ao0) to an Analog Input (ai2) to measure it (I also measured via oscilloscope to ensure NI-DAQ is accurate enough, and it looks like it is accurate)

However it seems like the waveform isn't generated correctly. See below image, I set the frequency to be 1/6 [Hz], meaning the period is 6 seconds and with a 50% duty cycle each state (Low or High) should be 3 seconds. However as the image suggests, each state duration is 4.4 seconds. meaning the real frequency is 0.11363 (5/44) instead of 1/6. Any idea how do I fix that?

 

AM7723_0-1682603705814.png

 

Edit:
I added sampling info and sampling rate for both Write and Read functions of the NI-DAQ.
Anyone can help me understand what am I doing wrong?

AM7723_0-1682606459024.png

 

 

0 Kudos
Message 1 of 7
(1,272 Views)

You don't have the sampling info wired when creating the waveform. Are you sure it corresponds to the sampling rate of Analog input?

 

(It's difficult to tell things from a picture. Can you attach the VI instead?)

0 Kudos
Message 2 of 7
(1,262 Views)

Yes, I edited the first message and added the VI.
How can I sync the sampling info and the sampling rate of the analog input?

0 Kudos
Message 3 of 7
(1,256 Views)

Look at the help. Currently you are using the default:

 

altenbach_0-1682605358957.png

 

Sorry, I am more pure math and rarely use hardware. I am sure others will be able to help. What is the point spacing in the acquired data? (can't see it from the picture)

0 Kudos
Message 4 of 7
(1,252 Views)

You are not using Sample Clock Timing. Setting the sample clock rate is meaningless. Without the sample clock timing, you are using the computer clock to do software timing, which is inaccurate. 

You should include DAQmx Timing VI (Sample Clock) for both AI and AO. Refer to shipping examples Help >> Find Examples... >> Hardware Input and Output >> DAQmx >> Analog Output >> Voltage Output (Continuous).vi

-------------------------------------------------------
Control Lead | Intelline Inc
Message 5 of 7
(1,233 Views)

Thanks for the help,

It seems like it doesn't let me use Sample Clock:

 

Error -200077 occurred at DAQmx Timing (Sample Clock).vi:4730003

Possible reason(s):

Requested value is not a supported value for this property. The property value may be invalid because it conflicts with another property.

Property: SampTimingType
Requested Value: Sample Clock
Possible Values: On Demand

Task Name: _unnamedTask<1C>


 

AM7723_0-1682839203191.png

(I also uploaded the vi for reference)

0 Kudos
Message 6 of 7
(1,191 Views)
Solution
Accepted by AM7723

Hi AM,

 

you are using very old DAQ devices...

Without reading the manuals (what you should do!) I think those old 6008 does NOT support hardware-timed AO tasks, so you are stuck with software-timed output of sample by sample...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 7
(1,186 Views)