Hi, I'm doing a DSP application on quite limited microcontroller hardware, and need a fast crude process to find a sinewave peak value based on two points on the sinewave which are guaranteed to be 90 degrees apart.
The two points are already full-wave rectified, so there are no negative values. Both values are already in the range 0-127 (7bit binary).
Normally this is found as the "square root of the sum of the two squares", which obviously works fine but I need to do this fast with no squares or roots, hopefully just with some additions/subtractions, and binary mult/divide (left/right shifts on a micro).
I also prefer not to use a lookup table. The good news is that the final accuracy only needs to be +/- 3%.
As an example I am currently using this calc;
peak = biggest - dif/4
(dif = biggest-smallest, where biggest and smallest are the two values), and it gets pretty close;
This gives a result within about 8% of the real RMS value, so it's almost accurate enough but leaves me with a problem of turning the RMS result into a peak result (ie *1.41).
If anyone has a fast simple way of getting a peak value within +/-3% or so it would be much appreciated!
The two points are already full-wave rectified, so there are no negative values. Both values are already in the range 0-127 (7bit binary).
Normally this is found as the "square root of the sum of the two squares", which obviously works fine but I need to do this fast with no squares or roots, hopefully just with some additions/subtractions, and binary mult/divide (left/right shifts on a micro).
I also prefer not to use a lookup table. The good news is that the final accuracy only needs to be +/- 3%.
As an example I am currently using this calc;
peak = biggest - dif/4
(dif = biggest-smallest, where biggest and smallest are the two values), and it gets pretty close;
Rich (BB code):
Big Small RMS Mine
0 100 71 75
36 90 71 76
71 71 71 71
If anyone has a fast simple way of getting a peak value within +/-3% or so it would be much appreciated!