10-16-2006 05:38 AM
10-17-2006 03:44 AM
Hi there Bob,
Thanks for posting on the NI forums.
I have taken a quick look at your code and I think I can see part of the problem here. At the minute your AI and AO tasks are running on seperate clocks, but starting on the same trigger. What could be done is to use the AI clock to time both the AI and AO tasks. I will see what I can do about mod'ing your code slightly to add in this functionality.
I hope this helps,
Rob
10-17-2006 06:57 AM
Hi again Bob,
I have generated a snippet of example code based on your VI.
By sychronising the AI and AO operations to the same clock (the AI sample clock) we have a situation where for each new voltage generated (datapoint on your waveform) the AI takes a measurement. By forcing the task to be more precisely 'in-step' with one another, we can use a continuous AI task and choose to return chunks of data from the AI buffer that equate to exactly one cycle of your waveform (no repeated triggering needed!).
In order to ensure the tasks start off at the same time, we use the ai start trigger to start the AO task. This means the AI task will start, then the AO will begin generating the sine wave. We have a slight time delay here which results in a slight phase offset, but this offset is constant thoughout each acquisition insance.
I hope this helps!
Rob
10-19-2006 06:51 AM
10-19-2006 07:28 AM
Hi Rob,
Horray for the power of a windows reboot! It seems to be working well now. I'm using it as the basis for a software lock-in amplifier & so far I have only tested by plugging the output straight back into the input terminal. I'll have to see what happens when I actually start sending the signal through my devices and amplifiers!
Thanks for all your help!
Bob
10-19-2006 09:10 AM
Hi Bob,
You've gotta love it when a plan comes together!
I suspect when you pass the signal through your external circuitry you'll most likely get a larger phase difference, but if you need the displayed waveforms to be aligned, you could probably 'nudge' the phase of the graphed data by acquiring 1 sample more (or less) for one of the while loop's iterations. Not a particularly pretty solution, but the waveform's would 'look right'! 🙂
Let us know how you get on. I'll be glad to help again should you run into issues.
Cheers,
Rob