Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Use a DAQmx write to increment a counter

I have a program that is writing output waveforms which go to some actuators, then some strain cards that are being read (essentially command-response). The issue we have is that we are always reading and logging, even when a test isn't running and nothing is being output to the actuators. This is done so data is still captured in the case where the parts may somehow go into resonance and break (yes this does happen). There are some weighted average calculations we need to do based on the number of waveforms that have been output and responses read, but we are trying to ensure the responses read line up with the correct sine wave output. My thought was if we could somehow use a buffered counter which was incremented every time a write was performed, then read every time a read was performed, we could ensure the data read is lined up with the correct count. 

 

Now, in general, the data that is output should align with the data that's read, and we could hold a counter in software. I just foresee a potential problem where for some reason the daq read loop gets a little behind and we do two writes before we do a read. Then our software counter would be +2 but the data we had actually read off the hardware buffer into software would be behind. This would throw off our calculation. 

 

I don't know if this makes sense, so feel free to ask clarifying questions.

0 Kudos
Message 1 of 3
(5,454 Views)

Hi Greg,

 

What card are you using?


@for(imstuck) wrote:

My thought was if we could somehow use a buffered counter which was incremented every time a write was performed, then read every time a read was performed, we could ensure the data read is lined up with the correct count. 


Does performing a "write" equate to starting a finite analog output task?  If so, you could count /<DevName>/ao/StartTrigger using a counter, and sample the count using /<DevName>/ai/SampleClock so you know which samples belong to which output waveform.

 

 

Best Regards,

John Passiak
0 Kudos
Message 2 of 3
(5,445 Views)

@John_P1 wrote:

Hi Greg,

 

What card are you using?


@for(imstuck) wrote:

My thought was if we could somehow use a buffered counter which was incremented every time a write was performed, then read every time a read was performed, we could ensure the data read is lined up with the correct count. 


Does performing a "write" equate to starting a finite analog output task?  If so, you could count /<DevName>/ao/StartTrigger using a counter, and sample the count using /<DevName>/ai/SampleClock so you know which samples belong to which output waveform.

 

 

Best Regards,


It's set up as continuous but no regeneration, we may be able to switch to finite. This may work I'll have to digest this option and play around with it some. Admittedly, I've somewhat checked out mentally for the weekend Smiley Very Happy. Strain cards are 4330 and I have to go look at the AO card but I do know they are not PXIe.

0 Kudos
Message 3 of 3
(5,440 Views)