Hi guys ! I want to detect peak of sine wave using built_in ADC of Atmega16. How can i achieve this? please cooperate..i m new in embedded world.
One of two ways:Hi guys ! I want to detect peak of sine wave using built_in ADC of Atmega16. How can i achieve this? please cooperate..i m new in embedded world.
You can sample at a slower rate if you make sure that your sampling rate is not some exact multiple or inverse multiple of the sine wave frequency, i.e. you want samples taken randomly at different phase points in the cycle.To do it in firmware:
1. Feed the signal into an A-to-D channel
2. Set some variable (or register or memory location) to zero. Call this variable "peak" for now.
3. Sample the value frequently and if the sampled value is greater than the value in "peak" replace the value in "peak" with the new sampled value.
4. Repeat
To be very useful you will need to also have a routine that is called regularly that decrements the value in "peak" by some number of counts or some fraction of the total so that if the peak input value gets lower with time the value in "peak" will track it.