Motor current controller

Fork of CURRENT_CONTROL by LDSC_Robotics_TAs

Revision:
2:562bd14dfd3a
Parent:
1:c5973a56d474
Child:
3:c787d1c5ad6a
--- a/CURRENT_CONTROL.cpp	Fri Apr 22 14:32:01 2016 +0000
+++ b/CURRENT_CONTROL.cpp	Fri Apr 22 15:21:31 2016 +0000
@@ -25,7 +25,8 @@
 
 void CURRENT_CONTROL::Control(float curRef)
 {
-    curFeedBack = (currentAnalogIn.read() - currentOffset)*analog2Cur;
+    analogInValue = currentAnalogIn.read();
+    curFeedBack = (analogInValue - currentOffset)*analog2Cur;
     pid.Compute(curRef, curFeedBack);
     MotorPlus = 0.5 - pid.output;
     if(pwmIndex_ == PWM1)TIM1->CCER |= 4;
@@ -36,10 +37,20 @@
 {
     analog2Cur = ratio;
 }
-
+//****************for test************************//
 void CURRENT_CONTROL::SetPWMDuty(float ratio)
 {
     MotorPlus = ratio;
     if(pwmIndex_ == PWM1)TIM1->CCER |= 4;
     else if(pwmIndex_ == PWM2)TIM1->CCER |= 64;
+}
+
+float CURRENT_CONTROL::GetAnalogIn(void)
+{
+    return analogInValue = currentAnalogIn.read();   
+}
+
+float CURRENT_CONTROL::GetCurrent(void)
+{
+    return  ((currentAnalogIn.read()-currentOffset)*analog2Cur);   
 }
\ No newline at end of file