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
F446ZE.h
00001 // 5TH JUNE 2018 NONE OF THIS IS RIGHT YET !! 00002 // Hoped to select servo functions from user info stored on EEROM. Too difficult. Do not define servo as in and out 00003 // Port A -> MotorA, Port B -> MotorB 00004 const uint16_t 00005 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 00006 AVL = 1 << 2, // These are which port bits connect to which mosfet driver 00007 AWL = 1 << 3, 00008 00009 AUH = 1 << 4, 00010 AVH = 1 << 5, 00011 AWH = 1 << 6, 00012 00013 AUV = AUH | AVL, // Each of 6 possible output energisations made up of one hi and one low 00014 AVU = AVH | AUL, 00015 AUW = AUH | AWL, 00016 AWU = AWH | AUL, 00017 AVW = AVH | AWL, 00018 AWV = AWH | AVL, 00019 00020 KEEP_L_MASK_A = AUL | AVL | AWL, 00021 KEEP_H_MASK_A = AUH | AVH | AWH, 00022 00023 BRA = AUL | AVL | AWL, // All low side switches on (and all high side off) for braking 00024 00025 BUL = 1 << 0, // Likewise for MotorB but different port bits on different port 00026 BVL = 1 << 1, 00027 BWL = 1 << 2, 00028 00029 BUH = 1 << 10, 00030 BVH = 1 << 11, 00031 BWH = 1 << 3, 00032 00033 BUV = BUH | BVL, 00034 BVU = BVH | BUL, 00035 BUW = BUH | BWL, 00036 BWU = BWH | BUL, 00037 BVW = BVH | BWL, 00038 BWV = BWH | BVL, 00039 00040 KEEP_L_MASK_B = BUL | BVL | BWL, 00041 KEEP_H_MASK_B = BUH | BVH | BWH, 00042 00043 BRB = BUL | BVL | BWL, 00044 00045 PORT_A_MASK = AUL | AVL | AWL | AUH | AVH | AWH, // NEW METHOD FOR DGD21032 MOSFET DRIVERS 00046 PORT_B_MASK = BUL | BVL | BWL | BUH | BVH | BWH; 00047 // Use Ports E and G - best first guess July 2018 00048 PortOut MotA (PortE, PORT_A_MASK); // Activate output ports to motor drivers 00049 PortOut MotB (PortG, PORT_B_MASK); 00050 00051 // Pin 1 VBAT NET +3V3 00052 00053 //DigitalIn J3 (PC_13, PullUp);// Pin 2 Jumper pulls to GND, R floats Hi 00054 InterruptIn Temperature_pin (PD_7);// Pin ?? June 2018 - taken for temperature sensor - hard wired to T1 due to wrong thought T1 could be InterruptIn 00055 00056 00057 // Pin 3 PC14-OSC32_IN NET O32I 00058 // Pin 4 PC15-OSC32_OUT NET O32O 00059 // Pin 5 PH0-OSC_IN NET PH1 00060 // Pin 6 PH1-OSC_OUT NET PH1 00061 // Pin 7 NRST NET NRST 00062 AnalogIn Ain_DriverPot (PC_0); // Pin 8 Spare Analogue in, net SAIN fitted with external pull-down 00063 AnalogIn Ain_SystemVolts (PC_1); // Pin 9 00064 AnalogIn Motor_A_Current (PC_2); // Pin 10 00065 AnalogIn Motor_B_Current (PC_3); // Pin 11 00066 // Pin 12 VSSA/VREF- NET GND 00067 // Pin 13 VDDA/VREF+ NET +3V3 00068 // Pin 14 Port_A AUL 00069 // Pin 15 Port_A AUH 00070 // Pins 16, 17 BufferedSerial pc 00071 BufferedSerial pc (PD_8, PD_9, 512, 4, NULL); // Pins 16, 17 tx, rx to pc via usb lead 00072 // Pin 18 VSS NET GND 00073 // Pin 19 VDD NET +3V3 00074 // Pin 20 Port_A AWL 00075 // Pin 21 DigitalOut led1(LED1); 00076 DigitalOut LED (PB_0); // Pin ?? as fitted to Nucleo board. Other leds use PB_7 and PB_14 00077 // Pin 22 Port_A AVL 00078 // Pin 23 Port_A AVH 00079 InterruptIn MBH2 (PD_1); // Pin ?? 00080 InterruptIn MBH3 (PD_3); // Pin ?? 00081 // Pin 26 Port_B BUL 00082 // Pin 27 Port_B BVL 00083 // Pin 28 Port_B BWL 00084 // Pin 29 Port_B BUH 00085 // Pin 30 VCAP1 00086 // Pin 31 VSS 00087 // Pin 32 VDD 00088 // Pin 33 Port_B BVH 00089 // Pin 34 Port_B BWH 00090 00091 //DigitalOut T4 (PB_14); // Pin ** 00092 //DigitalOut T3 (PB_15); // Pin ** 00093 00094 // BufferedSerial com2 pins 37 Tx, 38 Rx 00095 BufferedSerial com2 (PC_10, PC_11); // Pins 37, 38 tx, rx to XBee module 00096 FastPWM A_MAX_V_PWM (PC_8, PWM_PRESECALER_DEFAULT), // Pin 39 pwm3/3 00097 A_MAX_I_PWM (PC_9, PWM_PRESECALER_DEFAULT); // pin 40, prescaler value pwm3/4 00098 //InterruptIn MotB_Hall (PA_8); // Pin 41 00099 // Pin 41 Port_A AWH 00100 // BufferedSerial com3 pins 42 Tx, 43 Rx 00101 //InterruptIn tryseredge (PA_9); 00102 00103 BufferedSerial com3 (PC_12, PD_2); // Pins 42, 43 tx, rx to any aux module 00104 00105 // 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 ! 00106 // No. 00107 00108 // Feb 2018 Pins 44 and 45 now liberated, could use for serial or other uses 00109 //BufferedSerial extra_ser (PA_11, PA_12); // Pins 44, 45 tx, rx to XBee module 00110 DigitalOut T2 (PA_11); // Pin 44 00111 // was DigitalOut T1 (PA_12); // Pin 45 00112 00113 00114 //InterruptIn T1 (PA_12); // Pin 45 now input counting pulses from LMT01 temperature sensor 00115 // InterruptIn DOES NOT WORK ON PA_12. Boards are being made, will have to wire link PA12 to PC13 00116 //DigitalIn T1 (PA_12); 00117 ////InterruptIn T1 (PC_13); // Pin 45 now input counting pulses from LMT01 temperature sensor 00118 00119 00120 00121 // Pin 46 SWDIO 00122 // Pin 47 VSS 00123 // Pin 48 VDD 00124 // Pin 49 SWCLK 00125 00126 //Was DigitalOut T5 (PA_15); // Pin 50 00127 DigitalIn T5 (PA_15); // Pin 50 now fwd/rev from remote control box if fitted 00128 InterruptIn MAH1 (PD_4); // Pin 51 00129 InterruptIn MAH2 (PD_5); // Pin 52 00130 InterruptIn MAH3 (PD_6); // Pin 53 00131 InterruptIn MBH1 (PD_0); // Pin 54 00132 DigitalOut T6 (PB_3); // Pin 55 00133 FastPWM B_MAX_V_PWM (PE_13, PWM_PRESECALER_DEFAULT), // Pin 56 pwm3/3 00134 B_MAX_I_PWM (PE_14, PWM_PRESECALER_DEFAULT); // pin 57, prescaler value pwm3/4 00135 00136 I2C i2c (PB_9, PB_8); // Pins 58, 59 For 24LC64 eeprom 00137 // Pin 60 BOOT0 00138 00139 // Servo pins, 2 off. Configured as Input to read radio control receiver 00140 // If used as servo output, code gives pin to 'Servo' - seems to work 00141 InterruptIn Servo1_i (PF_14); // Pin 61 to read output from rc rx 00142 InterruptIn Servo2_i (PF_15); // Pin 62 to read output from rc rx 00143 00144 // Pin 63 VSS 00145 // Pin 64 VDD 00146 // SYSTEM CONSTANTS 00147
Generated on Tue Jul 19 2022 12:28:36 by 1.7.2