Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to synchronize analog input and counter output on USB-6216?

Hi,

 

This setup is using a USB-6216 with vb.net using the most recent nidaqmx 9.40.

I'd like to synchronize a PWM waveform (say 30 Hz, 10% duty cycle) with the analog input on one channel (61440 ksamp/s on AI0).  Steps taken are :

 

--
aiTask.AIChannels.CreateVoltageChannel("Dev1/ai0", "", AITerminalConfiguration.Rse, -10, 10, AIVoltageUnits.Volts)

ctrTask.COChannels.CreatePulseChannelFrequency("Dev1/ctr0", "", COPulseFrequencyUnits.Hertz, COPulseIdleState.Low, 0, 30, 0.1)

aiTask.Timing.ConfigureSampleClock("", 61440, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples,61440)

ctrTask.Timing.ConfigureImplicit(SampleQuantityMode.ContinuousSamples, 1024)
--

 

However, I see a large drift on the waveform acquired - the square waveform is drifting later (on the right on a time domain graph) by approximately 100 samples per second.  Playing with the sampling rate will change the drift to higher or lower amount, but should I expect the waveform to be timed with the analog input?  Is there a way to synchronize the timebases for both of the tasks?

I've tried to look into the examples in the DotNet catalog, however, it seems the Multi-Function example is not supported by the USB-6216.

 

Thanks, JC

0 Kudos
Message 1 of 2
(3,591 Views)

JC,

 

In this situation, what I would do would be to generate your signals from the same clock would be to generate a 30 Hz continous pulse train on one counter and the generate a 61440 Hz continuous pulse train on the other counter with a 50% duty cycle.  I would then use the 61440 Hz pulse train as your sample clock for your AI.  This would ensure that they are on the same clock.  How ever you might see a little drift because 61440 Hz doesn't divide into 80 Mhz evenly, so the clock wont be exactly at 61440 while 30 does divide evenly.  Take a look at this discussion forum.  The fourth post down explains how to do this.

 

I hope that helps.

 

Brian P.

Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(3,585 Views)