Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Comments on Measuring the peak voltage of a 1 kHz PWM/square wave using ESP32 ADC without peak detector

Post

Measuring the peak voltage of a 1 kHz PWM/square wave using ESP32 ADC without peak detector

+1
−1

I need to measure the positive peak of a 1 kHz PWM/square wave using an ESP32 ADC. The waveform has variable duty cycle; the minimum positive pulse width is about 100 µs.

After scaling, the ADC input positive levels are approximately 2.2 V, 1.65 V, 0.68 V, and 0.30 V.

I only need to classify these levels, not measure with high precision. Can I sample the ADC at 20–50 kHz and take the maximum value over several PWM cycles, or should I convert the waveform to DC using a peak detector/sample-hold before the ADC?

I want to avoid unnecessary analog peak-detection hardware if firmware-based sampling is reliable enough.

History

1 comment thread

Oscilloscope shot of your square wave (1 comment)
Oscilloscope shot of your square wave
Nick Alexeev‭ wrote 2 months ago

If you add an oscilloscope shot of your square wave, that would improve the question. How much noise and overshoot is there? If you don't have the hardware which generates the square wave, then we'll make do without the oscilloscope shot. We can imagine a 1 kHz 10% duty cycle square wave with a varying amplitude.