LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ waveform to binary

I have a data stream coming from an instrument. I am looking at a string of about 90 pulses, each 1 usec width. I am digitzing 2100 samples 2100/90 = 23 samples/pulse.

 

I need a binary representation of the analog waveform. I tried decimating the entire data stream but the instrument output has too much jitter that I have no control over. I attached a visual of what I am trying to do. I hope this makes sense. I'm scratching my head thinking I may need to go in an entirely different direction. We have time and hardware constraints to consider.

 

DAQ Decode problem.PNG

 

Thanks in advance.

 

 

PaulG.

LabVIEW versions 5.0 - 2023

“All programmers are optimists”
― Frederick P. Brooks Jr.
0 Kudos
Message 1 of 7
(3,933 Views)

What do you mean? I don't fully understand what you're trying to do, from what you've told us so far, you want to create an analog to digital converter? From what I can infer you would need to:

 

-Take said 23 samples and turn them into a binary representation (resolution depends on your needs) such as %11111111 (1024 decimal)

-Store said samples to reconstruct the signal. You mention 23 samples per pulse, i.e. 23 times the signal frequency, so sampling rate sounds great to me

 

So in a nutshell, you would have 90 binary numbers, one per pulse, from which you would reconstruct the signal (hopefully). Please attach VI for further advance.

0 Kudos
Message 2 of 7
(3,907 Views)

Not clear on either the final goal or the specific constraints.

 

What I see:  

  • bunch of analog data that appears to lend itself well to a boolean conversion via simple threshold
  • varying widths of both high and low times

 

What you described:

  • pulses are 1 usec width each.  Exactly?  Or approximately?  You mentioned "too much jitter..."

 

What I surmise:

  • 5 consecutive "pulses" of 1 usec will manifest as 5 usec of being in continuous "high" state

What I suggest:

  • I believe your first step should be to establish the time of each transition edge.  Also peek at your initial state, high or low.
  • Now you can loop over those time intervals and know how much time is spent in each boolean state, in order.  Divide each of those time intervals by your nominal 1 usec, then round to the nearest integer to help suppress jitter.  These results are the # of successive sample intervals in a particular state.  Use these to make your boolean output array
  • You'll need to fine-tune if this leaves you with the wrong total # of intervals due to an accumulation of rounding error
  • Benchmark the speed, you mentioned time constraints and this algorithm is not quite trivial to execute

 

-Kevin P

 

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 3 of 7
(3,899 Views)

It seemed like it might be fun to code up... so I did.  I didn't bother with optimizations, but this should execute fairly fast.A to D.png

Message 4 of 7
(3,891 Views)

 

Thanks for the followup!  Kudos granted, other comments not meant as criticism, just offered to help original poster.  Note: I'm on LV2013 and couldn't inspect the non-visible code in the snippet.

 

  • the initial boolean value fed to the shift register from outside is a constant named 'Last State'.  You should determine this initial value from the 1st element of the acquisition data rather than using a constant.
  • I myself would turn 'Sec / Pulse' into a front panel control while debugging the algorithm.  I'd also probably feed it into the code from outside the outermost loop.  Odds are, there's near duplicate code in one of the non-visible cases with another constant of the same value.  Wire in from outside the loop to be sure you can't get the values in the two cases out of sync

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 5 of 7
(3,881 Views)

I had a few ideas soon after I posted but got sidtracked Friday into something else.

 

I was a little confused because this seems like something that needs to be done often enough that we would have a more out-of-the-box primitive to this. So I did it myself. This is what I came up with. 

 

DAQ to bit stream.png

 

Later on down the pipe I use some decimation to convert 23 sample-wide pulses to 1 bit booleans. Little to no jitter to speak of. Works well. Data seems solid. Thanks for the ideas and suggestions.

PaulG.

LabVIEW versions 5.0 - 2023

“All programmers are optimists”
― Frederick P. Brooks Jr.
0 Kudos
Message 6 of 7
(3,823 Views)

Hi Paul,

 

why do you need so many loops? 😄

 

check.png

You can compare array with a comparison as they employ polymorphism.

You can search for elements in an array!

You can do the whole stuff on booleans instead of DBL values storing just 0 or 1…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 7
(3,817 Views)