Truth TableTB6612FNG/babyo-328: different results

Compared to the Pololu Baby Orangutan B User’s Guide, pololu.com/docs/0J14, page 12, I realized the commands for driving the motor (look to drive side) clockwise or ccw (math-pos) and stopping different. Motor: 298:1 Micro Metal Gearmotor with Extended Motor Shaft, #2208.

MY Code:

// ============================================================================= = void M12_for ( u8 pwm ) // Motor 12 forward { OCR0A = pwm; OCR0B = 0; } // // ============================================================================= = void M12_rev ( u8 pwm ) // Mot 12 backward { OCR0A = 0; OCR0B = pwm; } // // ============================================================================= = void M12_stp ( void ) // Beide Kanäle low ==> Aktiv bremsen { OCR0B = 0; OCR0A = 0; } // channels low, break // ============================================================================= = void M12_brms ( void ) // Beide Kanäle high <=> Ausrollen, stop { OCR0B = 255; OCR0A = 255; } // channels high, coast // ============================================================================= =

You see my instuctions for running and stop the engine different (counter instructions) to the code in the users guide (page 12); similar to :

9. Motor Driver Truth Table (for TB6612FNG) // Motor12 (0A/0B) Motor 34 Motor- // PD5 PD6 PB3 PD3 M1A,M2A M1B,M2B effekt // T0B-OC0B T0A_OC0A T2A-OC2A T2B-OC2B // H H H H L L brake // L H H L L H forward // H L L H H L reverse // L L L L OFF (high impedance) coast

Do you have any idea why ? I think its the effekt of the gearbox, is this right?
Thank you in advance for any help :slight_smile:

Swap the motor wires to change the direction of rotation.

Setting the OCR (Output Compare Registers) is not the same as setting the output pin levels.

Setting the OCR registers instead controls the HIGH versus LOW time of the outputs in a way that depends on other bits in the various timer registers. See the ATMega328 data sheet for the details of the timer registers.

You need to consider all the timer register settings to predict the exact behavior, but you can rely on the truth table for the motor driver.