fixed serial debug output, backward beep and low bat beeps work now together, low bat beeps can now be disabled, added inactivity timeout

This commit is contained in:
larsm
2018-07-25 12:54:13 +02:00
parent 2932480274
commit 612dce68ea
5 changed files with 280 additions and 254 deletions

View File

@@ -6,23 +6,29 @@
#define PWM_FREQ 16000 // PWM frequency in Hz
#define DEAD_TIME 32 // PWM deadtime
#define DC_CUR_LIMIT 15 // Motor DC current limit in amps. it does not disable motors, it is a soft current limit.
#define DC_CUR_LIMIT 15 // DC current limit in amps per motor. so 15 means it will draw 30A out of your battery. it does not disable motors, it is a soft current limit.
// Battery voltage calibration: connect power source. use multimeter to measure real voltage and write it to BAT_CALIB_REAL_VOLTAGE. watch UART on one of the sensor board cables. write value nr 4 to BAT_CALIB_ADC. make and flash firmware. you can verify voltage on UART debug value 5 (devide it by 100.0 to get calibrated voltage).
#define DELAY_IN_MAIN_LOOP 5 // in ms. default 5. it is independent of all the timing critical stuff. do not touch if you do not know what you are doing.
// Battery voltage calibration: connect power source. use multimeter to measure real voltage and write it to BAT_CALIB_REAL_VOLTAGE. enable DEBUG_SERIAL_USART3 and DEBUG_SERIAL_ASCII (and disconnect and disable CONTROL_NUNCHUCK) and watch UART on right sensor board cable. write value nr 5 to BAT_CALIB_ADC. make and flash firmware. you can verify voltage on UART debug value 6 (devide it by 100.0 to get calibrated voltage).
#define BAT_CALIB_REAL_VOLTAGE 42.0 // input voltage measured by multimeter
#define BAT_CALIB_ADC 1667 // adc-value measured by mainboard (value nr 4 on UART debug output)
#define BAT_NUMBER_OF_CELLS 10 // normal Hoverboard battery: 10s
#define BAT_NUMBER_OF_CELLS 12 // normal Hoverboard battery: 10s
#define BAT_LOW_LVL1_ENABLE 0 // to beep or not to beep, 1 or 0
#define BAT_LOW_LVL1 3.6 // gently beeps at this voltage level. [V/cell]
#define BAT_LOW_LVL2 3.5 // your battery is almost empty. Charge now! [V/cell]
#define BAT_LOW_DEAD 3.37 // undervoltage lockout. [V/cell]
#define BAT_LOW_LVL2_ENABLE 1 // to beep or not to beep, 1 or 0
#define BAT_LOW_LVL2 3.5 // your battery is almost empty. Charge now! [V/cell]
#define BAT_LOW_DEAD 3.37 // undervoltage lockout. [V/cell]
#define INACTIVITY_TIMEOUT 8 // minutes of not driving until poweroff. it is not very precise.
// ################################################################################
//#define DEBUG_SERIAL_USART3 // right sensor board cable, disable if I2C (nunchuck) is used!
#define DEBUG_BAUD 115200 // UART baud rate
//#define DEBUG_SERIAL_SERVOTERM
//#define DEBUG_SERIAL_ASCII // human readable output. i.e. "345;1337;0;0\n\r"
#define DEBUG_SERIAL_ASCII // "1:345 2:1337 3:0 4:0 5:0 6:0 7:0 8:0\r\n"
//#define CONTROL_SERIAL_USART2 // left sensor board cable, disable if ADC or PPM is used!
#define CONTROL_BAUD 19200 // control via usart from eg an Arduino or raspberry
@@ -40,7 +46,7 @@
//#define PPM_NUM_CHANNELS 6 // total number of PPM channels to receive, even if they are not used.
// ###### CONTROL VIA TWO POTENTIOMETERS ######
// ADC-calibration to cover the full poti-range: connect potis to left sensor board cable (0 to 3.3V), watch UART on the right sensor board cable. the first 2 values are ADC1 and ADC2. write minimum and maximum poti position-values to ADC?_MIN and ADC?_MAX.
// ADC-calibration to cover the full poti-range: connect potis to left sensor board cable (0 to 3.3V) (do NOT use the red 15V wire in the cable!). enable DEBUG_SERIAL_USART3 and DEBUG_SERIAL_ASCII (and disconnect and disable CONTROL_NUNCHUCK) and watch UART on right sensor board cable. value1 == ADC1 and value2 == ADC2. write minimum and maximum poti position-values to ADC?_MIN and ADC?_MAX.
//#define CONTROL_ADC // use ADC as input. disable DEBUG_SERIAL_USART2!
//#define ADC1_MIN 0 // min ADC1-value while poti at minimum-position (0 - 4095)
//#define ADC1_MAX 4095 // max ADC1-value while poti at maximum-position (0 - 4095)
@@ -64,7 +70,7 @@
// - weakr and weakl: field weakening for extra boost at high speed (speedR > 700 and speedL > 700). 0 to ~400
#define FILTER 0.1 // lower value == softer filter. do not use values <0.01, you will get float precision issues.
#define SPEED_COEFFICIENT 0.5 // higher value == stronger. 0.0 to 1.0
#define SPEED_COEFFICIENT 0.5 // higher value == stronger. 0.0 to ~2.0?
#define STEER_COEFFICIENT 0.5 // higher value == stronger. if you do not want any steering, set it to 0.0; 0.0 to 1.0
//#define INVERT_R_DIRECTION
//#define INVERT_L_DIRECTION
@@ -108,7 +114,7 @@ else {\
weakl = 0;\
weakr = 0;
// #define BEEPS_BACKWARD
#define BEEPS_BACKWARD 1 // 0 or 1
// ################################################################################