LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading analog output channel (or effector) synchronously with analog input channels into arrays in parallel loops

Hi Nathan,

 

What i'd like to have is continuous, uninterrupted acquisition of 6 analog input channels, while outputting an asymmetic (varied duty cycle) square wave over the analog output voltage. But to properly reduce the acquired data, i need to know precisely what the output voltage was when the input voltages were acquired (preferable to 1 ms or better synchonisity).

 

thanks... I'm reading through the overview link.

0 Kudos
Message 31 of 36
(1,646 Views)

Hello zipmanx,

 

If you need 1ms timing, you are going to need to sync up the analog input and analog output sample clocks. This can be done in a couple ways. One way is to keep them on separate clocks, and use a trigger to allow them to start at the same time. You can find an example of how to do this in the Example Finder and open Hardware Input and Output>DAQmx>Synchronization>Multi-Function>Multi-Function-Synch AI-AO.vi. This VI syncs up the analog inputs with the analog outputs by setting the base clock frequency to be the same and starting them at the same time. If you use this method, you can monitor what you are writing to the analog output, and what you are reading, and they will always be happening at the exact same time. 

 

Another method would be to share the analog input timebase with the analog output. Go to example finder and open Hardware Input and Output>DAQmx>Synchronization>Multi-Function>Multi-Function-Synch AI-Read Dig Chan.vi. This VI syncs up the analog input with the digital input by allowing the digital input to share the analog input's clock. You can just switch the digital input task for the analog output task. Again, this just guarantees that the analog input and output are synchronized exactly. From there, you can monitor the signals in software, and for any specific time-stamp, the output signal should correspond to the input signal at the same time-stamp. I hope this gets you started. Let me know if you have any other questions.

 

-Nathan H 

Software Developer
National Instruments
0 Kudos
Message 32 of 36
(1,632 Views)

Hi Nathan,

 

Thanks for your reply; i will look over those examples you've quoted. From the other examples i've looked at, i've been putting something together from 2 specific examples and i'm wondering what my flaws are.

 

LVexampleMerge.jpg

 

I think that one can clearly not use the waveform wire that defined the output voltage to be synchronised with the analog input voltage data, but it seems that you could include the internal channel (analog output) as one of the inputs being read by the analog in VI provided that task start and stops after the start of the AO voltage out and the before the end of the AO voltage out.

 

LV-read-internal.jpg

 

Is this approach correct?

 

thanks again.

0 Kudos
Message 33 of 36
(1,629 Views)

Hello zipmanx,

 

Reading from the ao0_vs_aognd line will definitely work for reading the output signal. However, I'm unsure if the timing will be exactly synced up. You are correct in that you cannot use the waveform wire that defined the output voltage to be synchronized in this case. However, if your output is setup like the "Cont Gen Voltage Wfm-Int Clk-Non Regeneration.vi", where the output waveform is inside the while loop, then you can use this wire to to read in monitor your output in sync with the input.

 

The method of using the internal routes should work fine, but you may want to run some timing tests by running two square waves that should be exactly in sync and making sure they actually do rise and fall at the same time interval.

 

Good luck with setting this up!

 

-Nathan H

Software Developer
National Instruments
0 Kudos
Message 34 of 36
(1,619 Views)

Hi Nathan,

 

what i've tried is a continuous square wave output through the DAQ AO channel, but I've found that for some combinations of number for the square wave, i.e. period of 65ms: 15 + 50, it gets trunkated when wrapped.

Squarewave.png

SqrWvout.jpg

 

I've tried varying the sample size, and the output sample rate. Varying the sample size moves the discontinuity around temporaly, but it's not obvious why. Restricting it to onboard memory doesn't change the behaviour either.

 

I have tried triggering for this application, where the continuous data acquisition would start at the same time as the square wave output, but i was not able to get this to work. The combinations i've tried produce similar errors

Error -200265 occurred at DAQmx Control Task.vi:2

Possible reason(s):

An attempt has been made to use an invalid analog trigger source.

Ensure that the trigger source you specify matches the name of the virtual channel in the task or matches the name of a non-scannable terminal that the device can use as an analog trigger source.

Property: Start.AnlgEdge.Src
Corresponding Value: /PXI1Slot4/ao/StartTrigger

Valid Choices: PXI1Slot4/ai0, APFI0

Task Name: _unnamedTask<E2A1E>

 

triggering.jpg

0 Kudos
Message 35 of 36
(1,594 Views)

Nevermind the square wave buffer size / trunkation mismatch! It was a simple fix that was staring me in the face. I wired the period total to the sample size...

0 Kudos
Message 36 of 36
(1,589 Views)