Support » Application Note: Using the Motor Driver on the 3pi Robot and Orangutan Robot Controllers »
2. Motor Driver Truth Tables
input | Orangutan LV-168 output | TB6612FNG-based controllers | PD5, PD3 | PD6, PB3 | M1A, M2A | M1B, M2B | motor effect | M1A, M2A | M1B, M2B | motor effect |
---|---|---|---|---|---|---|---|
H | H | L | L | brake low |
L | L | brake low |
L | H | L | H | “forward”* |
L | H | “forward”* |
H | L | H | L | “reverse”* |
H | L | “reverse”* |
L | L | H | H | brake high |
OFF (high-impedance) | coast |
* Note that the concept of “forward” is arbitrary as simply flipping the motor leads results in rotation in the opposite direction.
We advise against using the fourth state in the above truth table (both motor inputs low). For the Orangutan LV-168, this state results in “brake high”, which is functionally equivalent to “brake low” but less safe (it’s easier to accidentally short power to ground while braking high). For the TB6612FNG-based controllers (i.e. the Orangutan SV-xx8, Baby Orangutan B, and 3pi robot), this state results in coasting; there is no danger involved in using this coast state, but alternating between drive and brake produces a more linear relationship between motor RPM and PWM duty cycle than does alternating between drive and coast.
Motor 1 is controlled by pins PD5 and PD6 (i.e. OC0B and OC0A), and motor 2 is controlled by PD3 and PB3 (i.e. OC2B and OC2A). These pins are connected to the ATmega48/168/328’s four eight-bit hardware PWM outputs (PD5=OC0B, PD6=OC0A, PD3=OC2B, and PB3=OC2A), which allows you to achieve variable motor speeds through hardware timers rather than software. This frees the CPU to perform other tasks while motor speed is automatically maintained by the AVR timer hardware.