robot

Dependencies:   FastPWM3 mbed

Revision:
70:5e39beeb4a21
Parent:
65:6e1fdbfae57b
Child:
71:292dfc44ca53
--- a/main.cpp	Sun Jan 29 07:58:52 2017 +0000
+++ b/main.cpp	Sun Feb 05 08:41:21 2017 +0000
@@ -122,8 +122,8 @@
 }
 
 void slow_loop() {
-    float torque_percent = th->map(io.throttle_in->get_throttle(), read.w);
-    dq->map(torque_percent, read.w, &control.d_ref, &control.q_ref);
+    control.torque_percent = update_filter(control.torque_percent, th->map(io.throttle_in->get_throttle(), read.w), THROTTLE_FILTER_STRENGTH);
+    dq->map(control.torque_percent, read.w, &control.d_ref, &control.q_ref);
 }
 
 void go_enabled() {
@@ -146,6 +146,13 @@
     return str * old + (1.0f - str) * x;
 }
 
+void debug_print() {
+    io.pc->printf("%d,%d,%d,%d,%d,%d,%d,%d\n", (int) read.w, (int) control.d_ref, (int) control.d_filtered, (int) control.q_ref, (int) control.q_filtered, (int) (255 * control.torque_percent), 
+                        (int) (255 * control.d_integral), (int) (255 * control.q_integral));
+    wait(0.01);
+}
+        
+
 extern "C" void TIM1_UP_TIM10_IRQHandler(void) {
     if (TIM1->SR & TIM_SR_UIF ) {
         ADC1->CR2  |= 0x40000000; 
@@ -164,5 +171,6 @@
     BREMSInit(&io, &read, &foc, &control, false);
     
     for (;;) {
+        debug_print();
     }
 }
\ No newline at end of file