-1
\$\begingroup\$

PWM Freq : 30 HZ and 5% Duty cycle, uC internal ADC sampling time is configurable. any limitations with ADC sampling time & Duty cycle of PWM should be considered for choosing RC ?

\$\endgroup\$
4
  • 4
    \$\begingroup\$ Your question is so short that an answer would need to be the size of a book to cover the bases. Please write (a lot) more about your situation. \$\endgroup\$ – jonk May 19 '20 at 4:16
  • \$\begingroup\$ Hi and welcome here. You must have some ideas regarding what you are trying to achieve. Unfortunately it did not come across very well in your posting. Please describe a lot more regarding your goals, what you have tried and a more exact definition of what your question actually is. \$\endgroup\$ – Michael Karas May 19 '20 at 5:33
  • 1
    \$\begingroup\$ "PWM Freq : 30 HZ and 5% Duty cycle" - if you know what the duty cycle is, why do you need to measure it? \$\endgroup\$ – Bruce Abbott May 19 '20 at 5:40
  • 1
    \$\begingroup\$ Wouldnt be easier to measure PWM directly with uC than converting signal to analog and then sampling it? \$\endgroup\$ – Rokta May 19 '20 at 5:45
3
\$\begingroup\$

A rule of thumb is to use a 10:1 ratio of PWM frequency to filter cutoff. This will reduce ripple so that you have a nice "flat" signal.

So for your values that would be an RC cutoff of 3Hz, which is pretty low and will result in long settling times whenever the duty cycle changes.

If your system allows it, I would recomend upping your PWM freq. to 1kHz or 10kHz, thus allowing you to use a much higher RC cutoff frequency and giving you a fast response time to any changes in duty cycle.

\$\endgroup\$
4
  • \$\begingroup\$ Great answer. A settling time of a few seconds might be totally fine depending on the application. \$\endgroup\$ – Drew May 19 '20 at 4:48
  • \$\begingroup\$ "thus allowing you to use a much smaller RC cutoff frequency" For a new PWM frequency of 1kHz, if the ratio is still 10:1, the new cutoff should then be 100 Hz, >> 3 Hz. A mistake perhaps? \$\endgroup\$ – SoreDakeNoKoto May 20 '20 at 1:00
  • \$\begingroup\$ @Aaron must have meant "much bigger RC cutoff" \$\endgroup\$ – Geo Dec 15 '20 at 20:25
  • 1
    \$\begingroup\$ @George You are right. I was thinking "smaller time constant". Updated. \$\endgroup\$ – Aaron Dec 15 '20 at 21:01
1
\$\begingroup\$

This sounds like an RC servo control signal (0.5 to 2 ms or so pulse width every 30 ms) not a true PWM signal.

Smoothing it adequately to read with an ADC with any accuracy is a losing game unless you can tolerate settling times of about a second per Aaron's answer.

Instead, use a timer peripheral on your MCU to measure the pulse width directly.

\$\endgroup\$
3
  • \$\begingroup\$ Aren't servos 20ms period? \$\endgroup\$ – Aaron May 19 '20 at 15:48
  • \$\begingroup\$ Usually yes, but I don't think the precise period matters to the servo, only the pulse width. Only the OP knows in this case. \$\endgroup\$ – user_1818839 May 19 '20 at 15:53
  • \$\begingroup\$ @BrianDrummond could you let me understand what the OP is trying to achieve with his method and how measuring the pulse width directly through a timer achieves the same result? Is the OP trying to calculate an average voltage level of the PWM signal by sampling the pulse when it's high? \$\endgroup\$ – Geo Dec 15 '20 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.