From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

synchronize analog input with timer/counter

Solved!
Go to solution

Hi,

My Vi measures 4 current signals (4-20 mA) in one loop (use Create Channet, Timming Sample Clock, Start Task, Read Analog 1D Wfm Ncan Nsamp) 10 samples/loop with 100 sam/sec and one frequency in the second loop (Create Channet, Timming , Start Task, Read Counter 1D DBL 1Can NSamp ) 10 sam/loop. For Both I use continuous samples and data logging to disk.

Everything works perfectly, the readings, the waveforms, etc. The only problem is that I cannot synchronize in time the frequency graph with the other 4 analog waveforms. I need a software solution and not a frequency / current converter to measure all in the same loop.

Thank you

0 Kudos
Message 1 of 4
(3,100 Views)

 

I generally measure frequency with Implicit timing using the 1-Counter method.  The signal whose frequency is being measured acts as a variable-rate sample clock.

 

To sync up freq data with AI data, you'd need to do 2 things:

1. use the right kind of triggering to sync the start time of the task.  This might be as simple as configuring the AI task to use the freq signal as a start trigger.  (There are some issues with this if the freq signal is pulsing before your tasks start).

2. calculate cumulative time from your freq data.  SUM(1/f0 + 1/f1 + 1/f2...)

 

Depending on your specific data acq board there may be some further subtleties to deal with, but the basic idea is still the same.   What hardware are you using?

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 4
(3,072 Views)

Hi Kevin,

Thanks for your suggestions. I use a PCI6221, but I tried also a PCIe 6361. Please take into consideration that all readings are correct, perfect waveforms. Counter is programmed as Low Frequency with 1 Counter. I also use triggering from rotation to synchronize the analog acquisition. My problem is that the resulting datalogger files when I process them in Excel have different sizes (as samples produced in the same time). In other words, I can collect 100,000 analog values and 70000 speeds. Values are random, more values for analogue than frequency values are always obtained. It takes a very laborious processing in Excel to synchronize analogs and speed on the same graph.

Radu D

0 Kudos
Message 3 of 4
(3,045 Views)
Solution
Accepted by topic author eusini

Yep, 100% expected.  That's kinda the whole point of using implicit timing to measure frequency -- you latch ("sample") frequency measurements at the exact instant pulses occur.  Since the pulse source might have a variable frequency, your acquisition could have a variable sample rate.

 

Over in the post-processing world of Excel, you can visually sync things on a graph using an XY scatter plot.  The time column for AI is based on the constant AI sample rate while the time column for Freq comes from the cumulative sum 1/f0+1/f1+1/f2+...

 

In general, if you start the tasks in sync and stop them at about the same time, your 2 data streams will span the same time range.  It's just that the specific sample times will be different.   You can do some post processing in LabVIEW or Excel to "fill in" estimated Freq values at each AI sample time.  You could interpolate to make the frequency data smoother-looking but farther-from-true-measurement, or you could repeat the most recent true measurement to fill in the gaps.

 

As to subtleties, be aware that the M-series (62xx) and X-series (63xx) boards treat buffered Period measurement differently than one another so they might also treat Freq measurement differently.  Look into the manuals to see whether the 1st Freq measurement is buffered on the 1st or 2nd pulse edge.  For period measurement, M-series boards buffer the 1st sample on the 1st edge, X-series boards buffer the 1st sample on the 2nd edge.   You need to know this in order to properly sync to the AI task.  

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 4 of 4
(3,034 Views)