Recording maximum and minimum values of a sine wave

This user program shows how to record the maximum and minimum values of each cycle of a sine wave.
SineMaxMin.rmcprog (3.24 KB)

Jacob,

I have used your SineMinMax program as the base of my own program and have had it work well for our linear axis applications. I use similar code to find the Maxes and Mins of the sine wave, but I have run into a problem when working with a rotary axis. I have the rotary axis set up for an 8000 count encoder with a position range of 0-359.9 degrees. When the position rolls over in the middle of a sine wave, the position maxes and mins are obviously effected. I’m pretty sure I can fix the problem with some logic to determine if it will roll over and some simple formulas, but I was wondering if there was an easier fix that you knew of. For instance when dealing with a rotary axis, in the move absolute command, you can choose absolute as the direction and it treats the position as if it was on a number line.

Any suggestions would be appreciated.

Thank You

Mike

Hi Jacob,

Is it possible to record phase lag of operating frequency?
If it could, I can obtain amplitude and phase information. Next, I can test my system at different frequency and plot the frequency response.

Allen

Yes, I have measured phase by using a zero-crossing time method, and I have a user program that records the frequency response over a continuous range of frequencies. I am not in the office right now, but will find it when I get in.

Attached is a user program that ramps the frequency from 0 to some value and continuously calculates the sinusoidal amplitude and phase during that time. This was made to test our filtering, so you will likely need to modify some things to make it work in different situations, but the basics for calculations phase are in there. Import the user program into your project. Make sure the variables from Sine_Cycles to Sine_Phase are all in one block in the Variable Table.
SineSweep.rmcprog (9.31 KB)

Great, I will try to implement this program to my platform and maybe use LabVIEW to show the result.

Thanks.