Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Can not set the sample rate of timing clock for internal clock of AO

I tried with the exaples from NI, under MeasurementStudioVS2005\DotNet\Examples\DAQmx\Analog Out\Generate Voltage\GenerateMultVoltUpdates_IntClk. It show similiar results. I kept Function Generator parameters unchanged, only change Timing Pararmeters->Signal Frequency (Hz), and output signal to ao0; for different Signal Frequency (1k, 10k, 100k), the time length of output AO signal is the same.
 
Please check it.
 
Thanks,
 
Chen.
0 Kudos
Message 11 of 18
(1,570 Views)
I tried with the example provided by NI too, which is under: DAQmx\Analog Out\Generate Voltage\GenerateMultVoltUpdates_IntClk. I get the similiar conclusions with my code.
I kept the Function Generator Parameters unchanged, only change the Timing Paramters->Signal Frequency (Hz) from 1k, 10k, 100k. The signal is output to ao0, and checked with a oscilloscope. For different Signal Frequency, the time length of the signal lasted is the same. This verified the results of my code.
 
Thanks,
 
 
Chen.
 
0 Kudos
Message 12 of 18
(1,569 Views)
(continued)
 
I tried with the example provided by NI too, which is under: DAQmx\Analog Out\Generate Voltage\GenerateMultVoltUpdates_IntClk. I get the similiar conclusions with my code.
I kept the Function Generator Parameters unchanged, only change the Timing Paramters->Signal Frequency (Hz) from 1k, 10k, 100k. The signal is output to ao0, and checked with a oscilloscope. For different Signal Frequency, the time length of the signal lasted is the same. This verified the results of my code.
 
Please check it.
 
Thanks,
 
 
Chen.
0 Kudos
Message 13 of 18
(1,569 Views)
Hey Chen,

I am using that exact example actually, but there is one thing you may be missing.  Setting the Signal Frequency to 1k, 10k, and 100k, is NOT setting the AO sample clock to 1k, 10k, or 100k.  It is setting the frequency of the sine wave that the Function generator outputs.  The Function Generator class determines the sample clock rate based on what you enter for the signal frequency.  So in the case of the this example, if I enter in 1k, 10k, and 100k, the actual sample clock rates are 50k, 500k, and 5M respectively if I leave the Samples per buffer set to 250.  I get an error on the last rate since the 6071E can't sample that fast.

This is all due to the fact that to output a sine wave at a certain frequency you must actually output at a higher rate to construct a sine wave as cleanly as needed.

Let me know i fyou have any further questions.

Regards,

Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 14 of 18
(1,565 Views)

Sorry, I am pretty confused by .Net AO write methods now. Why for 250 samples, actual sample clock rate 50k, 500k, they got the same actual time length? The BegineWriteMultiSample write a double[] data into channel, for axample 250 data point. Is that task.Timing.ConfigureSampleClock("",sampleRate, SampleClockActiveEdge.Rising, SampleQuantityMOde.FiniteSamples, data.Length) determine the speed of wrting samples? Because it is obvious no time increment information from double[] data.

If so, then for higher  sampleRate, it should result a shorter duration of signal. Am i right? Should be do any else settin for timing clock?

Thanks,

Chen.

0 Kudos
Message 15 of 18
(1,561 Views)
Hey Chen,

If I want to output a 1kHz sine wave, I need to setup a buffer of points that I can output at a high enough rate that it looks like a sine wave.  Nyquist theory tells us that this needs to be at least 2 times as fast, but if you go a little faster it can look even smoother.  The Function Generator class does a lot of math based on the input setting you provide.  For example if I specify 25 samples per buffer the output sample clock rate is set to 5kHz, whereas if I keep it set to 250 it sets the output sample clock rate to 50kHz.  So this is a point of confusion I can see people having with regard to that class. 

Aside from that class if you were to handle all of this yourself you would need a sample clock rate faster than 100Hz to output a sine wave at 100Hz.  You would need to set the sample clock to 200Hz or more.  I have tested this card here at my bench and have verified it functions in LabVIEW, MAX, and .NET as expected.  I think the main confusion was with the Function Generator class.

Let me know if you have further questions.

Regards,
Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 16 of 18
(1,556 Views)
In my code, I don't want ot use Function Generator class. I just want to send a curve with finite points, for example 250 points. Of course, I will set sampl rate higher than 250, such as 1000. I set by timing.ConfigureSampleClock. My question is that: no matter what sample rate I set, for example 1k, 10k, 100k, the output signal from ao0 is the same time length monitored by oscilloscope.
 
Thanks,
 
 
Chen.
0 Kudos
Message 17 of 18
(1,551 Views)
Hey Chen,

I have tested this driver in .NET with an external scope using the examples we already talked about.  As long as you follow the syntax in the examples I know it works, I have tested here.  There is either, something not quite right with your code, or you are not measuring the signal properly with your O'scope.  You should be able to verify this by setting up a square wave by simply outputting a 1 and 0, and output it, you should see the sample rate reflected in the output signal. 

Let me know if you have further questions.

Regards,
Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 18 of 18
(1,542 Views)