SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.
Dependencies: TSI USBDevice mbed-dev
Fork of SmartWheels by
Diff: Hardwares/Motor.cpp
- Revision:
- 52:078b521c9edf
- Parent:
- 47:a682be9908b9
- Child:
- 87:15fcf7891bf9
--- a/Hardwares/Motor.cpp Thu Apr 06 18:37:16 2017 +0000 +++ b/Hardwares/Motor.cpp Thu Apr 06 18:57:54 2017 +0000 @@ -7,9 +7,8 @@ #include "PinAssignment.h" #include "GlobalVariable.h" -#define MOTOR_PERIOD 0.020 +#define MOTOR_PERIOD 0.020f -#define MAX_SPEED_LIMIT 0.2 #ifdef __cplusplus @@ -37,7 +36,7 @@ motor_set_left_direction(speed < 0 ? MDIR_Backward : MDIR_Forward); - motor_pwm_l.pulsewidth((speed < 0 ? -speed : speed) * MOTOR_PERIOD * MAX_SPEED_LIMIT); + motor_pwm_l.pulsewidth((speed < 0 ? -speed : speed) * MOTOR_PERIOD * MOTOR_MAX_SPEED_LIMIT); //char buf[20]; //sprintf(buf, "Motor %f", (float)motor_pwm_l); @@ -51,7 +50,7 @@ motor_set_right_direction(speed < 0 ? MDIR_Backward : MDIR_Forward); - motor_pwm_r.pulsewidth((speed < 0 ? -speed : speed) * MOTOR_PERIOD * MAX_SPEED_LIMIT); + motor_pwm_r.pulsewidth((speed < 0 ? -speed : speed) * MOTOR_PERIOD * MOTOR_MAX_SPEED_LIMIT); } void motor_set_left_direction(MotorDir dir)