LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronization of analog input and analog output module

Hi there,

 

I am trying to sync the NI 9264 & NI 9205 analog Output and analog input Modules respectively.

But while reading i am getting phase shift incrementing if the frequency of generation is changed.

for example for 1k-hz = 14 degree of phase shift while reading and 2KHz = 28 degree of phase shift.

 

Not able to solve it. Can anybody tell me what's happening?

 

Your reply can be helpful.

Thanks,

Ransher.

 

image (1).png

0 Kudos
Message 1 of 4
(447 Views)

Hi Ransher,

 

right now you try to sync both tasks by setting a common start time for both.

Usually it is recommended to use the "ao/StartTrigger" as start trigger of the AI task so the AI task starts at the same moment as the AO task starts to output samples. Can you try this with your hardware?

 

Btw. you don't need a timed while loop just to read samples! Use a simple while loop with no other wait as the DAQmxRead will provide the timing of the loop…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(429 Views)

Hi  GerdW & Thomas,

 

Thanks for replying.

 

I tryed both the method of triggering Start Timer Trigger &  ao/start Trigger but still its not helping me out.

However, i observed its reading 1 sample behind the actual generation which is causing phase shift if i remove 1 sample in beginning it shows perfect sync of phase shift but the total no. samples are reduced to n-1 which is anyhow not accurate.

Even if you are using trigger method as suggested still its giving same result.

Capture.PNG

 

Another case, i used 2 channels for generation and 2 for acquisition , what i found first waveform is not synced but the other is synced. However, i tried interchanging the analog input wire but same result came.

 

I tryed changing the channels but outcome was same.

 

Why the sync is happening correctly for second waveform when more than 1 channel are used in parallel for generation & acquisition?

 

Is there any way to sync the single waveform or first waveform without removing first sample?

 

Thanks,

Ransher.

0 Kudos
Message 3 of 4
(405 Views)

I don't know details about your specific cDAQ hardware, so here is some fairly generic advice about things I'd be trying.

 

1. I haven't explored the ability to do Time-based triggering with certain cDAQ chassis, thus I don't know if I can trust it.  So try taking that part out.

 

2. I've long been an advocate of sync'ing via shared sample clock when possible rather than via trigger.  Your front panel *appears* to show you trying to do that, I just don't recognize what the "ot1" might be in the terminal name.  I'd expect to see something like "ao" there.  Whatever the naming syntax needs to be, aim to tell the AI task to use the AO task's sample clock, and then make sure the AI task is started *before* you start AO.  Just put the call to DAQmx Start for AI *before* your sequence structure that contains DAQmx Start for AO.

 

3. The next experiment might be to try out different polarities for the sample clock configuration.  The sample clock signal will probably be a brief pulse.  You'll want the AO to generate on the leading edge and the AI to acquire on the trailing edge.

 

4. If the pulse duration is too short or too long for this to work out nicely, you may just need to accept and work around the off-by-1-sample issue.  What may be going on is that AI and AO are trying to respond to the same clock edge.  It may take AO a tiny fraction of a second to "build up to" the next voltage value (see the spec for "slew rate").  But AI may sample immediately and catch AO in its previous state rather than the one it'll be in a microsecond or so later.   This kind of thing manifests as an off-by-1-sample.

    Once you can prove to yourself that AI is always sampling the past state of AO, you can just accept that fact and shift your data by 1 sample to line it back up in time.

 

5. There are other techniques that use a counter pulse train to generate a clock with a controllable delay from leading to trailing edge which both AO and AI use as their sample clock.  AO updates on the leading edge, AI acquires on the delayed trailing edge after AO (and perhaps the system as a whole) has had time to respond and settle.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy coming to an end (finally!). Permanent license pricing remains WIP. Tread carefully.
0 Kudos
Message 4 of 4
(382 Views)