2018-02-09 07:53:25 +00:00
|
|
|
#pragma once
|
|
|
|
#include "stm32f1xx_hal.h"
|
|
|
|
|
|
|
|
#define R 0.27
|
|
|
|
#define P 15
|
|
|
|
#define PSI 0.02
|
|
|
|
#define V 23
|
|
|
|
|
|
|
|
#define MILLI_R (R * 1000)
|
|
|
|
#define MILLI_PSI (PSI * 1000)
|
|
|
|
#define MILLI_V (V * 1000)
|
|
|
|
|
2018-04-09 19:43:59 +00:00
|
|
|
// ################################################################################
|
|
|
|
|
2018-04-09 20:03:19 +00:00
|
|
|
#define PWM_FREQ 16000 // PWM frequency in Hz
|
|
|
|
#define DEAD_TIME 32 // PWM deadtime
|
2018-02-09 07:53:25 +00:00
|
|
|
|
2018-04-25 17:27:15 +00:00
|
|
|
#define DC_CUR_LIMIT 25 // Motor DC current limit in amps
|
2018-02-09 07:53:25 +00:00
|
|
|
|
2018-04-09 20:03:19 +00:00
|
|
|
#define BAT_LOW_LVL1 36.0 // gently beeps at this voltage level
|
|
|
|
#define BAT_LOW_LVL2 33.0 // your battery is almost empty. Charge now!
|
|
|
|
#define BAT_LOW_DEAD 30.0 // undervoltage lockout
|
|
|
|
|
2018-04-09 19:43:59 +00:00
|
|
|
// ################################################################################
|
|
|
|
|
2018-04-07 22:03:35 +00:00
|
|
|
#define DEBUG_SERIAL_USART2
|
2018-04-09 19:43:59 +00:00
|
|
|
//#define DEBUG_SERIAL_USART3
|
2018-04-09 20:03:19 +00:00
|
|
|
#define DEBUG_BAUD 115200 // UART baud rate
|
2018-04-09 19:43:59 +00:00
|
|
|
//#define DEBUG_SERIAL_SERVOTERM
|
|
|
|
#define DEBUG_SERIAL_ASCII
|
2018-02-09 07:53:25 +00:00
|
|
|
//#define DEBUG_I2C_LCD
|
2018-02-09 08:39:47 +00:00
|
|
|
|
2018-05-06 18:11:53 +00:00
|
|
|
#define TIMEOUT 5 //wrong commands before emergency off
|
|
|
|
|
2018-04-09 19:43:59 +00:00
|
|
|
// ################################################################################
|
|
|
|
|
|
|
|
// ###### CONTROL VIA RC REMOTE ######
|
2018-04-07 22:03:35 +00:00
|
|
|
//#define CONTROL_PPM // use PPM CONTROL_PPM
|
2018-04-09 19:43:59 +00:00
|
|
|
//#define PPM_NUM_CHANNELS 6 // number of PPM channels to receive
|
2018-04-07 22:03:35 +00:00
|
|
|
|
2018-04-09 19:43:59 +00:00
|
|
|
// ###### CONTROL VIA TWO POTENTIOMETERS ######
|
2018-04-07 22:03:35 +00:00
|
|
|
// #define CONTROL_ADC
|
2018-04-09 19:43:59 +00:00
|
|
|
|
|
|
|
// ###### CONTROL VIA NINTENDO NUNCHUCK ######
|
2018-04-07 22:03:35 +00:00
|
|
|
#define CONTROL_NUNCHUCK
|
|
|
|
|
2018-04-09 19:43:59 +00:00
|
|
|
// ################################################################################
|
|
|
|
|
|
|
|
// ###### DRIVING BEHAVIOR ######
|
|
|
|
#define FILTER 0.1
|
|
|
|
#define SPEED_COEFFICIENT 0.5
|
|
|
|
#define STEER_COEFFICIENT 0.5
|
|
|
|
|
|
|
|
// ###### BOBBYCAR ######
|
|
|
|
// #define FILTER 0.1
|
2018-04-09 20:03:19 +00:00
|
|
|
// #define SPEED_COEFFICIENT -1
|
2018-04-09 19:43:59 +00:00
|
|
|
// #define STEER_COEFFICIENT 0
|
|
|
|
|
2018-04-25 17:27:15 +00:00
|
|
|
// #define ADDITIONAL_CODE \
|
|
|
|
if (button1 && speedR < 300) { \
|
|
|
|
speedR = speedR * -0.2f; \
|
|
|
|
speedL = speedL * -0.2f; } \
|
|
|
|
else { \
|
|
|
|
direction = 1; } \
|
|
|
|
if (button1 && speedR > 700) { /* field weakening at high speeds */ \
|
|
|
|
weakl = speedR - 600; /* weak should never exceed 400 or 450 MAX!! */ \
|
|
|
|
weakr = speedR - 600; } \
|
|
|
|
else { \
|
|
|
|
weakl = 0; \
|
|
|
|
weakr = 0; }
|
|
|
|
|
2018-04-09 19:43:59 +00:00
|
|
|
// ###### ARMCHAIR ######
|
|
|
|
// #define FILTER 0.05
|
|
|
|
// #define SPEED_COEFFICIENT 0.5
|
2018-04-09 20:03:19 +00:00
|
|
|
// #define STEER_COEFFICIENT -0.2
|
2018-04-09 19:43:59 +00:00
|
|
|
|
2018-04-07 22:03:35 +00:00
|
|
|
// #define BEEPS_BACKWARD
|