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

Committer:
JonFreeman
Date:
Sat Aug 18 12:51:35 2018 +0000
Revision:
8:93203f473f6e
Parent:
7:6deaeace9a3e
Child:
10:e40d8724268a
Work underway to drive brushed motors.; Code as supplied to Rob

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JonFreeman 2:04761b196473 1 const int HANDBRAKE = 0,
JonFreeman 2:04761b196473 2 FORWARD = 8,
JonFreeman 2:04761b196473 3 REVERSE = 16,
JonFreeman 2:04761b196473 4 REGENBRAKE = 24;
JonFreeman 3:ecb00e0e8d68 5
JonFreeman 5:ca86a7848d54 6 const int TIMEOUT_SECONDS = 30;
JonFreeman 5:ca86a7848d54 7
JonFreeman 5:ca86a7848d54 8 /* Please Do Not Alter these */
JonFreeman 8:93203f473f6e 9 const int PWM_PRESECALER_DEFAULT = 5,
JonFreeman 8:93203f473f6e 10 VOLTAGE_READ_INTERVAL_US = 50, // Interrupts timed every 50 micro sec, runs around loop performing 1 A-D conversion per pass
JonFreeman 5:ca86a7848d54 11 MAIN_LOOP_REPEAT_TIME_US = 31250, // 31250 us, with TACHO_TAB_SIZE = 32 means tacho_ticks_per_time is tacho_ticks_per_second
JonFreeman 5:ca86a7848d54 12 MAIN_LOOP_ITERATION_Hz = 1000000 / MAIN_LOOP_REPEAT_TIME_US,
JonFreeman 5:ca86a7848d54 13 CURRENT_SAMPLES_AVERAGED = 100, // Current is spikey. Reading smoothed by using average of this many latest current readings
JonFreeman 8:93203f473f6e 14 PWM_HZ = 15000, // chosen to be above cutoff frequency of average human ear
JonFreeman 8:93203f473f6e 15 MAX_PWM_TICKS = (SystemCoreClock / (PWM_HZ * PWM_PRESECALER_DEFAULT)),
JonFreeman 5:ca86a7848d54 16 TICKLE_TIMES = 100 ,
JonFreeman 5:ca86a7848d54 17 WATCHDOG_RELOAD = (TIMEOUT_SECONDS * 8); // WatchDog counter ticked down in 8Hz loop
JonFreeman 5:ca86a7848d54 18
JonFreeman 5:ca86a7848d54 19 /* End of Please Do Not Alter these */
JonFreeman 3:ecb00e0e8d68 20 const double PI = 4.0 * atan(1.0),
JonFreeman 3:ecb00e0e8d68 21 TWOPI = 8.0 * atan(1.0);
JonFreeman 8:93203f473f6e 22 const double Pot_Brake_Range = 0.33;
JonFreeman 5:ca86a7848d54 23
JonFreeman 8:93203f473f6e 24 //enum {MOTADIR, MOTBDIR, GANG, SVO1, SVO2, COMM_SRC, ID, WHEELDIA, MOTPIN, WHEELGEAR} ; // Identical in TS and DualBLS
JonFreeman 8:93203f473f6e 25 enum {MOTADIR, MOTBDIR, GANG, SVO1, SVO2, COMM_SRC, ID, WHEELDIA, MOTPIN, WHEELGEAR, BOGHUNWAT, FUT1, FUT2, FUT3, FUT4, FUT5} ; // Identical in TS and DualBLS
JonFreeman 5:ca86a7848d54 26 struct optpar {
JonFreeman 5:ca86a7848d54 27 int min, max, def; // min, max, default
JonFreeman 5:ca86a7848d54 28 const char * t; // description
JonFreeman 5:ca86a7848d54 29 } ;
JonFreeman 5:ca86a7848d54 30 struct optpar const option_list[] = {
JonFreeman 5:ca86a7848d54 31 {0, 1, 1, "MotorA direction 0 or 1"},
JonFreeman 5:ca86a7848d54 32 {0, 1, 0, "MotorB direction 0 or 1"},
JonFreeman 5:ca86a7848d54 33 {0, 1, 1, "gang 0 for separate control (robot mode), 1 for ganged loco bogie mode"},
JonFreeman 5:ca86a7848d54 34 {0, 2, 2, "Servo1 0, 1, 2 = Not used, Input, Output"},
JonFreeman 5:ca86a7848d54 35 {0, 2, 2, "Servo2 0, 1, 2 = Not used, Input, Output"},
JonFreeman 5:ca86a7848d54 36 {1, 5, 2, "Command source 0 Invalid, 1 COM1, 2 COM2, 3 Pot, 4 Servo1, 5 Servo2"},
JonFreeman 5:ca86a7848d54 37 {'1', '9', '0', "Alternative ID ascii '1' to '9'"}, // defaults to '0' before eerom setup for first time
JonFreeman 8:93203f473f6e 38 {50, 253, 98, "Wheel diameter mm"}, // New 01/06/2018
JonFreeman 7:6deaeace9a3e 39 {10, 253, 27, "Motor pinion"}, // New 01/06/2018
JonFreeman 8:93203f473f6e 40 {50, 253, 85, "Wheel gear"}, // New 01/06/2018
JonFreeman 8:93203f473f6e 41 {1, 20, 4, "Bogie power closest hundreds of Watt"}, // New 22/06/2018
JonFreeman 8:93203f473f6e 42 {0, 100, 0, "Future 1"},
JonFreeman 8:93203f473f6e 43 {0, 100, 0, "Future 2"},
JonFreeman 8:93203f473f6e 44 {0, 100, 0, "Future 3"},
JonFreeman 8:93203f473f6e 45 {0, 100, 0, "Future 4"},
JonFreeman 8:93203f473f6e 46 {0, 100, 0, "Future 5"},
JonFreeman 5:ca86a7848d54 47 } ;
JonFreeman 6:f289a49c1eae 48 const int numof_eeprom_options = sizeof(option_list) / sizeof (struct optpar);
JonFreeman 5:ca86a7848d54 49
JonFreeman 6:f289a49c1eae 50 struct single_bogie_options {
JonFreeman 6:f289a49c1eae 51 char motoradir, motorbdir, gang, svo1, svo2, comm_src, id, wheeldia, motpin, wheelgear, spare;
JonFreeman 6:f289a49c1eae 52 } ;