Braking torque calculation for motor