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: F401RE.h
- Revision:
- 11:bfb73f083009
- Parent:
- 10:e40d8724268a
- Child:
- 12:d1d21a2941ef
--- a/F401RE.h Tue Jan 15 09:03:57 2019 +0000 +++ b/F401RE.h Sat Jan 19 11:45:01 2019 +0000 @@ -4,11 +4,9 @@ // Problem - Appears to conflict with serial port used for comms with controller // Earlier efforts to use 'Servo' ports as 'you choose' between I/O failed as pins not capable of use as 'InterruptIn' -// Experiment disabling RC inputs to see if clearing serial conflict is possible +// CORRECTION Comms problem with Touch Screen was insufficient pull-up on STM3_ESC opto. Change R12 from 1k to 470R -//#define RC1IN -//#define RC2IN - +// Experiment disabling RC inputs to see if clearing serial conflict is possible // Port A -> MotorA, Port B -> MotorB @@ -67,8 +65,8 @@ 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); +//PortOut MotA (PortA, PORT_A_MASK); // Activate output ports to motor drivers +//PortOut MotB (PortB, PORT_B_MASK); // Pin 1 VBAT NET +3V3 @@ -76,13 +74,6 @@ 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 -#ifdef RC1IN -InterruptIn RC_1_in (PC_14); //New Dec 2018 tryiing to find pins to use for servo in -#endif -#ifdef RC2IN -InterruptIn RC_2_in (PC_15); //Yes, PC_14 and PC_15 do work -#endif - // Pin 3 PC14-OSC32_IN NET O32I Xtal chucked off these pins, now needed for RC inputs // Pin 4 PC15-OSC32_OUT NET O32O // Pin 5 PH0-OSC_IN NET PH1 @@ -90,8 +81,10 @@ // Pin 7 NRST NET NRST AnalogIn Ain_DriverPot (PC_0); // Pin 8 Spare Analogue in, net SAIN fitted with external pull-down AnalogIn Ain_SystemVolts (PC_1); // Pin 9 -AnalogIn Motor_A_Current (PC_2); // Pin 10 -AnalogIn Motor_B_Current (PC_3); // Pin 11 +#define MOT_A_I_ADC PC_2 +#define MOT_B_I_ADC PC_3 +//AnalogIn Motor_A_Current (PC_2); // Pin 10 +//AnalogIn Motor_B_Current (PC_3); // Pin 11 // Pin 12 VSSA/VREF- NET GND // Pin 13 VDDA/VREF+ NET +3V3 // Pin 14 Port_A AUL @@ -105,8 +98,10 @@ DigitalOut LED (PA_5); // Pin 21 // Pin 22 Port_A AVL // Pin 23 Port_A AVH -InterruptIn MBH2 (PC_4); // Pin 24 -InterruptIn MBH3 (PC_5); // Pin 25 +//InterruptIn MBH2 (PC_4); // Pin 24 +//InterruptIn MBH3 (PC_5); // Pin 25 +#define _MBH2 PC_4 +#define _MBH3 PC_5 // Pin 26 Port_B BUL // Pin 27 Port_B BVL // Pin 28 Port_B BWL @@ -119,9 +114,11 @@ DigitalOut T4 (PB_14); // Pin 35 DigitalOut T3 (PB_15); // Pin 36 // 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, PWM_PRESECALER_DEFAULT), // Pin 39 pwm3/3 - A_MAX_I_PWM (PC_9, PWM_PRESECALER_DEFAULT); // pin 40, prescaler value pwm3/4 +BufferedSerial com2 (PC_6, PC_7); // Pins 37, 38 tx, rx to Touch Screen Controller +#define APWMV PC_8 +#define APWMI PC_9 +//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 @@ -150,13 +147,19 @@ //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 (PC_10); // Pin 51 +//InterruptIn MAH2 (PC_11); // Pin 52 +//InterruptIn MAH3 (PC_12); // Pin 53 +#define _MAH1 PC_10 +#define _MAH2 PC_11 +#define _MAH3 PC_12 +//InterruptIn MBH1 (PD_2); // Pin 54 +#define _MBH1 PD_2 DigitalOut T6 (PB_3); // Pin 55 -FastPWM B_MAX_V_PWM (PB_4, PWM_PRESECALER_DEFAULT), // Pin 56 pwm3/3 - B_MAX_I_PWM (PB_5, PWM_PRESECALER_DEFAULT); // pin 57, prescaler value pwm3/4 +#define BPWMV PB_4 +#define BPWMI PB_5 +//FastPWM B_MAX_V_PWM (PB_4, PWM_PRESECALER_DEFAULT), // Pin 56 pwm3/3 +// B_MAX_I_PWM (PB_5, PWM_PRESECALER_DEFAULT); // pin 57, prescaler value pwm3/4 I2C i2c (PB_7, PB_6); // Pins 58, 59 For 24LC64 eeprom // Pin 60 BOOT0 @@ -175,4 +178,9 @@ // Pin 63 VSS // Pin 64 VDD // SYSTEM CONSTANTS +// December 2018 ** NEED TO PROVE SERVO OUT WORKS ** YES, DONE. + Servo Servo1 (PB_8) ; +// Servos[0] = & Servo1; + Servo Servo2 (PB_9) ; +// Servos[1] = & Servo2;