ADD: UVLO in config
This commit is contained in:
parent
17f497f357
commit
5a3ed507b2
14
Inc/config.h
14
Inc/config.h
|
@ -12,16 +12,20 @@
|
||||||
|
|
||||||
// ################################################################################
|
// ################################################################################
|
||||||
|
|
||||||
#define PWM_FREQ 16000 // PWM frequency in Hz
|
#define PWM_FREQ 16000 // PWM frequency in Hz
|
||||||
#define DEAD_TIME 32 // PWM deadtime
|
#define DEAD_TIME 32 // PWM deadtime
|
||||||
|
|
||||||
#define DC_CUR_LIMIT 35 // Motor DC current limit in amps
|
#define DC_CUR_LIMIT 35 // Motor DC current limit in amps
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
// ################################################################################
|
// ################################################################################
|
||||||
|
|
||||||
#define DEBUG_SERIAL_USART2
|
#define DEBUG_SERIAL_USART2
|
||||||
//#define DEBUG_SERIAL_USART3
|
//#define DEBUG_SERIAL_USART3
|
||||||
#define DEBUG_BAUD 115200 // UART baud rate
|
#define DEBUG_BAUD 115200 // UART baud rate
|
||||||
//#define DEBUG_SERIAL_SERVOTERM
|
//#define DEBUG_SERIAL_SERVOTERM
|
||||||
#define DEBUG_SERIAL_ASCII
|
#define DEBUG_SERIAL_ASCII
|
||||||
//#define DEBUG_I2C_LCD
|
//#define DEBUG_I2C_LCD
|
||||||
|
@ -47,12 +51,12 @@
|
||||||
|
|
||||||
// ###### BOBBYCAR ######
|
// ###### BOBBYCAR ######
|
||||||
// #define FILTER 0.1
|
// #define FILTER 0.1
|
||||||
// #define SPEED_COEFFICIENT 1
|
// #define SPEED_COEFFICIENT -1
|
||||||
// #define STEER_COEFFICIENT 0
|
// #define STEER_COEFFICIENT 0
|
||||||
|
|
||||||
// ###### ARMCHAIR ######
|
// ###### ARMCHAIR ######
|
||||||
// #define FILTER 0.05
|
// #define FILTER 0.05
|
||||||
// #define SPEED_COEFFICIENT 0.5
|
// #define SPEED_COEFFICIENT 0.5
|
||||||
// #define STEER_COEFFICIENT 0.2
|
// #define STEER_COEFFICIENT -0.2
|
||||||
|
|
||||||
// #define BEEPS_BACKWARD
|
// #define BEEPS_BACKWARD
|
||||||
|
|
12
Src/main.c
12
Src/main.c
|
@ -123,8 +123,8 @@ int main(void) {
|
||||||
|
|
||||||
#ifdef CONTROL_NUNCHUCK
|
#ifdef CONTROL_NUNCHUCK
|
||||||
Nunchuck_Read();
|
Nunchuck_Read();
|
||||||
cmd1 = CLAMP((nunchuck_data[0] - 127) * 10, -1000, 1000);
|
cmd1 = CLAMP((nunchuck_data[0] - 127) * 10, -1000, 1000); // y - axis. Nunchuck joystick readings range 30 - 230
|
||||||
cmd2 = CLAMP((nunchuck_data[1] - 127) * 10, -1000, 1000);
|
cmd2 = CLAMP((nunchuck_data[1] - 127) * 10, -1000, 1000); // x - axis
|
||||||
|
|
||||||
//uint8_t button1 = (uint8_t)nunchuck_data[5] & 1;
|
//uint8_t button1 = (uint8_t)nunchuck_data[5] & 1;
|
||||||
//uint8_t button2 = (uint8_t)(nunchuck_data[5] >> 1) & 1;
|
//uint8_t button2 = (uint8_t)(nunchuck_data[5] >> 1) & 1;
|
||||||
|
@ -138,7 +138,7 @@ int main(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONTROL_ADC
|
#ifdef CONTROL_ADC
|
||||||
cmd1 = CLAMP(adc_buffer.l_rx2 - 700, 0, 2350) / 2.35;
|
cmd1 = CLAMP(adc_buffer.l_rx2 - 700, 0, 2350) / 2.35; // ADC values range 0-4095, however full range of our poti only covers 650 - 3050
|
||||||
//uint8_t button1 = (uint8_t)(adc_buffer.l_tx2 > 2000);
|
//uint8_t button1 = (uint8_t)(adc_buffer.l_tx2 > 2000);
|
||||||
|
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
|
@ -185,13 +185,13 @@ int main(void) {
|
||||||
while(1) {}
|
while(1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (batteryVoltage < 36.0 && batteryVoltage > 33.0) {
|
if (batteryVoltage < BAT_LOW_LVL1 && batteryVoltage > BAT_LOW_LVL2) {
|
||||||
buzzerFreq = 5;
|
buzzerFreq = 5;
|
||||||
buzzerPattern = 8;
|
buzzerPattern = 8;
|
||||||
} else if (batteryVoltage < 33.0 && batteryVoltage > 30.0) {
|
} else if (batteryVoltage < BAT_LOW_LVL2 && batteryVoltage > BAT_LOW_DEAD) {
|
||||||
buzzerFreq = 5;
|
buzzerFreq = 5;
|
||||||
buzzerPattern = 1;
|
buzzerPattern = 1;
|
||||||
} else if (batteryVoltage < 30.0) {
|
} else if (batteryVoltage < BAT_LOW_DEAD) {
|
||||||
buzzerPattern = 0;
|
buzzerPattern = 0;
|
||||||
enable = 0;
|
enable = 0;
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
|
|
Loading…
Reference in New Issue