Motor current controller

Fork of CURRENT_CONTROL by LDSC_Robotics_TAs

Revision:
11:31cd02611cd0
Parent:
10:9f5f4a22346c
Child:
12:085f35babe21
--- a/CURRENT_CONTROL.cpp	Wed Dec 21 18:45:23 2016 +0000
+++ b/CURRENT_CONTROL.cpp	Thu Dec 22 19:22:59 2016 +0000
@@ -51,7 +51,7 @@
     MotorMinus(PwmChannel2),
     wheelSpeed(QEI_A, QEI_B, NC, pulsesPerRev, arraysize, samplingTime, QEI::X4_ENCODING), //(pin1, pin2, pin3, pulsesPerRev, arraysize, sampletime, pulses)
     pid(0.0,0.0,0.0,samplingTime),
-    lpFilter(samplingTime, 100.0) // 1.5915 Hz = 10 rad/s
+    lpFilter(samplingTime, 70.0) // 1.5915 Hz = 10 rad/s
 
     
 {
@@ -208,7 +208,7 @@
 
 // Control
 ///////////////////////////////////////////////////////////
-void CURRENT_CONTROL::Control(float curRef)
+void CURRENT_CONTROL::Control(float curRef, bool enable)
 {
     // Init check
     OffsetInit();
@@ -231,8 +231,11 @@
     // voltage_out = 0.0 + func_back_emf(angularSpeed); 
     
     // Output saturation and unit changing
-    SetVoltage(voltage_out);
     
+    if (enable)
+        SetVoltage(voltage_out);
+    else
+        SetVoltage(0.0);
     
     //--------------------------------//