Library version for DC_Stepper_Controller_Lib with PWM speed control
Dependents: DR-ArmServoTest Auto_DC_pick_class MBed_TR1 ros_button_2021
Diff: sample_main.cpp
- Revision:
- 13:675456f1f401
- Parent:
- 12:3949fd23be49
- Child:
- 14:c9611cf036ad
diff -r 3949fd23be49 -r 675456f1f401 sample_main.cpp --- a/sample_main.cpp Wed May 26 07:43:28 2021 +0000 +++ b/sample_main.cpp Thu May 27 05:43:48 2021 +0000 @@ -1,10 +1,7 @@ /******************************************************* DC MODOR CONTROLLER LIBRARY ******************************************************* - Important: - 1) Enable / Disable DEBUG_MODE in DC_Motor_controller.cpp - (DEBUG_MODE affects accuracy in control!!!) - 2) If compliation issue occurs, DELETE this file. + IMPORTANT: GO TO README FOR DOCUMENT! ********************************************************/ #include "mbed.h" @@ -12,7 +9,7 @@ #include "DC_Motor_Controller.h" -DC_Motor_Controller motor(D6,D3,D4,D5,792); //M1, M2, INA, INB, PPR +DC_Motor_PID motor(D6,D3,D4,D5,792); //M1, M2, INA, INB, PPR DigitalIn but(USER_BUTTON); // angle = 412 degree to move from one to another @@ -20,7 +17,7 @@ int main() { - motor.reset(); + motor.set_pid(0.008, 0, 0); Serial pc(USBTX, USBRX); // tx, rx pc.baud(9600); @@ -44,14 +41,14 @@ wait(5); */ wait(0.5); - motor.move_angle(412, 0.5); // speed, 0 to 1 + motor.move_angle(412); // speed, 0 to 1 wait(0.5); - motor.move_angle(412, 0.5); // speed, 0 to 1 + motor.move_angle(-412); // speed, 0 to 1 wait(0.5); - motor.move_angle(412, 0.5); // speed, 0 to 1 + motor.move_angle(412); // speed, 0 to 1 wait(0.5); - motor.move_angle(412, 0.5); // speed, 0 to 1 + motor.move_angle(412); // speed, 0 to 1 wait(0.5); - motor.move_angle(120, 0.5); // speed, 0 to 1 + motor.move_angle(120); // speed, 0 to 1 } \ No newline at end of file