Proffie v2.2 or Teensy for Servo Motor Control

Servos are fairly easy to control IF you have a timer available.
Basically, you set up a PWM signal for 50 updates per second, and then PWM value tells the servo which way to turn. The tricky part is that a single timer can do several PWM outputs at the same time, but they must have the same overall frequency, or it won’t work.

On a Proffieboard V2, there are four timers. For reasons that are only known to ST-micro, they are called TIM1, TIM2, TIM15 and TIM16.

TIM2 is generally tied up with driving neopixels, ,and is generally set to 800kHz
TIM1, TIM15 and TIM16 are used to drive LED1-6 as follows:
TIM1 drives LED3, LED4 and LED6
TIM15 drives LED1 and LED5
TIM16 drives LED2

Since you want to drive two servos, we could repurpose TIM15 for this purpose, and we could use the LED1 and LED5 pads to run the servos. For each channel we would need a pullup resistor (100ohms maybe?) connected between 3.3v and the LED pad. Then we just need to configure TIM15 to run at 50Hz and set the PWM width to control the servo. We can still use the other LED pads for LED power control.

Now, things works a little bit different on a Proffieboard V3. It has tan extra timer, so I was able to allocate one timer specifically for stuff like this. It his hooked up to three pads on the side of the board called Free1, Free2 and Free3. These pads won’t need resistors to run a servo, and it won’t interfere with how anything else on the board works.

Controlling some servos from a teensy is also pretty simple, but then of course you have to worry about hooking up an amplifier and a motion chip to get smoothswing working.

2 Likes