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: F446ZE.h
- Revision:
- 8:93203f473f6e
- Parent:
- 7:6deaeace9a3e
--- a/F446ZE.h Sun Jun 17 06:59:37 2018 +0000 +++ b/F446ZE.h Sat Aug 18 12:51:35 2018 +0000 @@ -1,16 +1,14 @@ // 5TH JUNE 2018 NONE OF THIS IS RIGHT YET !! - // Hoped to select servo functions from user info stored on EEROM. Too difficult. Do not define servo as in and out - // Port A -> MotorA, Port B -> MotorB const uint16_t -AUL = 1 << 0, // Feb 2018 Now using DGD21032 mosfet drivers via 74HC00 pwm gates (low side) - GOOD, works well with auto-tickle of high side drivers -AVL = 1 << 6, // These are which port bits connect to which mosfet driver -AWL = 1 << 4, +AUL = 1 << 1, // Feb 2018 Now using DGD21032 mosfet drivers via 74HC00 pwm gates (low side) - GOOD, works well with auto-tickle of high side drivers +AVL = 1 << 2, // These are which port bits connect to which mosfet driver +AWL = 1 << 3, -AUH = 1 << 1, -AVH = 1 << 7, -AWH = 1 << 8, +AUH = 1 << 4, +AVH = 1 << 5, +AWH = 1 << 6, AUV = AUH | AVL, // Each of 6 possible output energisations made up of one hi and one low AVU = AVH | AUL, @@ -29,8 +27,8 @@ BWL = 1 << 2, BUH = 1 << 10, -BVH = 1 << 12, -BWH = 1 << 13, +BVH = 1 << 11, +BWH = 1 << 3, BUV = BUH | BVL, BVU = BVH | BUL, @@ -46,14 +44,14 @@ PORT_A_MASK = AUL | AVL | AWL | AUH | AVH | AWH, // NEW METHOD FOR DGD21032 MOSFET DRIVERS PORT_B_MASK = BUL | BVL | BWL | BUH | BVH | BWH; - -PortOut MotA (PortA, PORT_A_MASK); // Activate output ports to motor drivers -PortOut MotB (PortB, PORT_B_MASK); +// Use Ports E and G - best first guess July 2018 +PortOut MotA (PortE, PORT_A_MASK); // Activate output ports to motor drivers +PortOut MotB (PortG, PORT_B_MASK); // Pin 1 VBAT NET +3V3 //DigitalIn J3 (PC_13, PullUp);// Pin 2 Jumper pulls to GND, R floats Hi -InterruptIn Temperature_pin (PC_13);// Pin 2 June 2018 - taken for temperature sensor - hard wired to T1 due to wrong thought T1 could be InterruptIn +InterruptIn Temperature_pin (PD_7);// Pin ?? June 2018 - taken for temperature sensor - hard wired to T1 due to wrong thought T1 could be InterruptIn // Pin 3 PC14-OSC32_IN NET O32I @@ -70,16 +68,16 @@ // Pin 14 Port_A AUL // Pin 15 Port_A AUH // Pins 16, 17 BufferedSerial pc -BufferedSerial pc (PA_2, PA_3, 512, 4, NULL); // Pins 16, 17 tx, rx to pc via usb lead +BufferedSerial pc (PD_8, PD_9, 512, 4, NULL); // Pins 16, 17 tx, rx to pc via usb lead // Pin 18 VSS NET GND // Pin 19 VDD NET +3V3 // Pin 20 Port_A AWL // Pin 21 DigitalOut led1(LED1); -DigitalOut LED (PA_5); // Pin 21 +DigitalOut LED (PB_0); // Pin ?? as fitted to Nucleo board. Other leds use PB_7 and PB_14 // Pin 22 Port_A AVL // Pin 23 Port_A AVH -InterruptIn MBH2 (PC_4); // Pin 24 -InterruptIn MBH3 (PC_5); // Pin 25 +InterruptIn MBH2 (PD_1); // Pin ?? +InterruptIn MBH3 (PD_3); // Pin ?? // Pin 26 Port_B BUL // Pin 27 Port_B BVL // Pin 28 Port_B BWL @@ -89,17 +87,21 @@ // Pin 32 VDD // Pin 33 Port_B BVH // Pin 34 Port_B BWH -DigitalOut T4 (PB_14); // Pin 35 -DigitalOut T3 (PB_15); // Pin 36 + +//DigitalOut T4 (PB_14); // Pin ** +//DigitalOut T3 (PB_15); // Pin ** + // BufferedSerial com2 pins 37 Tx, 38 Rx -BufferedSerial com2 (PC_6, PC_7); // Pins 37, 38 tx, rx to XBee module -FastPWM A_MAX_V_PWM (PC_8, 1), // Pin 39 pwm3/3 - A_MAX_I_PWM (PC_9, 1); // pin 40, prescaler value pwm3/4 +BufferedSerial com2 (PC_10, PC_11); // Pins 37, 38 tx, rx to XBee module +FastPWM A_MAX_V_PWM (PC_8, PWM_PRESECALER_DEFAULT), // Pin 39 pwm3/3 + A_MAX_I_PWM (PC_9, PWM_PRESECALER_DEFAULT); // pin 40, prescaler value pwm3/4 //InterruptIn MotB_Hall (PA_8); // Pin 41 // Pin 41 Port_A AWH // BufferedSerial com3 pins 42 Tx, 43 Rx //InterruptIn tryseredge (PA_9); -BufferedSerial com3 (PA_9, PA_10); // Pins 42, 43 tx, rx to any aux module + +BufferedSerial com3 (PC_12, PD_2); // Pins 42, 43 tx, rx to any aux module + // PA_9 is Tx. I wonder, can we also use InterruptIn on this pin to generate interrupts on tx bit transitions ? Let's find out ! // No. @@ -111,7 +113,7 @@ //InterruptIn T1 (PA_12); // Pin 45 now input counting pulses from LMT01 temperature sensor // InterruptIn DOES NOT WORK ON PA_12. Boards are being made, will have to wire link PA12 to PC13 -DigitalIn T1 (PA_12); +//DigitalIn T1 (PA_12); ////InterruptIn T1 (PC_13); // Pin 45 now input counting pulses from LMT01 temperature sensor @@ -123,21 +125,21 @@ //Was DigitalOut T5 (PA_15); // Pin 50 DigitalIn T5 (PA_15); // Pin 50 now fwd/rev from remote control box if fitted -InterruptIn MAH1 (PC_10); // Pin 51 -InterruptIn MAH2 (PC_11); // Pin 52 -InterruptIn MAH3 (PC_12); // Pin 53 -InterruptIn MBH1 (PD_2); // Pin 54 +InterruptIn MAH1 (PD_4); // Pin 51 +InterruptIn MAH2 (PD_5); // Pin 52 +InterruptIn MAH3 (PD_6); // Pin 53 +InterruptIn MBH1 (PD_0); // Pin 54 DigitalOut T6 (PB_3); // Pin 55 -FastPWM B_MAX_V_PWM (PB_4, 1), // Pin 56 pwm3/3 - B_MAX_I_PWM (PB_5, 1); // pin 57, prescaler value pwm3/4 +FastPWM B_MAX_V_PWM (PE_13, PWM_PRESECALER_DEFAULT), // Pin 56 pwm3/3 + B_MAX_I_PWM (PE_14, PWM_PRESECALER_DEFAULT); // pin 57, prescaler value pwm3/4 -I2C i2c (PB_7, PB_6); // Pins 58, 59 For 24LC64 eeprom +I2C i2c (PB_9, PB_8); // Pins 58, 59 For 24LC64 eeprom // Pin 60 BOOT0 // Servo pins, 2 off. Configured as Input to read radio control receiver // If used as servo output, code gives pin to 'Servo' - seems to work -InterruptIn Servo1_i (PB_8); // Pin 61 to read output from rc rx -InterruptIn Servo2_i (PB_9); // Pin 62 to read output from rc rx +InterruptIn Servo1_i (PF_14); // Pin 61 to read output from rc rx +InterruptIn Servo2_i (PF_15); // Pin 62 to read output from rc rx // Pin 63 VSS // Pin 64 VDD