robot

Dependencies:   FastPWM3 mbed

Revision:
83:eb3704d4943f
Parent:
82:5e741c5ffd9f
Child:
84:dd32640942a4
--- a/main.cpp	Fri Mar 10 08:29:13 2017 +0000
+++ b/main.cpp	Sat Mar 11 08:51:04 2017 +0000
@@ -33,7 +33,6 @@
 ThrottleMapper *th;
 
 int loop_counter = 0;
-float user_cmd = 0.0f;
 
 void update_velocity() {
     read.last_p_mech = read.p_mech;
@@ -132,7 +131,7 @@
 void slow_loop() {
     switch (BREMS_src) {
     case CMD_SRC_RC:
-        user_cmd = update_filter(user_cmd, io.throttle_in->get_throttle(), THROTTLE_FILTER_STRENGTH);
+        control.user_cmd = update_filter(control.user_cmd, io.throttle_in->get_throttle(), THROTTLE_FILTER_STRENGTH);
         break;
     case CMD_SRC_ANALOG:
         //analog code here;
@@ -142,14 +141,15 @@
     case CMD_SRC_CAN:
     case CMD_SRC_INTERNAL:
     default:
+        //these sources are updated asynchronously via interrupts
         break;
     }
     switch (BREMS_op) {
     case OP_TORQUE:
-        control.torque_percent = user_cmd;
+        control.torque_percent = control.user_cmd;
         break;
     case OP_DRIVING:
-        control.torque_percent = th->map(user_cmd, read.w);
+        control.torque_percent = th->map(control.user_cmd, read.w);
         break;
     case OP_SPEED:
         //set velocity setpoint here;
@@ -159,21 +159,6 @@
         break;
     }
 }
-        
-extern "C" void TIM1_UP_TIM10_IRQHandler(void) {
-    int start_state = io.throttle_in->state();
-    if (TIM1->SR & TIM_SR_UIF ) {
-        ADC1->CR2  |= 0x40000000; 
-        volatile int delay;
-        for (delay = 0; delay < 35; delay++);
-        read.adval1 = ADC1->DR;
-        read.adval2 = ADC2->DR;
-        commutate();
-    }
-    TIM1->SR = 0x00;
-    int end_state = io.throttle_in->state();
-    if (start_state != end_state) io.throttle_in->block();
-}
 
 int main() {
     dq = new LutMapper();