WANG YUCHAO / Mbed 2 deprecated Motor_DRV8323RH_for_20190

Dependencies:   mbed FastPWM3

Files at this revision

API Documentation at this revision

Comitter:
benkatz
Date:
Sun May 22 03:47:40 2016 +0000
Parent:
12:c473a25f54f7
Child:
14:80ce59119d93
Commit message:
fixed some dumb things;

Changed in this revision

CurrentRegulator/CurrentRegulator.cpp Show annotated file Show diff for this revision Revisions of this file
PositionSensor/PositionSensor.cpp Show annotated file Show diff for this revision Revisions of this file
PositionSensor/PositionSensor.h Show annotated file Show diff for this revision Revisions of this file
--- a/CurrentRegulator/CurrentRegulator.cpp	Sun May 22 03:38:19 2016 +0000
+++ b/CurrentRegulator/CurrentRegulator.cpp	Sun May 22 03:47:40 2016 +0000
@@ -110,7 +110,7 @@
 void CurrentRegulator::Update(){
         float Q_Error = IQ_Ref - I_Q;
         float D_Error = ID_Ref - I_D;
-        float w_elec = _velocitySensor.GetElecVelocity();
+        float w_elec = _VelocitySensor->GetElecVelocity();
         
         Q_Integral += Q_Error*_Ki*_Kp;
         D_Integral += D_Error*_Ki*_Kp;
--- a/PositionSensor/PositionSensor.cpp	Sun May 22 03:38:19 2016 +0000
+++ b/PositionSensor/PositionSensor.cpp	Sun May 22 03:47:40 2016 +0000
@@ -139,9 +139,7 @@
     return elec;
 }
 
-float PositionSensorEncoder::GetElecVelocity(){
-    return _ppairs*GetMechVelocity();
-    }
+
     
 float PositionSensorEncoder::GetMechVelocity(){
     float out = 0;
@@ -157,18 +155,15 @@
         out = meas;
         }
     
-    /*
-    if(abs(vel) < 2.0f){
-        vel = 0;
-        }
-        */
     vel_old = meas;
-    
-    //out = .5f*out + .5f*out_old;
     out_old = out;
     return out;
     }
-
+    
+float PositionSensorEncoder::GetElecVelocity(){
+    return _ppairs*GetMechVelocity();
+    }
+    
 void PositionSensorEncoder::ZeroEncoderCount(void){
     if (ZSense->read() == 1 & flag == 0){
         if (ZSense->read() == 1){
--- a/PositionSensor/PositionSensor.h	Sun May 22 03:38:19 2016 +0000
+++ b/PositionSensor/PositionSensor.h	Sun May 22 03:47:40 2016 +0000
@@ -5,6 +5,7 @@
     virtual float GetMechPosition() {return 0.0f;}
     virtual float GetElecPosition() {return 0.0f;}
     virtual float GetMechVelocity() {return 0.0f;}
+    virtual float GetElecVelocity() {return 0.0f;}
 };