mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
adafruitms1438: fix a bug in PWM handling for DC motors
Eric Hubert reported a bug in that no matter what setting he used to control the speed of a DC motor, it was always running at full speed. There was a bug in the setMotorSpeed() method that did not clear the 'FullOn' bit in the register used for PWM, causing full power to be applied all the time no matter the PWM duty cycle setting. This patch corrects that issue. Signed-off-by: Jon Trulson <jtrulson@ics.com> signed-off-by: Sisinty Sasmita Patra<sisinty.s.patra@intel.com>
This commit is contained in:
parent
fba8139416
commit
488ea234d5
@ -47,7 +47,7 @@ AdafruitMS1438::AdafruitMS1438(int bus, uint8_t address) :
|
||||
disableMotor(MOTOR_M2);
|
||||
disableMotor(MOTOR_M3);
|
||||
disableMotor(MOTOR_M4);
|
||||
|
||||
|
||||
// Set all 'on time' registers to 0
|
||||
m_pca9685->ledOnTime(PCA9685_ALL_LED, 0);
|
||||
|
||||
@ -152,6 +152,11 @@ void AdafruitMS1438::setMotorSpeed(DCMOTORS_T motor, int speed)
|
||||
|
||||
float percent = float(speed) / 100.0;
|
||||
|
||||
// make sure that the FullOn bit is turned off, or the speed setting
|
||||
// (PWM duty cycle) won't have any effect.
|
||||
m_pca9685->ledFullOn(m_dcMotors[motor].pwm, false);
|
||||
|
||||
// set the PWM duty cycle
|
||||
m_pca9685->ledOffTime(m_dcMotors[motor].pwm, int(4095.0 * percent));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user