I usually still use the DAQmx Timing VI to configure sample clock parameters (you're using just a property node, this can be done but there are a few properties that you haven't set that are important--open up the DAQmx Timing VI to find out which ones).
In addition to what is inside the DAQmx Timing call, you should just need to add the single property to each task (replace "Dev2" with the appropriate device):
I made the change but I couldn't find Am I doing something wrong ?
"but there are a few properties that you haven't set that are important--open up the DAQmx Timing VI to find out which ones"
I don't understand which properties I missed. Please elaborate.
The inside of the DAQmx Timing VI looks like this:
You'll find that your earlier example is missing SampTimingType, SampQuant.SampPerChan, SampClk.ActiveEdge, SampClkSrc. I'm not 100% sure which of these are required (SampPerChanel almost certainly is, and I'd expect SampTimingType as well) but to avoid worrying about it I just usually use the timing VI to make things easier.
Apologies I left this out: to get PXIe_Clk100 to show up in the drop-down list you'll have to right-click the terminal and select I/O Name Filtering, then make sure "Include Advanced Terminals" is checked. I just made a rant in the idea exchange about this behavior if anybody is interested:
you are very detailed in your answers this is amazing, I won't be able to check till I go back in the lab day after tomorrow. In the mean time I would like to know which book do you follow ? do you have any suggestions ? I would try to see if this solution works on thursday.
I made the above changes and I am not getting the required result still. Can you tell me what am I doing wrong ?
The "Samples per Channel" input of DAQmx timing is unwired on both the AI and AO tasks. The default is 1000 samples.
On the AO Task (@ 2 MHz) the 1000 samples will only be 500 us (.0005 seconds). Since you're generating a 1V, 10 Hz sine wave, the voltage at .0005 seconds should be pi/100 (.0314...). The AI task (@ 250 kHz) would acquire 4 ms of data, but most of this is after the AO task has completed. The graph you have shown reflects this.
The other thing I notice is that the signal appears to be floating--do you have AI 2- (aka AI 10, pin 31 on the 6221) connected to AO GND from the 6361? Or you could alternatively try RSE mode on the input so the measurement will be taken relative to the ground of the 6221.
Now I am getting above data, it looks good but I have some following questions ?
1. Do you agree that I am not missing any data and the signal is fully synchronised ?
2. What is Dev1/PXIe_Clk100 and Dev2/PXI_Clk10 represents and what is their function ?
3. In your previous post "the voltage at .0005 seconds should be pi/100 (.0314...)." how did you calculate that ?
Keeping my answers short this time:
2. These are clocks on the PXI backplane--see here.
3. The link shows how I calculated it. V*sin(angle). Angle in radians is 2 * pi * current time * frequency. Although... I was assuming 1V for the amplitude, it looks like you're generating at 1.2V?
thanks for being fast I just noticed that I changed the rate at dev1 to 250ks/s and also that number of samples to 250k samples because i talked to someone at technichal support yesterday and they mentioned that it is impossible to achieve synchronisation when I am generating at 2Ms/s and reading at 250Ks/s.
Do you still agree that the signal is synchronised with output ?
I'd say they are still synchronized since the clocks will not drift relative to one another and they are starting at the same time. NI's own training and documentation (this article comes to mind) often refer to synchronization at different rates so I am surprised somebody from NI would make this claim. Sharing a sample clock is just one way to synchronize devices but it is by no means the only (or best) way.
However, you have asked a few times now if the tasks are indeed synchronized. Perhaps you have some other definition of synchronization or some other expectation of what behavior to expect? I'm assuming your end application isn't just to generate and measure back a sine wave so perhaps there is some other consideration I'm not aware of.
At the rates you are using (250 kHz AI, 2 MHz AO) you will acquire one sample for every 8 samples generated. The AI samples will always occur at the same time relative to the AO sample clock. This fits my definition of synchronization, but if you're asking about something different you'll have to be more specific.