my new gear...

Dependencies:   mbed

Revision:
8:1ca5a2052b0c
Parent:
2:e7b09385d197
Child:
10:b64f586efb2d
diff -r 1c09bcc18c14 -r 1ca5a2052b0c actuator/IMC_motorDrive.cpp
--- a/actuator/IMC_motorDrive.cpp	Sat Apr 09 03:39:36 2022 +0000
+++ b/actuator/IMC_motorDrive.cpp	Fri Jun 10 08:09:09 2022 +0000
@@ -1,6 +1,6 @@
 #include<IMC_motorDrive.hpp>
 
-IMC_motor::IMC_motor(Port encoder,int resolution,double wheel_ensyu,Port motor_,double K_,double Tau_,double dt_):K(K_),Tau(Tau_),dt(dt_),motor(motor_){
+IMC_motor::IMC_motor(Port encoder,int resolution,double wheel_ensyu,Port motor_,double K_,double Tau_,double dt_,bool CW_flag):K(K_),Tau(Tau_),dt(dt_),motor(motor_),cw_flag(CW_flag){
     motor_enc.specinit(encoder.pin[0],encoder.pin[1],wheel_ensyu,resolution,4);
     IMCreset();
 }
@@ -16,6 +16,9 @@
 
 void IMC_motor::drive(int pwm){
     float output_pwm = constrain(pwm,-200,200)/255;
+    if(cw_flag){
+        pwm = -pwm;    
+    }
     if(!pwm) {
         DigitalOut Moter1(motor.pin[0],0);
         DigitalOut Moter2(motor.pin[1],0);