04-27-2023 09:06 AM - edited 04-27-2023 09:41 AM
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?
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?
Solved! Go to Solution.
04-27-2023 09:19 AM
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?)
04-27-2023 09:21 AM
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?
04-27-2023 09:23 AM - edited 04-27-2023 09:25 AM
Look at the help. Currently you are using the default:
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)
04-27-2023 10:11 AM
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
04-30-2023 02:21 AM
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 DemandTask Name: _unnamedTask<1C>
(I also uploaded the vi for reference)
04-30-2023 02:39 AM
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...