nRF Connect SDK Intermediate course - Lesson 4, Exercise 1 PWM terminology

In this exercise the PWM terminology is used incorrectly, confusing the pwm pulse width (nsecs) and duty cycle (percentage).  I know the difference from 40+ years of designing PWM circuits and firmware, but your lesson will confuse people that are new to PWM.

In step 2 the text says "Define the PWM period and pulse, as the macros PWM_PERIOD_NS and PWM_PULSE_NS", but the code snippet shows a macro for duty cycle with a value that is clearly nsecs and not a percentage:

#define PWM_PERIOD_NS 20000000
#define PWM_DUTY_CYCLE 1400000

The text on the rest of the page continues to correctly refer to the second setting as the pulse width, but two more code snippets show the incorrectly named PWM_DUTY_CYCLE macro, including passing it to the pwm_set_dt() function that takes a pulse width, not duty cycle.

I checked the solution in GitHub, and that code also has the incorrectly named PWM_DUTY_CYCLE macro in two places, matching the lesson code snippets.

Parents
  • In Exercise 2 the problem is even worse, with the term duty cycle (which is a ratio or percentage) used instead of the pulse width (time, e.g.- msecs) throughout the exercise.  The servo motor data sheet also incorrectly shows "duty cycle" on the timing diagram but with units of msecs.  This is less surprising since it may have been translated from Chinese or something.  But every control systems reference I've ever seen makes it clear that duty cycle is the ratio of the pulse width to the period, usually expressed as a percentage:

    en.wikipedia.org/.../Duty_cycle

Reply
  • In Exercise 2 the problem is even worse, with the term duty cycle (which is a ratio or percentage) used instead of the pulse width (time, e.g.- msecs) throughout the exercise.  The servo motor data sheet also incorrectly shows "duty cycle" on the timing diagram but with units of msecs.  This is less surprising since it may have been translated from Chinese or something.  But every control systems reference I've ever seen makes it clear that duty cycle is the ratio of the pulse width to the period, usually expressed as a percentage:

    en.wikipedia.org/.../Duty_cycle

Children
No Data
Related