wannaBinventor
Member
I'm using a PIC16F1934 running at 32MHz. I'd like to maintain the current clock speed, but I need to get a 20ms period from the PWM to run a servo.
PWM period = (PRx +1) × 4 × Tosc × TMRx Prescale Value
PRx is the Timer Period Register
Tosc = 1/Fosc
TMRx Prescale Value maxes out at 1:64.
2.048ms = (255+1) × 4 × (1 / 32MHz) × 64
With the prescaler set to 1:64 and the period register loaded to 0xFF the max period I'm figuring is 2.048 milli seconds. If I'm correct in all of this, I will need a 2 Mhz clock speed just to achieve this.
It's my understanding that a standard servo needs one pulse of every 20 ms, so I was just going to vary the duty cycle on a 20ms period to achieve the 1ms-2ms pulse widths needed to position the servo.
I'm doing a good bit of calculation and displaying, so I'm pretty set on keeping my clock speed.
any suggestions for a work around?
PWM period = (PRx +1) × 4 × Tosc × TMRx Prescale Value
PRx is the Timer Period Register
Tosc = 1/Fosc
TMRx Prescale Value maxes out at 1:64.
2.048ms = (255+1) × 4 × (1 / 32MHz) × 64
With the prescaler set to 1:64 and the period register loaded to 0xFF the max period I'm figuring is 2.048 milli seconds. If I'm correct in all of this, I will need a 2 Mhz clock speed just to achieve this.
It's my understanding that a standard servo needs one pulse of every 20 ms, so I was just going to vary the duty cycle on a 20ms period to achieve the 1ms-2ms pulse widths needed to position the servo.
I'm doing a good bit of calculation and displaying, so I'm pretty set on keeping my clock speed.
any suggestions for a work around?