Bayley Wang / Mbed 2 deprecated foc-ed_in_the_bot_compact

Dependencies:   FastPWM3 mbed

Files at this revision

API Documentation at this revision

Comitter:
bwang
Date:
Mon Feb 12 04:22:13 2018 +0000
Parent:
204:74714d52a936
Child:
206:5c848ea69028
Commit message:
02/11/2018 21:21 - cmd_exit() checks that motor is not running

Changed in this revision

CHANGELOG.txt Show annotated file Show diff for this revision Revisions of this file
CommandProcessor/cmd_mode.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/CHANGELOG.txt	Mon Feb 12 04:12:07 2018 +0000
+++ b/CHANGELOG.txt	Mon Feb 12 04:22:13 2018 +0000
@@ -45,4 +45,5 @@
 02/11/2018 02:54 - long commands can no longer be executed while control.enabled == true, invalid BREMS_src now sets control.user_cmd to 0
 02/11/2018 03:16 - blocked switching modes when motor is running
 02/11/2018 20:13 - scrambled the mode and error handling code in commutate() to be cleaner
-02/11/2018 21:11 - further improvements to mode handling, output overrides and output disabling now live in their own functions
\ No newline at end of file
+02/11/2018 21:11 - further improvements to mode handling, output overrides and output disabling now live in their own functions
+02/11/2018 21:21 - cmd_exit() checks that motor is not running
\ No newline at end of file
--- a/CommandProcessor/cmd_mode.cpp	Mon Feb 12 04:12:07 2018 +0000
+++ b/CommandProcessor/cmd_mode.cpp	Mon Feb 12 04:22:13 2018 +0000
@@ -56,6 +56,10 @@
 }
 
 void cmd_exit(Serial *pc) {
+    if (control.user_cmd != 0.0f || control.torque_percent != 0.0f) {
+        pc->printf("%s\n", "Turn off motor first");
+        return;
+    }
     BREMS_mode = MODE_RUN;
     pc->printf("%s\n", "Run mode ON");
 }
\ No newline at end of file
--- a/main.cpp	Mon Feb 12 04:12:07 2018 +0000
+++ b/main.cpp	Mon Feb 12 04:22:13 2018 +0000
@@ -96,7 +96,8 @@
     va = va - voff;
     vb = vb - voff;
     vc = vc - voff;
-        
+    
+    /*some modes override the FOC outputs*/    
     switch (BREMS_mode) {
     case MODE_CFG:
         va = 0.0f;