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:
- 5:ca86a7848d54
- Parent:
- 3:ecb00e0e8d68
- Child:
- 6:f289a49c1eae
--- a/DualBLS.h Thu Apr 26 08:23:04 2018 +0000 +++ b/DualBLS.h Tue May 29 16:36:34 2018 +0000 @@ -5,5 +5,34 @@ REVERSE = 16, REGENBRAKE = 24; +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 + 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), + 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); + +struct optpar { + int min, max, def; // min, max, default + const char * t; // description +} ; +struct optpar const option_list[] = { + {0, 1, 1, "MotorA direction 0 or 1"}, + {0, 1, 0, "MotorB direction 0 or 1"}, + {0, 1, 1, "gang 0 for separate control (robot mode), 1 for ganged loco bogie mode"}, + {0, 2, 2, "Servo1 0, 1, 2 = Not used, Input, Output"}, + {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 +} ; +const int numofopts = sizeof(option_list) / sizeof (struct optpar); +