Using a Microcontroller to read peak values

Click For Summary
SUMMARY

The discussion focuses on using the analogRead feature of an Arduino microcontroller to accurately read the peak value of a sinusoidal signal. Users reported that the Arduino consistently returns the maximum value of 1023, even when a 1V peak signal is applied. Suggestions include testing the Analog-to-Digital Converter (ADC) with DC voltages to verify functionality and ensuring that the AC signal is properly biased within the 0-5V range. Proper biasing at 2.5V is recommended to avoid saturation of the ADC readings.

PREREQUISITES
  • Understanding of Arduino microcontroller functionality
  • Knowledge of Analog-to-Digital Conversion (ADC) principles
  • Familiarity with signal biasing techniques
  • Experience with Serial communication in Arduino programming
NEXT STEPS
  • Learn about Arduino ADC configuration and limitations
  • Research signal conditioning techniques for AC signals
  • Explore debugging methods for Arduino code
  • Study the implementation of peak detection algorithms in embedded systems
USEFUL FOR

Electronics hobbyists, embedded systems developers, and anyone working with Arduino microcontrollers who needs to accurately read and process analog signals.

sherrellbc
Messages
83
Reaction score
0
I need to use the analogRead feature of an Arduino microcontroller to read the peak value of a sinusoidal signal. I wrote a function that sampled the analog signal many times more than the frequency of the input signal and saves the highest read value.

The problem being, the Arduino always returns the highest resolution value of 1023. Even when a smaller signal(1Vpeak) is fed in, the arduino only returns 1023.

Any suggestions?
 
Engineering news on Phys.org
sherrellbc said:
I need to use the analogRead feature of an Arduino microcontroller to read the peak value of a sinusoidal signal. I wrote a function that sampled the analog signal many times more than the frequency of the input signal and saves the highest read value.

The problem being, the Arduino always returns the highest resolution value of 1023. Even when a smaller signal(1Vpeak) is fed in, the arduino only returns 1023.

Any suggestions?

I'd suggest you test the ADC out using DC voltages at first, to see how it behaves. You can just use the wiper of a potentiometer to feed different DC voltages into it and see what the ADC reads out...
 
berkeman said:
I'd suggest you test the ADC out using DC voltages at first, to see how it behaves. You can just use the wiper of a potentiometer to feed different DC voltages into it and see what the ADC reads out...

It reads DC perfectly. I did exactly what you suggested.
 
So then it sounds like a bug in the program that is reading the AC waveform. What kind of debugger resources does the Arduino offer?
 
Post your code, as well as how you are getting this number to begin with. Are you having it reported by Serial.println() to the Serial Monitor? Is this the output of your max function, or printed straight from analogRead() with no other processing?

Also, a basic drawing of how your ADC is hooked up. If you're just hooking up a straight AC source to the ADC input, that's not the best. The ATmega's inputs are meant for 0-5V range, so you'll need to bias the signal somewhere in that range. 2.5V, being the midpoint of the range, is usually the best.

What is the source of your signal? Have you verified its value with an independent measurement to make sure it's actually the value you want it to be?

If it's biased properly, then the next step would be to program your board to print analogRead directly to the Serial Monitor. If you're coming up with sensible data from that, then start combing through your max algorithm for bugs.
 

Similar threads

  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
7K
Replies
17
Views
3K
Replies
7
Views
9K
Replies
138
Views
26K
  • · Replies 4 ·
Replies
4
Views
761