
Library version for DC_Stepper_Controller_Lib with PWM speed control
Dependents: DR-ArmServoTest Auto_DC_pick_class MBed_TR1 ros_button_2021
Revision 20:a0d027b80d2c, committed 2021-08-16
- Comitter:
- howanglam3
- Date:
- Mon Aug 16 15:42:30 2021 +0000
- Parent:
- 16:3a1b95e2ecb8
- Commit message:
- library_version
Changed in this revision
sample_main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sample_main.cpp Mon Aug 16 15:42:30 2021 +0000 @@ -0,0 +1,44 @@ +/******************************************************* + DC MODOR CONTROLLER LIBRARY + ******************************************************* + IMPORTANT: GO TO README FOR DOCUMENT! +********************************************************/ + +#include "mbed.h" +#include "QEI.h" +#include "DC_Motor_Controller.h" + + +DC_Motor_PID motor(D6,D3,D4,D5,792); //M1, M2, INA, INB, PPR +DigitalIn but(D7); +// angle = 412 degree to move from one to another +// angle = 100 degree to + +DigitalOut led1(LED1); +DigitalOut led2(LED2); + +int main() { + Serial pc(USBTX, USBRX); // tx, rx + pc.baud(9600); + motor.set_pid(0.008, 0, 0, 0.10); + + but.mode(PullUp); + + while(1){ + + wait(0.5); + motor.set_out(0,0.4); + while(1) + { + pc.printf("%g \n", but); + if(but) { motor.set_out(0,0); pc.printf("\nend: %d \n", motor.get_pulse()); break;} + } + + wait(0.5); + motor.reset(); + wait(0.5); + motor.move_angle(-250); + wait(2); + } + +} \ No newline at end of file