Using a Microcontroller to read peak values

AI Thread Summary
The discussion focuses on using an Arduino microcontroller to read the peak value of a sinusoidal signal via the analogRead feature. The user encounters an issue where the Arduino consistently returns the maximum value of 1023, even with a 1V peak input. Suggestions include testing the analog-to-digital converter (ADC) with DC voltages to verify functionality and ensuring proper biasing of the AC signal within the 0-5V range. It is recommended to print the raw analogRead values directly to the Serial Monitor for debugging, and to check the signal source for accuracy. Proper signal conditioning and debugging steps are essential for resolving the issue.
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.
 
Hi all I have some confusion about piezoelectrical sensors combination. If i have three acoustic piezoelectrical sensors (with same receive sensitivity in dB ref V/1uPa) placed at specific distance, these sensors receive acoustic signal from a sound source placed at far field distance (Plane Wave) and from broadside. I receive output of these sensors through individual preamplifiers, add them through hardware like summer circuit adder or in software after digitization and in this way got an...
While I was rolling out a shielded cable, a though came to my mind - what happens to the current flow in the cable if there came a short between the wire and the shield in both ends of the cable? For simplicity, lets assume a 1-wire copper wire wrapped in an aluminum shield. The wire and the shield has the same cross section area. There are insulating material between them, and in both ends there is a short between them. My first thought, the total resistance of the cable would be reduced...
I am not an electrical engineering student, but a lowly apprentice electrician. I learn both on the job and also take classes for my apprenticeship. I recently wired my first transformer and I understand that the neutral and ground are bonded together in the transformer or in the service. What I don't understand is, if the neutral is a current carrying conductor, which is then bonded to the ground conductor, why does current only flow back to its source and not on the ground path...
Back
Top