STM3 ESC dual brushless motor controller. 10-60v, motor power rating tiny to kW. Ganged or independent motor control As used in 'The Brute' locomotive - www.jons-workshop.com
Dependencies: mbed BufferedSerial Servo FastPWM
Diff: DualBLS.h
- Revision:
- 8:93203f473f6e
- Parent:
- 7:6deaeace9a3e
- Child:
- 10:e40d8724268a
--- a/DualBLS.h Sun Jun 17 06:59:37 2018 +0000 +++ b/DualBLS.h Sat Aug 18 12:51:35 2018 +0000 @@ -6,20 +6,23 @@ const int TIMEOUT_SECONDS = 30; /* Please Do Not Alter these */ -const int VOLTAGE_READ_INTERVAL_US = 50, // Interrupts timed every 50 micro sec, runs around loop performing 1 A-D conversion per pass +const int PWM_PRESECALER_DEFAULT = 5, + VOLTAGE_READ_INTERVAL_US = 50, // Interrupts timed every 50 micro sec, runs around loop performing 1 A-D conversion per pass MAIN_LOOP_REPEAT_TIME_US = 31250, // 31250 us, with TACHO_TAB_SIZE = 32 means tacho_ticks_per_time is tacho_ticks_per_second MAIN_LOOP_ITERATION_Hz = 1000000 / MAIN_LOOP_REPEAT_TIME_US, CURRENT_SAMPLES_AVERAGED = 100, // Current is spikey. Reading smoothed by using average of this many latest current readings - PWM_HZ = 16000, // chosen to be above cutoff frequency of average human ear - MAX_PWM_TICKS = (SystemCoreClock / PWM_HZ), + PWM_HZ = 15000, // chosen to be above cutoff frequency of average human ear + MAX_PWM_TICKS = (SystemCoreClock / (PWM_HZ * PWM_PRESECALER_DEFAULT)), TICKLE_TIMES = 100 , WATCHDOG_RELOAD = (TIMEOUT_SECONDS * 8); // WatchDog counter ticked down in 8Hz loop /* End of Please Do Not Alter these */ const double PI = 4.0 * atan(1.0), TWOPI = 8.0 * atan(1.0); +const double Pot_Brake_Range = 0.33; -enum {MOTADIR, MOTBDIR, GANG, SVO1, SVO2, COMM_SRC, ID, WHEELDIA, MOTPIN, WHEELGEAR} ; // Identical in TS and DualBLS +//enum {MOTADIR, MOTBDIR, GANG, SVO1, SVO2, COMM_SRC, ID, WHEELDIA, MOTPIN, WHEELGEAR} ; // Identical in TS and DualBLS +enum {MOTADIR, MOTBDIR, GANG, SVO1, SVO2, COMM_SRC, ID, WHEELDIA, MOTPIN, WHEELGEAR, BOGHUNWAT, FUT1, FUT2, FUT3, FUT4, FUT5} ; // Identical in TS and DualBLS struct optpar { int min, max, def; // min, max, default const char * t; // description @@ -32,9 +35,15 @@ {0, 2, 2, "Servo2 0, 1, 2 = Not used, Input, Output"}, {1, 5, 2, "Command source 0 Invalid, 1 COM1, 2 COM2, 3 Pot, 4 Servo1, 5 Servo2"}, {'1', '9', '0', "Alternative ID ascii '1' to '9'"}, // defaults to '0' before eerom setup for first time - {20, 253, 98, "Wheel diameter mm"}, // New 01/06/2018 + {50, 253, 98, "Wheel diameter mm"}, // New 01/06/2018 {10, 253, 27, "Motor pinion"}, // New 01/06/2018 - {20, 253, 85, "Wheel gear"}, // New 01/06/2018 + {50, 253, 85, "Wheel gear"}, // New 01/06/2018 + {1, 20, 4, "Bogie power closest hundreds of Watt"}, // New 22/06/2018 + {0, 100, 0, "Future 1"}, + {0, 100, 0, "Future 2"}, + {0, 100, 0, "Future 3"}, + {0, 100, 0, "Future 4"}, + {0, 100, 0, "Future 5"}, } ; const int numof_eeprom_options = sizeof(option_list) / sizeof (struct optpar);