Showing results for 
Search instead for 
Did you mean: 

Algorithim on AC waveform



I need some math help.


I am measuring an AC waveform (see atached screenshot).  I need to detect "Events" i.e. a sinusoidal waveform with a different amplitude.  What math would I run to determine this.


test Count Events_FP.png


Any help would be appreciated.



Dan Shangraw, P.E.


0 Kudos
Message 1 of 12

I once had to do something sort of like this for a coding challenge.  I ended up using the RMS Point-To-Point function to perform a moving RMS measurement.  From the RMS measurement, you can detect when the change in amplitude happens.


Correction:  It was the AC & DC Estimator PtByPt VI

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 12

I was playing around with the RMS measurement point to point.  I was having trouble developing the algorithim for the amplitude change.  Any hints in that direction?


Thanks so much for your help

Dan Shangraw, P.E.


0 Kudos
Message 3 of 12

How about peak detection?  When you detect the peak has changed a substantial amount, you know the amplitude as stepped up.

0 Kudos
Message 4 of 12

Here is what I get when I do an RMS Point to Point.  I tried using Peak detection and no go.


Calculate Events_FP.png

Dan Shangraw, P.E.


0 Kudos
Message 5 of 12

Attach your VI's with the data saved as either a control with default data or a constant.


What do you mean that "peak detection no go".  What have you tried?


RMS is doing averaging.  The question then is how much of a window are you averaging?  You are seeing the effects of the change in amplitude in your graph where the RMS value is beginning to increase.  Since you are averaging over a larger window, the effect is taking some time to come into play.  If you look for the point where the slope of this graph is beginning to increase, that is where you peaks have changed.

0 Kudos
Message 6 of 12



Here are the VI's I am using.  The main one is test Count Events.


Any help would be appreciated

Dan Shangraw, P.E.


Download All
0 Kudos
Message 7 of 12

Try this. You can see in your output waveform that you have two stair steps. An easy way to detect those stair steps is with a derivative. As your slope changes from 0, you will notice a change in your derivative. I ran the Pt by Pt Derivative function on the output of the Pt by Pt RMS and was able to see two distinct spikes where your RMS is changing. You can run a threshold (just a simple >= function) or a Peak Detector to detect a change in RMS of that magnitiude. You can then run some other code based on whether this value is true or not. 


This isn't a perfect solution, but it should get your closer to your goal. You will probably need to run some additional filtering to get some really clean peaks. The Peak Detector can handle some of that for you.



Download All
0 Kudos
Message 8 of 12



I am playing around with a high pass filter.  I am getting some interesting results.  I will post if this solves my problem.



Dan Shangraw, P.E.


0 Kudos
Message 9 of 12

How much noise does your real signal have?


How many cycles (minimum) will occur at each level? How much does the frequency vary?



0 Kudos
Message 10 of 12