Jon Freeman / Mbed 2 deprecated Brushless_STM3_ESC_2019_10

Dependencies:   mbed BufferedSerial Servo PCT2075 FastPWM

Revision:
2:04761b196473
Parent:
0:435bf84ce48a
Child:
3:ecb00e0e8d68
--- a/cli_nortos.cpp	Wed Mar 07 08:29:18 2018 +0000
+++ b/cli_nortos.cpp	Sat Mar 10 10:11:07 2018 +0000
@@ -1,6 +1,7 @@
 #include "mbed.h"
 #include "BufferedSerial.h"
 #include <cctype>
+#include "DualBLS.h"
 using namespace std;
 
 typedef double  fl_typ;  //  
@@ -23,11 +24,23 @@
 //extern  void    read_pulses (uint32_t * ) ;
 //extern  void    apply_brake (double b)  ;
 //extern  uint32_t    Watch_Dog   ;
+extern  void    setVI   (double v, double i)  ;
+
+/*void    pcp (char * toprint)    {
+    pc.printf   (toprint);
+    return;
+}*/
 
 void    null_cmd (struct parameters & a)   {
     pc.printf   ("At null_cmd, parameters : First %.3f, second %.3f\r\n", a.dbl[0], a.dbl[1]);
 }
 
+extern  void    tickle  ()  ;
+void    ti_cmd (struct parameters & a)   {
+    pc.printf   ("At tickle\r\n");
+    tickle  ();
+}
+
 void    rd_cmd (struct parameters & a)   {  //  Reading Hall pulse totals and clock() from bogie
     uint32_t rd[2];
     char t[36];
@@ -35,31 +48,37 @@
     sprintf (t, "P0=%d, P1=%d, clock=%d\n", rd[0], rd[1], clock());
     pc.printf   (t);
 }
+extern  void    mode_test   (int mode, double val)  ;
 
 void    fw_cmd (struct parameters & a)   {
     pc.printf   ("Forward : First %d, second %d\r\n", a.dbl[0], a.dbl[1]);
+    mode_test   (FORWARD, 0.0);
 }
 
 void    re_cmd (struct parameters & a)   {
     pc.printf   ("Reverse : First %d, second %d\r\n", a.dbl[0], a.dbl[1]);
+    mode_test   (REVERSE, 0.0);
 }
 
 void    rb_cmd (struct parameters & a)   {  //  Regen brake
-    double b = a.dbl[0] / 999.0;
+    double b = a.dbl[0] / 99.0;
     pc.printf   ("Applying brake %.3f\r\n", b);
+    mode_test   (REGENBRAKE, b);
 //    apply_brake (b);
 }
 
-void    drive_cmd (struct parameters & a)   {   //  Drive
+/*void    drive_cmd (struct parameters & a)   {   //  Drive
     double drive = a.dbl[0] / 999.0;
 
 }
 void    coast_cmd (struct parameters & a)   {   //  Coast
     
 }
+*/
 void    hb_cmd (struct parameters & a)   {
     pc.printf   ("numof params = %d\r\n", a.numof_dbls);
     pc.printf   ("Hand Brake : First %.3f, second %.3f\r\n", a.dbl[0], a.dbl[1]);
+    mode_test   (HANDBRAKE, 0.0);
 }
 
 //void    wd_cmd (struct parameters & a)   {
@@ -117,22 +136,18 @@
 //    send_test();
 //}
 
-extern    void    set_api_mode    (bool mode) ;
-void    xm_cmd (struct parameters & a)
+//extern    void    set_api_mode    (bool mode) ;
+void    vi_cmd (struct parameters & a)
 {
-/*    if  (a[1].i == 2)
-        set_api_mode    (true);
-    else
-        set_api_mode    (false);
-    pc.printf   ("New API_MODE %d\r\n", a[1].i);
-*/
+    pc.printf   ("In setVI, setting V to %.2f, I %.2f\r\n", a.dbl[0], a.dbl[1]);
+    setVI   (a.dbl[0] / 100.0, a.dbl[1] / 100.0);
 }
 
-void    at_cmd (struct parameters & a)
+/*void    at_cmd (struct parameters & a)
 {
     xb.printf ("AT\r");
 //    pc.printf   ("AT %d\r\n", a[1].i);
-}
+}*/
 
 struct kb_command  {
     const char * cmd_word;         //  points to text e.g. "menu"
@@ -146,14 +161,15 @@
 //    {"sv", "set Volts pwm 0 to 999", setpwm_cmd},
 //    {"si", "set Amps pwm 0 to 999", setvref_cmd},
 //    {"ha", "read Hall pulse totals", hall_cmd},
+    {"ti", "tickle to try to get mosfet driver charge pump primed", ti_cmd},
     {"fw", "forward", fw_cmd},
     {"re", "reverse", re_cmd},
-    {"rb", "regen brake", rb_cmd},
-    {"dr", "drive", drive_cmd},
-    {"co", "coast", coast_cmd},
+    {"rb", "regen brake 0 to 99 %", rb_cmd},
+//    {"dr", "drive", drive_cmd},
+//    {"co", "coast", coast_cmd},
     {"hb", "hand brake", hb_cmd},
-    {"at", "AT", at_cmd},
-    {"xm", "set api mode, 1 or 2", xm_cmd},
+//    {"at", "AT", at_cmd},
+    {"vi", "set motors V and I percent RANGE 0 to 100", vi_cmd},
     {"nu", "do nothing", null_cmd},
 
 //    {"rev", "set motors in tother direction", set_rev_cmd},