Dual Brushless Motor ESC, 10-62V, up to 50A per motor. Motors ganged or independent, multiple control input methods, cycle-by-cycle current limit, speed mode and torque mode control. Motors tiny to kW. Speed limit and other parameters easily set in firmware. As used in 'The Brushless Brutalist' locomotive - www.jons-workshop.com. See also Model Engineer magazine June-October 2019.

Dependencies:   mbed BufferedSerial Servo PCT2075 FastPWM

Update 17th August 2020 Radio control inputs completed

Revision:
8:93203f473f6e
Parent:
7:6deaeace9a3e
Child:
9:ac2412df01be
--- a/cli_BLS_nortos.cpp	Sun Jun 17 06:59:37 2018 +0000
+++ b/cli_BLS_nortos.cpp	Sat Aug 18 12:51:35 2018 +0000
@@ -7,7 +7,9 @@
 using namespace std;
 
 extern  int I_Am    ()  ;      //  Returns boards id number as ASCII char '0', '1' etc. Code for Broadcast = '\r'
-extern  int WatchDog;
+extern  int     WatchDog;
+extern  bool    WatchDogEnable;
+extern  char    mode_bytes[];
 
 const int   BROADCAST   = '\r';
 const   int MAX_PARAMS = 20;
@@ -31,6 +33,11 @@
 extern  void    read_last_VI    (double * val)  ;   //  only for test from cli
 
 //BufferedSerial * com;
+extern  double  Read_DriverPot  ();
+void    pot_cmd (struct parameters & a)
+{
+    pc.printf   ("Driver's pot %.3f\r\n", Read_DriverPot  ());
+}
 
 void    null_cmd (struct parameters & a)
 {
@@ -38,7 +45,45 @@
         a.com->printf   ("At null_cmd, board ID %c, parameters : First %.3f, second %.3f\r\n", I_Am(), a.dbl[0], a.dbl[1]);
 }
 
-extern  void    mode_set   (int mode, double val)  ;   //  called from cli to set fw, re, rb, hb
+//    {"wden", "enable watchdog if modes allow", wden_lococmd},
+//    {"wddi", "disable watchdog always", wddi_lococmd},
+
+void    wden_lococmd (struct parameters & a)
+{
+    if  (mode_bytes[COMM_SRC] != 3)     //  When not hand pot control, allow watchdog enable
+        WatchDogEnable  = true;
+}
+void    wden_pccmd (struct parameters & a)
+{
+    wden_lococmd    (a);
+    a.com->printf   ("Watchdog %sabled\r\n", WatchDogEnable ? "En":"Dis");
+}
+
+void    wddi_lococmd (struct parameters & a)
+{
+    WatchDogEnable  = false;
+}
+void    wddi_pccmd (struct parameters & a)
+{
+    wddi_lococmd    (a);
+    a.com->printf   ("Watchdog %sabled\r\n", WatchDogEnable ? "En":"Dis");
+}
+
+extern  void prscfuck   (int);
+void    pf_cmd (struct parameters & a)
+{
+    prscfuck    ((int)a.dbl[0]);
+}
+
+extern  void    report_motor_types  ()  ;
+void    mt_cmd (struct parameters & a)
+{
+    report_motor_types  ();
+//    if  (a.respond) 
+//        a.com->printf   ("At null_cmd, board ID %c, parameters : First %.3f, second %.3f\r\n", I_Am(), a.dbl[0], a.dbl[1]);
+}
+
+extern  void    mode_set_both_motors   (int mode, double val)  ;   //  called from cli to set fw, re, rb, hb
 extern  void    read_supply_vi   (double * val)  ;
 
 void    rdi_cmd (struct parameters & a)  //  read motor currents
@@ -61,19 +106,19 @@
 
 void    fw_cmd (struct parameters & a)  //  Forward command
 {
-    mode_set   (FORWARD, 0.0);
+    mode_set_both_motors   (FORWARD, 0.0);
 }
 
 void    re_cmd (struct parameters & a)  //  Reverse command
 {
-    mode_set   (REVERSE, 0.0);
+    mode_set_both_motors   (REVERSE, 0.0);
 }
 
 void    rb_cmd (struct parameters & a)      //  Regen brake command
 {
     double b = a.dbl[0] / 100.0;
 //    a.com->printf   ("Applying brake %.3f\r\n", b);
-    mode_set   (REGENBRAKE, b);
+    mode_set_both_motors   (REGENBRAKE, b);
 //    apply_brake (b);
 }
 
@@ -105,7 +150,25 @@
 //            last;
 }   ;
 */
-extern  char mode_bytes[];
+
+//  New 22 June 2018
+//  get bogie bytes - report back to touch controller
+void    gbb_cmd (struct parameters & a)       //  
+{
+    if  (a.target_unit == BROADCAST || !a.resp_always) {
+//        a.com->printf ("At mode_cmd, can not use BROADCAST with mode_cmd\r\n");
+    } else    {
+        pc.printf   ("At gbb\r\n");
+        char    eeprom_contents[36];    //  might need to be unsigned?
+        memset  (eeprom_contents, 0, 36);
+        a.com->printf   ("gbb");
+        rd_24LC64   (0, eeprom_contents, 32);
+        for (int i = 0; i < numof_eeprom_options; i++)
+            a.com->printf (" %d", eeprom_contents[i]);
+        a.com->putc ('\r');
+        a.com->putc ('\n');
+    }
+}
 
 void    mode_cmd (struct parameters & a)       //  With no params, reads eeprom contents. With params sets eeprom contents
 {
@@ -154,7 +217,7 @@
         a.com->printf   ("numof params = %d\r\n", a.numof_dbls);
         a.com->printf   ("Hand Brake : First %.3f, second %.3f\r\n", a.dbl[0], a.dbl[1]);
     }
-    mode_set   (HANDBRAKE, 0.0);
+    mode_set_both_motors   (HANDBRAKE, 0.0);
 }
 
 extern  uint32_t    last_temp_count;
@@ -183,9 +246,11 @@
 extern  double  rpm2mph ;
 void    mph_cmd (struct parameters & a) //  to report miles per hour
 {
+    if  (a.respond) {
         uint32_t dest[3];
         read_RPM    (dest);     //  gets rpm for each motor
-        a.com->printf ("mph%c %.3f\r\n", mode_bytes[ID], (double)(dest[0] + dest[1]) * rpm2mph / 2.0);
+        a.com->printf ("mph%c %.3f\r", mode_bytes[ID], (double)(dest[0] + dest[1]) * rpm2mph / 2.0);
+    }
 }
 
 void    menucmd (struct parameters & a);
@@ -240,15 +305,19 @@
     {"v", "set motors V percent RANGE 0 to 100", v_cmd},
     {"i", "set motors I percent RANGE 0 to 100", i_cmd},
     {"vi", "set motors V and I percent RANGE 0 to 100", vi_cmd},
-    {"who", "search for connected units, e.g. 3who returs 'Hi there' if found", who_cmd},
+    {"who", "search for connected units, e.g. 3who returs 'who3' if found", who_cmd},
     {"mode", "read or set params in eeprom", mode_cmd},
     {"erase", "set eeprom contents to all 0xff", erase_cmd},
     {"tem", "report temperature", temperature_cmd},
     {"kd", "kick the dog, reloads WatchDog", kd_cmd},
+    {"wden", "enable watchdog if modes allow", wden_lococmd},
+    {"wddi", "disable watchdog always", wddi_lococmd},
     {"rpm", "read motor pair speeds", rpm_cmd},
+    {"mph", "read loco speed miles per hour", mph_cmd},
     {"rvi", "read most recent values sent to pwms", rvi_cmd},
     {"rdi", "read motor currents and power voltage", rdi_cmd},
-    {"bc", "bogie constants - wheel dia, motor pinion, wheel gear", bogie_constants_report_cmd},
+    {"bc", "bogie constants - wheel dia, motor pinion, wheel gear", bogie_constants_report_cmd},    //  OBSOLETE, replaced by 'gbb'
+    {"gbb", "get bogie bytes from eeprom and report", gbb_cmd},
     {"nu", "do nothing", null_cmd},
 };
 
@@ -258,6 +327,9 @@
 struct  kb_command const pc_command_list[] = {
     {"ls", "Lists available commands", menucmd},
     {"?", "Lists available commands, same as ls", menucmd},
+    {"mtypes", "report types of motors found", mt_cmd},
+    {"pf", "try changing FastPWM prescaler values", pf_cmd},
+    {"pot", "read drivers control pot", pot_cmd},
     {"fw", "forward", fw_cmd},
     {"re", "reverse", re_cmd},
     {"rb", "regen brake 0 to 99 %", rb_cmd},
@@ -265,16 +337,19 @@
     {"v", "set motors V percent RANGE 0 to 100", v_cmd},
     {"i", "set motors I percent RANGE 0 to 100", i_cmd},
     {"vi", "set motors V and I percent RANGE 0 to 100", vi_cmd},
-    {"who", "search for connected units, e.g. 3who returs 'Hi there' if found", who_cmd},
+    {"who", "search for connected units, e.g. 3who returs 'who3' if found", who_cmd},
     {"mode", "read or set params in eeprom", mode_cmd},
     {"erase", "set eeprom contents to all 0xff", erase_cmd},
     {"tem", "report temperature", temperature_cmd},
     {"kd", "kick the dog, reloads WatchDog", kd_cmd},
+    {"wden", "enable watchdog if modes allow", wden_pccmd},
+    {"wddi", "disable watchdog always", wddi_pccmd},
     {"rpm", "read motor pair speeds", rpm_cmd},
     {"mph", "read loco speed miles per hour", mph_cmd},
     {"rvi", "read most recent values sent to pwms", rvi_cmd},
     {"rdi", "read motor currents and power voltage", rdi_cmd},
     {"bc", "bogie constants - wheel dia, motor pinion, wheel gear", bogie_constants_report_cmd},
+    {"gbb", "get bogie bytes from eeprom and report", gbb_cmd},    //  OBSOLETE, replaced by 'gbb'
     {"nu", "do nothing", null_cmd},
 };