Default mbed pwm doesn't have enough resolution at high frequencies, thats why I implemented VNH5019 Motor carrier with FastPWM.
Fork of VNH5019 by
VNH5019Accel.cpp
- Committer:
- mbedoguz
- Date:
- 2017-01-08
- Revision:
- 6:c8343fa0f3b4
- Parent:
- 5:b5f360a16354
File content as of revision 6:c8343fa0f3b4:
#include "VNH5019Accel.h" void VNH5019Accel::Interrupt() { float MyRequestedSpeed = RequestedSpeed; if (CurrentSpeed != MyRequestedSpeed) { if (std::abs(CurrentSpeed-MyRequestedSpeed) < VNH5019ChangePerTick) CurrentSpeed = MyRequestedSpeed; else if (MyRequestedSpeed > CurrentSpeed) CurrentSpeed += VNH5019ChangePerTick; else CurrentSpeed -= VNH5019ChangePerTick; Driver.speed(CurrentSpeed); } else { float MyRequestedBrake = RequestedBrake; if (CurrentBrake != MyRequestedBrake) { if (std::abs(CurrentBrake-MyRequestedBrake) < VNH5019BrakeChangePerTick) CurrentBrake = MyRequestedBrake; else if (MyRequestedBrake > CurrentBrake) CurrentBrake += VNH5019BrakeChangePerTick; else CurrentBrake -= VNH5019BrakeChangePerTick; Driver.brake(CurrentBrake); } } }