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:
Tue Jan 15 09:03:57 2019 +0000
Revision:
10:e40d8724268a
Parent:
8:93203f473f6e
Child:
11:bfb73f083009
Buggered serial comms to TS controller

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 5:ca86a7848d54 22
JonFreeman 8:93203f473f6e 23 //enum {MOTADIR, MOTBDIR, GANG, SVO1, SVO2, COMM_SRC, ID, WHEELDIA, MOTPIN, WHEELGEAR} ; // Identical in TS and DualBLS
JonFreeman 8:93203f473f6e 24 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 25 struct optpar {
JonFreeman 5:ca86a7848d54 26 int min, max, def; // min, max, default
JonFreeman 5:ca86a7848d54 27 const char * t; // description
JonFreeman 5:ca86a7848d54 28 } ;
JonFreeman 5:ca86a7848d54 29 struct optpar const option_list[] = {
JonFreeman 5:ca86a7848d54 30 {0, 1, 1, "MotorA direction 0 or 1"},
JonFreeman 5:ca86a7848d54 31 {0, 1, 0, "MotorB direction 0 or 1"},
JonFreeman 5:ca86a7848d54 32 {0, 1, 1, "gang 0 for separate control (robot mode), 1 for ganged loco bogie mode"},
JonFreeman 5:ca86a7848d54 33 {0, 2, 2, "Servo1 0, 1, 2 = Not used, Input, Output"},
JonFreeman 5:ca86a7848d54 34 {0, 2, 2, "Servo2 0, 1, 2 = Not used, Input, Output"},
JonFreeman 5:ca86a7848d54 35 {1, 5, 2, "Command source 0 Invalid, 1 COM1, 2 COM2, 3 Pot, 4 Servo1, 5 Servo2"},
JonFreeman 5:ca86a7848d54 36 {'1', '9', '0', "Alternative ID ascii '1' to '9'"}, // defaults to '0' before eerom setup for first time
JonFreeman 8:93203f473f6e 37 {50, 253, 98, "Wheel diameter mm"}, // New 01/06/2018
JonFreeman 7:6deaeace9a3e 38 {10, 253, 27, "Motor pinion"}, // New 01/06/2018
JonFreeman 8:93203f473f6e 39 {50, 253, 85, "Wheel gear"}, // New 01/06/2018
JonFreeman 8:93203f473f6e 40 {1, 20, 4, "Bogie power closest hundreds of Watt"}, // New 22/06/2018
JonFreeman 8:93203f473f6e 41 {0, 100, 0, "Future 1"},
JonFreeman 8:93203f473f6e 42 {0, 100, 0, "Future 2"},
JonFreeman 8:93203f473f6e 43 {0, 100, 0, "Future 3"},
JonFreeman 8:93203f473f6e 44 {0, 100, 0, "Future 4"},
JonFreeman 8:93203f473f6e 45 {0, 100, 0, "Future 5"},
JonFreeman 5:ca86a7848d54 46 } ;
JonFreeman 6:f289a49c1eae 47 const int numof_eeprom_options = sizeof(option_list) / sizeof (struct optpar);
JonFreeman 5:ca86a7848d54 48
JonFreeman 6:f289a49c1eae 49 struct single_bogie_options {
JonFreeman 6:f289a49c1eae 50 char motoradir, motorbdir, gang, svo1, svo2, comm_src, id, wheeldia, motpin, wheelgear, spare;
JonFreeman 6:f289a49c1eae 51 } ;
JonFreeman 10:e40d8724268a 52
JonFreeman 10:e40d8724268a 53 //const double SERVOIN_PWR_BENDER = 1.5; // Used to change servo_in stick at centre position to match pot approx 1/3 braking 2/3 driving