Ironcup Mar 2020
Dependencies: mbed mbed-rtos MotionSensor EthernetInterface
Diff: Motor/Motor.cpp
- Revision:
- 20:7138ab2f93f7
- Parent:
- 14:e8cd237c8639
- Child:
- 22:b7cca3089dfe
--- a/Motor/Motor.cpp Sun May 15 19:14:06 2016 +0000 +++ b/Motor/Motor.cpp Sat Jul 16 19:17:08 2016 +0000 @@ -3,12 +3,9 @@ #include "Motor.h" #define PI 3.141592653589793238462 -#define Ts 0.02 // Seconds -#define PWM_PERIOD 13.5 // ms -#define BRAKE_CONSTANT 40 -#define BRAKE_WAIT 2 -#define END_THRESH 4 -#define START_THRESH 10 +#define PWM_PERIOD 13.5 // ms +#define BRAKE_CONSTANT 100 // Brake force(max = 100) +#define BRAKE_WAIT 1.662 // seconds #define MINIMUM_VELOCITY 15 void Motor(){ @@ -39,11 +36,11 @@ alternate_motor = !alternate_motor; } -void Motor::brakeMotor(void){ +void Motor::brakeMotor(float brake_intensity, float brake_wait){ stopJogging(); if(velocity >= 0){ - setMotorPWM(-BRAKE_CONSTANT, motor); - wait(BRAKE_WAIT); + setMotorPWM(-brake_intensity, motor); + wait(brake_wait); velocity = 0; setMotorPWM(velocity,motor); } @@ -87,4 +84,7 @@ void Motor::setVelocity(int new_velocity){ setMotorPWM(new_velocity,motor); velocity = new_velocity; -} \ No newline at end of file +} +float Motor::getVelocity(){ + return velocity; + } \ No newline at end of file