Consider the problem of servo control using PWM signals. Assume we have the following requirements or given conditions. • The repetition period of the PWM pulse for servo control is 20 ms. • The pulse width is between 1.0 to 2.0 ms, with 1.5 ms setting the servos to the center. • We need a resolution of no less than 1 us (micro second) for the pulse width change. • The timer used for the PWM generation has a 16-bit prescaler and a 16- bit counter. • The clock to the prescaler is 10 MHz. Determine the following (which may not be unique): 1. The range of PSC that satisfies the requirements for resolution and period of the pulses.
To determine the range of the prescaler (PSC) that satisfies the requirements for resolution and period of the pulses, we need to first calculate the timer clock frequency (f_timer).
The timer clock frequency is calculated as follows:
f_timer = f_prescaler / (PSC + 1)
where f_prescaler is the frequency of the clock to the prescaler, which is 10 MHz in this case.
To achieve a repetition period of 20 ms, the timer should count up to a value that corresponds to a period of 20 ms. This value can be calculated as follows:
timer_count = (repetition period / timer period) - 1
where repetition period is 20 ms and timer period is the period of the timer clock. The period of the timer clock is calculated as follows:
timer period = 1 / f_timer
To achieve a resolution of 1 us, the pulse width needs to be changed in steps of 1 us. Since the pulse width is between 1.0 to 2.0 ms, this means we need to be able to generate 1000 steps between 1.0 and 2.0 ms. Therefore, the step size can be calculated as follows:
step size = (2.0 ms - 1.0 ms) / 1000 = 1 us
Trending now
This is a popular solution!
Step by step
Solved in 2 steps