Skip to content

Commit 79bfbe6

Browse files
committed
FW3.28: dual throttle curves, ntc beta factor config, board file added
1 parent 73d55e5 commit 79bfbe6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1388
-33
lines changed

CHANGELOG

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
=== FW 3.28 ===
2+
* DC_CAL timeout.
3+
* Added board configuration file to avoid braking at boot.
4+
* Shorter default fault stop time.
5+
* Lower default PPM ramping time.
6+
* Configurable beta value for motor thermistor.
7+
* Individual throttle curves for acceleration and braking.
8+
19
=== FW 3.27 ===
210
* Watt hour reset bug fix
311
* Changed the way custom applications are implemented.

Makefile

+6-8
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,16 @@ PROJECT = BLDC_4_ChibiOS
9494

9595
# Imported source files and paths
9696
CHIBIOS = ChibiOS_3.0.2
97-
# Startup files.
97+
# Startup files
9898
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/startup_stm32f4xx.mk
99-
# HAL-OSAL files (optional).
99+
# HAL-OSAL files
100100
include $(CHIBIOS)/os/hal/hal.mk
101101
include $(CHIBIOS)/os/hal/ports/STM32/STM32F4xx/platform.mk
102-
include $(CHIBIOS)/os/hal/boards/ST_STM32F4_DISCOVERY/board.mk
103102
include $(CHIBIOS)/os/hal/osal/rt/osal.mk
104-
# RTOS files (optional).
103+
# RTOS files
105104
include $(CHIBIOS)/os/rt/rt.mk
106105
include $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
107-
# Other files (optional).
108-
#include $(CHIBIOS)/test/rt/test.mk
106+
# Other files
109107
include hwconf/hwconf.mk
110108
include applications/applications.mk
111109
include nrf/nrf.mk
@@ -121,9 +119,9 @@ CSRC = $(STARTUPSRC) \
121119
$(OSALSRC) \
122120
$(HALSRC) \
123121
$(PLATFORMSRC) \
124-
$(BOARDSRC) \
125122
$(CHIBIOS)/os/hal/lib/streams/chprintf.c \
126123
$(CHIBIOS)/os/various/syscalls.c \
124+
board.c \
127125
main.c \
128126
comm_usb_serial.c \
129127
irq_handlers.c \
@@ -182,7 +180,7 @@ TCPPSRC =
182180
ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
183181

184182
INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
185-
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
183+
$(HALINC) $(PLATFORMINC) \
186184
$(CHIBIOS)/os/various \
187185
$(CHIBIOS)/os/hal/lib/streams \
188186
mcconf \

appconf/appconf_default.h

+11-2
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,17 @@
7171
#ifndef APPCONF_PPM_THROTTLE_EXP
7272
#define APPCONF_PPM_THROTTLE_EXP 0.0
7373
#endif
74+
#ifndef APPCONF_PPM_THROTTLE_EXP_BRAKE
75+
#define APPCONF_PPM_THROTTLE_EXP_BRAKE 0.0
76+
#endif
7477
#ifndef APPCONF_PPM_THROTTLE_EXP_MODE
7578
#define APPCONF_PPM_THROTTLE_EXP_MODE THR_EXP_POLY
7679
#endif
7780
#ifndef APPCONF_PPM_RAMP_TIME_POS
78-
#define APPCONF_PPM_RAMP_TIME_POS 0.9
81+
#define APPCONF_PPM_RAMP_TIME_POS 0.3
7982
#endif
8083
#ifndef APPCONF_PPM_RAMP_TIME_NEG
81-
#define APPCONF_PPM_RAMP_TIME_NEG 0.3
84+
#define APPCONF_PPM_RAMP_TIME_NEG 0.1
8285
#endif
8386
#ifndef APPCONF_PPM_MULTI_ESC
8487
#define APPCONF_PPM_MULTI_ESC false
@@ -133,6 +136,9 @@
133136
#ifndef APPCONF_ADC_THROTTLE_EXP
134137
#define APPCONF_ADC_THROTTLE_EXP 0.0
135138
#endif
139+
#ifndef APPCONF_ADC_THROTTLE_EXP_BRAKE
140+
#define APPCONF_ADC_THROTTLE_EXP_BRAKE 0.0
141+
#endif
136142
#ifndef APPCONF_ADC_THROTTLE_EXP_MODE
137143
#define APPCONF_ADC_THROTTLE_EXP_MODE THR_EXP_POLY
138144
#endif
@@ -179,6 +185,9 @@
179185
#ifndef APPCONF_CHUK_THROTTLE_EXP
180186
#define APPCONF_CHUK_THROTTLE_EXP 0.0
181187
#endif
188+
#ifndef APPCONF_CHUK_THROTTLE_EXP_BRAKE
189+
#define APPCONF_CHUK_THROTTLE_EXP_BRAKE 0.0
190+
#endif
182191
#ifndef APPCONF_CHUK_THROTTLE_EXP_MODE
183192
#define APPCONF_CHUK_THROTTLE_EXP_MODE THR_EXP_POLY
184193
#endif

applications/app_adc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static THD_FUNCTION(adc_thread, arg) {
274274
utils_deadband(&pwr, config.hyst, 1.0);
275275

276276
// Apply throttle curve
277-
pwr = utils_throttle_curve(pwr, config.throttle_exp, config.throttle_exp_mode);
277+
pwr = utils_throttle_curve(pwr, config.throttle_exp, config.throttle_exp_brake, config.throttle_exp_mode);
278278

279279
// Apply ramping
280280
static systime_t last_time = 0;

applications/app_nunchuk.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static THD_FUNCTION(output_thread, arg) {
243243

244244
float out_val = app_nunchuk_get_decoded_chuk();
245245
utils_deadband(&out_val, config.hyst, 1.0);
246-
out_val = utils_throttle_curve(out_val, config.throttle_exp, config.throttle_exp_mode);
246+
out_val = utils_throttle_curve(out_val, config.throttle_exp, config.throttle_exp_brake, config.throttle_exp_mode);
247247

248248
// LEDs
249249
float x_axis = ((float)chuck_d.js_x - 128.0) / 128.0;

applications/app_ppm.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static THD_FUNCTION(ppm_thread, arg) {
177177
utils_deadband(&servo_val, config.hyst, 1.0);
178178

179179
// Apply throttle curve
180-
servo_val = utils_throttle_curve(servo_val, config.throttle_exp, config.throttle_exp_mode);
180+
servo_val = utils_throttle_curve(servo_val, config.throttle_exp, config.throttle_exp_brake, config.throttle_exp_mode);
181181

182182
// Apply ramping
183183
static systime_t last_time = 0;

applications/app_uartcomm.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ void app_uartcomm_start(void) {
141141
if (!is_running) {
142142
chThdCreateStatic(packet_process_thread_wa, sizeof(packet_process_thread_wa),
143143
NORMALPRIO, packet_process_thread, NULL);
144+
is_running = true;
144145
}
145146

146147
uartStart(&HW_UART_DEV, &uart_cfg);
@@ -173,7 +174,6 @@ static THD_FUNCTION(packet_process_thread, arg) {
173174

174175
chRegSetThreadName("uartcomm process");
175176

176-
is_running = true;
177177
process_tp = chThdGetSelfX();
178178

179179
for(;;) {

board.c

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*
2+
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
#include "hal.h"
18+
19+
#if HAL_USE_PAL || defined(__DOXYGEN__)
20+
/**
21+
* @brief PAL setup.
22+
* @details Digital I/O ports static configuration as defined in @p board.h.
23+
* This variable is used by the HAL when initializing the PAL driver.
24+
*/
25+
const PALConfig pal_default_config = {
26+
#if STM32_HAS_GPIOA
27+
{VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR,
28+
VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH},
29+
#endif
30+
#if STM32_HAS_GPIOB
31+
{VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR,
32+
VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH},
33+
#endif
34+
#if STM32_HAS_GPIOC
35+
{VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR,
36+
VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH},
37+
#endif
38+
#if STM32_HAS_GPIOD
39+
{VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR,
40+
VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH},
41+
#endif
42+
#if STM32_HAS_GPIOE
43+
{VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR,
44+
VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH},
45+
#endif
46+
#if STM32_HAS_GPIOF
47+
{VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR,
48+
VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH},
49+
#endif
50+
#if STM32_HAS_GPIOG
51+
{VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR,
52+
VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH},
53+
#endif
54+
#if STM32_HAS_GPIOH
55+
{VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR,
56+
VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH},
57+
#endif
58+
#if STM32_HAS_GPIOI
59+
{VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR,
60+
VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRH}
61+
#endif
62+
};
63+
#endif
64+
65+
/**
66+
* @brief Early initialization code.
67+
* @details This initialization must be performed just after stack setup
68+
* and before any other initialization.
69+
*/
70+
void __early_init(void) {
71+
72+
stm32_clock_init();
73+
}
74+
75+
#if HAL_USE_SDC || defined(__DOXYGEN__)
76+
/**
77+
* @brief SDC card detection.
78+
*/
79+
bool sdc_lld_is_card_inserted(SDCDriver *sdcp) {
80+
81+
(void)sdcp;
82+
/* TODO: Fill the implementation.*/
83+
return true;
84+
}
85+
86+
/**
87+
* @brief SDC card write protection detection.
88+
*/
89+
bool sdc_lld_is_write_protected(SDCDriver *sdcp) {
90+
91+
(void)sdcp;
92+
/* TODO: Fill the implementation.*/
93+
return false;
94+
}
95+
#endif /* HAL_USE_SDC */
96+
97+
#if HAL_USE_MMC_SPI || defined(__DOXYGEN__)
98+
/**
99+
* @brief MMC_SPI card detection.
100+
*/
101+
bool mmc_lld_is_card_inserted(MMCDriver *mmcp) {
102+
103+
(void)mmcp;
104+
/* TODO: Fill the implementation.*/
105+
return true;
106+
}
107+
108+
/**
109+
* @brief MMC_SPI card write protection detection.
110+
*/
111+
bool mmc_lld_is_write_protected(MMCDriver *mmcp) {
112+
113+
(void)mmcp;
114+
/* TODO: Fill the implementation.*/
115+
return false;
116+
}
117+
#endif
118+
119+
/**
120+
* @brief Board-specific initialization code.
121+
* @todo Add your board-specific code, if any.
122+
*/
123+
void boardInit(void) {
124+
}

0 commit comments

Comments
 (0)