Motor current controller

Fork of CURRENT_CONTROL by LDSC_Robotics_TAs

Revision:
9:d8157fbfcd2a
Parent:
8:fd6fb3cb12ec
Child:
11:31cd02611cd0
--- a/CURRENT_CONTROL.h	Mon Dec 19 15:27:13 2016 +0000
+++ b/CURRENT_CONTROL.h	Wed Dec 21 17:39:56 2016 +0000
@@ -26,6 +26,7 @@
     float Ts;    
     float cutOff_freq_Hz; // Hz
     float alpha_Ts;
+    float One_alpha_Ts;
     
     // Flag
     bool Flag_Init;
@@ -46,12 +47,13 @@
     CURRENT_CONTROL(PinName curChannel, PinName PwmChannel1, PinName PwmChannel2, PWMIndex pwmIndex, PinName QEI_A, PinName QEI_B, float pulsesPerRev, int arraysize, float samplingTime);
     
     //
-    void SetParams(float Analog2Cur, float angSpeed2BackEmf, float voltage2DutyRatio);
+    void SetParams(float Analog2Cur_in, float angSpeed2BackEmf, float voltage2Duty_in);
+    void SetReversal(bool reverse_current_in, bool reverse_rotationalSpeed_in, bool reverse_voltage_in);
     void SetGain(float Kp, float Ki, float Kd, float Ka);
     //
     void OffsetInit(void);
     float saturation(float input_value, float &delta, const float &limit_H, const float &limit_L);
-    void Control(float curRef, float speed);
+    void Control(float curRef);
         
     // Back emf as the function of rotational speed
     float func_back_emf(const float &W_in);
@@ -59,6 +61,7 @@
     //functions for test////////
     void ChangePwmPeriod(float microSeconds);
     void SetPWMDuty(float ratio);
+    void SetVoltage(float volt);
     float GetAnalogIn(void);
     float GetCurrent(void);
     
@@ -106,9 +109,11 @@
     float getAngularSpeed_deg_s(void); 
 
 private:
-
+    
     float Ts;
-    
+    bool reverse_current;
+    bool reverse_rotationalSpeed;
+    bool reverse_voltage;
 
 };