LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fit a square wave to an analog signal

Hi,

 

I am looking to take an analog signal and fit a square wave onto it, as shown in the attached picture (I added the red line in Powerpoint, but this is what I would like to achieve programmatically).

 

This will allow me to condense some complex data down to just the key information of magnitude and duration for each square wave.

 

I have searched the forums and LabVIEW help but am really not sure how to approach this. Will it require a completely custom solution of can I make use of existing analysis tools? Any suggestions would be much appreciated.

 

Many thanks for your help,

Robin

 

 

0 Kudos
Message 1 of 6
(3,358 Views)

First you need to define an algorithm.
How do you determine the transition point?
How do you determine the high and low levels?

0 Kudos
Message 2 of 6
(3,345 Views)

Hi, thanks for the reply.

 

The transition point would be determined from looking at the slope - a very steep slope would indicate a rise or fall. Conversely, a low slope would indicate a flat section where it remains at the current value.

 

To prevent constant fluctuation, there would have to be some averaging in there.

 

The high and low levels can be any value (they're not locked to 1/0) and the level should be an average over the square.

 

In terms of an algorithm, it would look like this:

 

1) Detect a rising edge from a large slope.

2) Wait until a falling edge is detected from a dropping slope.

3) Average the values between the rise and fall to determine the level of the square.

 

Thank you for your help.

 

 

 

0 Kudos
Message 3 of 6
(3,339 Views)

What is a steep slope?
What is the average between rising and falling? When is the rising considered complete?
You can use the moving average.

0 Kudos
Message 4 of 6
(3,315 Views)

Analog - Digital.png

 

Can you not just use the Analog to Digital waveform converter? 

0 Kudos
Message 5 of 6
(3,304 Views)

Thanks for your suggestion - I think I may have been able to do this, but I'm not sure whether using a digital waveform would quite give the behavior required.

 

I've managed to achieve this now by averaging the signal values and then using the 'round to nearest' function. 

 

This creates the square waves as intended.

 

Thank you for all your help.

 

0 Kudos
Message 6 of 6
(3,290 Views)