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

Post History

60%
+1 −0
Q&A Measuring the peak voltage of a 1 kHz PWM/square wave using ESP32 ADC without peak detector

Doing peak-detection in firmware is a valid method. I have done similar things. At the bare minimum, you want at least one sample guaranteed within the 100 µs pulse width. That means 100 µs samp...

posted 2mo ago by Olin Lathrop‭  ·  edited 2mo ago by Olin Lathrop‭

Answer
#2: Post edited by user avatar Olin Lathrop‭ · 2026-07-08T22:29:49Z (2 months ago)
  • Doing peak-detection in firmware is a valid method. I have done similar things.
  • At the bare minimum, you want at least one sample guaranteed within the 100 &micro;s pulse width. That means 100 &micro;s conversion period, which is 10 kHz conversion rate.
  • However, you also have to take the acquisition time before each conversion into account. The signal is not point-sampled, but acquired over a finite interval. The overall sample rate needs to be fast enough so that there is always at least one whole acquisition interval in every 100 &micro;s.
  • For example, let's say the sample period is 10 &micro;s. That would require a sample period of 90 &micro;s absolute maximum, which is a sample rate of 11.1 kHz.
  • In reality, I'd want two whole guaranteed samples over the minimum 100 &micro;s period. That way at least one of them isn't near an edge. Using the 10 &micro;s acquisition time example again, that leaves 45 &micro;s for each sample, for a sample rate of 22 kHz. Fortunately, that seems to be well within the capability of your A/D, so the digital peak detection method should work fine given what you have told us.
  • Doing peak-detection in firmware is a valid method. I have done similar things.
  • At the bare minimum, you want at least one sample guaranteed within the 100 &micro;s pulse width. That means 100 &micro;s sample period, which is 10 kHz sample rate.
  • However, you also have to take the acquisition time before each conversion into account. The signal is not point-sampled, but acquired over a finite interval. The overall sample rate needs to be fast enough so that there is always at least one whole acquisition interval in every 100 &micro;s.
  • For example, let's say the acquisition time is 10 &micro;s. That would require a sample period of 90 &micro;s absolute maximum, which is a sample rate of 11.1 kHz.
  • In reality, I'd want two whole guaranteed samples over the minimum 100 &micro;s period. That way at least one of them isn't near an edge. Using the 10 &micro;s acquisition time example again, that leaves 45 &micro;s for each sample, for a sample rate of 22 kHz. Fortunately, that seems to be well within the capability of your A/D, so the digital peak detection method should work fine given what you have told us.
#1: Initial revision by user avatar Olin Lathrop‭ · 2026-07-08T22:26:08Z (2 months ago)
Doing peak-detection in firmware is a valid method.  I have done similar things.

At the bare minimum, you want at least one sample guaranteed within the 100 &micro;s pulse width.  That means 100 &micro;s conversion period, which is 10 kHz conversion rate.

However, you also have to take the acquisition time before each conversion into account.  The signal is not point-sampled, but acquired over a finite interval.  The overall sample rate needs to be fast enough so that there is always at least one whole acquisition interval in every 100 &micro;s.

For example, let's say the sample period is 10 &micro;s.  That would require a sample period of 90 &micro;s absolute maximum, which is a sample rate of 11.1 kHz.

In reality, I'd want two whole guaranteed samples over the minimum 100 &micro;s period.  That way at least one of them isn't near an edge.  Using the 10 &micro;s acquisition time example again, that leaves 45 &micro;s for each sample, for a sample rate of 22 kHz.  Fortunately, that seems to be well within the capability of your A/D, so the digital peak detection method should work fine given what you have told us.