# Motor Control

# M0 Pro Considerations

M0 Pro specification

# PWM

Pins 2 - 13 can be used for PWM with the analogWrite() function with the exceptions that pairs 4 & 10 and 5 & 12 cannot be used together.

# Interrupts

Interrupts are available on all pins except pin 4.

# Motor Encoders

From the product page:

Encoders use custom made 8-pole magnets and 2 hall-effect sensors to provide 2 square waves, 90 degree out of phase with a total of 16 state changes per motor revolution.

There is then a 75:1 gear ratio meaning that one revolution results in 1200 state changes.

This was checked using a logic analyser and PulseView. At the time a 34:1 gearbox was on the motor which should result in 544 edges per rotation. The wheel was rotated 10 times and the rising/falling edges counted. The count total was 5466 which is 546.6 per revolution, very close to the calculated amount (wheel cannot accurately be stopped at start position).

Logic analyser response over 10 wheel rotations