photodude / DualVNH5019MotorShieldMod3

Arduino library for the Pololu Dual VNH5019 Motor Driver Shield
http://www.pololu.com/product/2507
Other
5 stars 5 forks source link

mismatch for m4Brake and if evaluation #5

Closed sailhobie closed 5 years ago

sailhobie commented 5 years ago

Noticed a typo

The evaluation on the Timer5 pins for the M4brake function evals PWMpin3 instead of PWMpin4

`void DualVNH5019MotorShieldMod3::setM4Brake(int brake) { // Normalize brake if (brake < 0) { brake = -brake; }

if (brake > 400) // Max brake { brake = 400; }

digitalWrite(_INA4, LOW); digitalWrite(_INB4, LOW);

ifdef DUALVNH5019MOTORSHIELD_TIMER5_AVAILABLE

if (_PWM3 == _PWM3_TIMER5_PIN && _PWM3 == _PWM3_TIMER5_PIN)`
sailhobie commented 5 years ago

probably it is supposed to be

if (_PWM3 == _PWM3_TIMER5_PIN && _PWM4 == _PWM4_TIMER5_PIN)

for both M3 and M4 Braking, analogous to M1 and M2 braking

photodude commented 5 years ago

Yes, that is a copy-paste typo error. Yes, That line should be

if (_PWM3 == _PWM3_TIMER5_PIN && _PWM4 == _PWM4_TIMER5_PIN)`

it's actually checking that both PWM pins are on the same timer so the duty cycle of the PWM timer is set to the brake value before applying the brake function to the pin. (at least that's my understanding of how that part of the code from the parent Pololu library works)

photodude commented 5 years ago

@sailhobie Version 4.0.0 has been released with this fix. Note there was a Backward Compatability break between Version 3.0.2 and version 4.0.0 to fix the PWM pins. Details on the BC break change are in the release notes and this commit 227a49b

Closed via f7452231b2fbfcf5f2a04540660fc646a688feab