Skip to content

Commit 602db74

Browse files
committed
FW3.59. Many updates, see changelog for details
1 parent 66ae92e commit 602db74

Some content is hidden

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

82 files changed

+11321
-180
lines changed

CHANGELOG

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
=== FW 3.59 ===
2+
* Added more data to MOTE_PACKET_ALIVE.
3+
* Added app template.
4+
* Added function to unregister terminal callbacks.
5+
* Added BMI160 support.
6+
* Added support for the VESC HD.
7+
* Added support for SWD programming permanent NRF.
8+
* Encoder SW SPI fix.
9+
* Slightly faster boot.
10+
* Moved custom HW and APP configurations to conf_general.h.
11+
* Added support for passing HW and APP default configuration as make arguments.
12+
* Added SW shutdown support.
13+
* Added command to erase bootloader.
14+
* Added function to stop IMU threads, so that IMUs can be switched during runtime.
15+
* Only generate encoder fault when the ERPM is low enough to use the encoder.
16+
* Added many IMU and AHRS settings to appconf.
17+
* Re-initialize IMU when appconf is written.
18+
* Added imu_gyro_info terminal command.
19+
120
=== FW 3.58 ===
221
* Set motor to FOC mode after successful FOC detection instead of the default type for the hardware.
322
* APP_ADC: Do not send brake command over CAN if config.multi_esc is not set.

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ CSRC = $(STARTUPSRC) \
155155
timer.c \
156156
i2c_bb.c \
157157
virtual_motor.c \
158+
shutdown.c \
158159
$(HWSRC) \
159160
$(APPSRC) \
160161
$(NRFSRC) \

appconf/appconf_default.h

+69-4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
#ifndef APPCONF_PERMANENT_UART_ENABLED
5252
#define APPCONF_PERMANENT_UART_ENABLED true
5353
#endif
54+
#ifndef APPCONF_SHUTDOWN_MODE
55+
#define APPCONF_SHUTDOWN_MODE SHUTDOWN_MODE_OFF_AFTER_30M
56+
#endif
5457

5558
// The default app is UART in case the UART port is used for
5659
// firmware updates.
@@ -93,10 +96,10 @@
9396
#define APPCONF_PPM_THROTTLE_EXP_MODE THR_EXP_POLY
9497
#endif
9598
#ifndef APPCONF_PPM_RAMP_TIME_POS
96-
#define APPCONF_PPM_RAMP_TIME_POS 0.3
99+
#define APPCONF_PPM_RAMP_TIME_POS 0.4
97100
#endif
98101
#ifndef APPCONF_PPM_RAMP_TIME_NEG
99-
#define APPCONF_PPM_RAMP_TIME_NEG 0.1
102+
#define APPCONF_PPM_RAMP_TIME_NEG 0.2
100103
#endif
101104
#ifndef APPCONF_PPM_MULTI_ESC
102105
#define APPCONF_PPM_MULTI_ESC true
@@ -192,10 +195,10 @@
192195
#define APPCONF_CHUK_HYST 0.15
193196
#endif
194197
#ifndef APPCONF_CHUK_RAMP_TIME_POS
195-
#define APPCONF_CHUK_RAMP_TIME_POS 0.9
198+
#define APPCONF_CHUK_RAMP_TIME_POS 0.4
196199
#endif
197200
#ifndef APPCONF_CHUK_RAMP_TIME_NEG
198-
#define APPCONF_CHUK_RAMP_TIME_NEG 0.3
201+
#define APPCONF_CHUK_RAMP_TIME_NEG 0.2
199202
#endif
200203
#ifndef APPCONF_STICK_ERPM_PER_S_IN_CC
201204
#define APPCONF_STICK_ERPM_PER_S_IN_CC 3000.0
@@ -251,4 +254,66 @@
251254
#define APPCONF_NRF_SEND_CRC_ACK true
252255
#endif
253256

257+
// IMU
258+
#ifndef APPCONF_IMU_TYPE
259+
#define APPCONF_IMU_TYPE IMU_TYPE_INTERNAL
260+
#endif
261+
#ifndef APPCONF_IMU_AHRS_MODE
262+
#define APPCONF_IMU_AHRS_MODE AHRS_MODE_MADGWICK
263+
#endif
264+
#ifndef APPCONF_IMU_SAMPLE_RATE_HZ
265+
#define APPCONF_IMU_SAMPLE_RATE_HZ 200
266+
#endif
267+
#ifndef APPCONF_IMU_ACCEL_CONFIDENCE_DECAY
268+
#define APPCONF_IMU_ACCEL_CONFIDENCE_DECAY 1.0
269+
#endif
270+
#ifndef APPCONF_IMU_MAHONY_KP
271+
#define APPCONF_IMU_MAHONY_KP 0.3
272+
#endif
273+
#ifndef APPCONF_IMU_MAHONY_KI
274+
#define APPCONF_IMU_MAHONY_KI 0.0
275+
#endif
276+
#ifndef APPCONF_IMU_MADGWICK_BETA
277+
#define APPCONF_IMU_MADGWICK_BETA 0.1
278+
#endif
279+
#ifndef APPCONF_IMU_ROT_ROLL
280+
#define APPCONF_IMU_ROT_ROLL 0.0
281+
#endif
282+
#ifndef APPCONF_IMU_ROT_PITCH
283+
#define APPCONF_IMU_ROT_PITCH 0.0
284+
#endif
285+
#ifndef APPCONF_IMU_ROT_YAW
286+
#define APPCONF_IMU_ROT_YAW 0.0
287+
#endif
288+
#ifndef APPCONF_IMU_A_OFFSET_0
289+
#define APPCONF_IMU_A_OFFSET_0 0.0
290+
#endif
291+
#ifndef APPCONF_IMU_A_OFFSET_1
292+
#define APPCONF_IMU_A_OFFSET_1 0.0
293+
#endif
294+
#ifndef APPCONF_IMU_A_OFFSET_2
295+
#define APPCONF_IMU_A_OFFSET_2 0.0
296+
#endif
297+
#ifndef APPCONF_IMU_G_OFFSET_0
298+
#define APPCONF_IMU_G_OFFSET_0 0.0
299+
#endif
300+
#ifndef APPCONF_IMU_G_OFFSET_1
301+
#define APPCONF_IMU_G_OFFSET_1 0.0
302+
#endif
303+
#ifndef APPCONF_IMU_G_OFFSET_2
304+
#define APPCONF_IMU_G_OFFSET_2 0.0
305+
#endif
306+
#ifndef APPCONF_IMU_G_OFFSET_COMP_FACT_0
307+
#define APPCONF_IMU_G_OFFSET_COMP_FACT_0 0.0
308+
#endif
309+
#ifndef APPCONF_IMU_G_OFFSET_COMP_FACT_1
310+
#define APPCONF_IMU_G_OFFSET_COMP_FACT_1 0.0
311+
#endif
312+
#ifndef APPCONF_IMU_G_OFFSET_COMP_FACT_2
313+
#define APPCONF_IMU_G_OFFSET_COMP_FACT_2 0.0
314+
#endif
315+
#ifndef APPCONF_IMU_G_OFFSET_COMP_CLAMP
316+
#define APPCONF_IMU_G_OFFSET_COMP_CLAMP 5.0
317+
#endif
318+
254319
#endif /* APPCONF_DEFAULT_H_ */

applications/app.c

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "nrf_driver.h"
2525
#include "rfhelp.h"
2626
#include "comm_can.h"
27+
#include "imu.h"
2728

2829
// Private variables
2930
static app_configuration appconf;
@@ -64,6 +65,8 @@ void app_set_configuration(app_configuration *conf) {
6465
app_custom_stop();
6566
#endif
6667

68+
imu_init(&conf->imu_conf);
69+
6770
switch (appconf.app_to_use) {
6871
case APP_PPM:
6972
app_ppm_start();

applications/app_custom_template.c

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/*
2+
Copyright 2019 Benjamin Vedder [email protected]
3+
4+
This file is part of the VESC firmware.
5+
6+
The VESC firmware is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
The VESC firmware is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#include "app.h"
21+
#include "ch.h"
22+
#include "hal.h"
23+
24+
// Some useful includes
25+
#include "mc_interface.h"
26+
#include "utils.h"
27+
#include "encoder.h"
28+
#include "terminal.h"
29+
#include "comm_can.h"
30+
#include "hw.h"
31+
#include "commands.h"
32+
33+
#include <math.h>
34+
#include <string.h>
35+
#include <stdio.h>
36+
37+
// Threads
38+
static THD_FUNCTION(my_thread, arg);
39+
static THD_WORKING_AREA(my_thread_wa, 2048);
40+
41+
// Private functions
42+
static void pwm_callback(void);
43+
static void terminal_test(int argc, const char **argv);
44+
45+
// Private variables
46+
static volatile bool stop_now = true;
47+
static volatile bool is_running = false;
48+
49+
// Called when the custom application is started. Start our
50+
// threads here and set up callbacks.
51+
void app_custom_start(void) {
52+
mc_interface_set_pwm_callback(pwm_callback);
53+
54+
stop_now = false;
55+
chThdCreateStatic(my_thread_wa, sizeof(my_thread_wa),
56+
NORMALPRIO, my_thread, NULL);
57+
58+
// Terminal commands for the VESC Tool terminal can be registered.
59+
terminal_register_command_callback(
60+
"custom_cmd",
61+
"Print the number d",
62+
"[d]",
63+
terminal_test);
64+
}
65+
66+
// Called when the custom application is stopped. Stop our threads
67+
// and release callbacks.
68+
void app_custom_stop(void) {
69+
mc_interface_set_pwm_callback(0);
70+
terminal_unregister_callback(terminal_test);
71+
72+
stop_now = true;
73+
while (is_running) {
74+
chThdSleepMilliseconds(1);
75+
}
76+
}
77+
78+
void app_custom_configure(app_configuration *conf) {
79+
(void)conf;
80+
}
81+
82+
static THD_FUNCTION(my_thread, arg) {
83+
(void)arg;
84+
85+
chRegSetThreadName("App Custom");
86+
87+
is_running = true;
88+
89+
for(;;) {
90+
// Check if it is time to stop.
91+
if (stop_now) {
92+
is_running = false;
93+
return;
94+
}
95+
96+
// Run your logic here. A lot of functionality is available in mc_interface.h.
97+
98+
chThdSleepMicroseconds(10);
99+
}
100+
}
101+
102+
static void pwm_callback(void) {
103+
// Called for every control iteration in interrupt context.
104+
}
105+
106+
// Callback function for the terminal command with arguments.
107+
static void terminal_test(int argc, const char **argv) {
108+
if (argc == 2) {
109+
int d = -1;
110+
sscanf(argv[1], "%d", &d);
111+
112+
commands_printf("You have entered %d", d);
113+
114+
// For example, read the ADC inputs on the COMM header.
115+
commands_printf("ADC1: %.2f V ADC2: %.2f V",
116+
(double)ADC_VOLTS(ADC_IND_EXT), (double)ADC_VOLTS(ADC_IND_EXT2));
117+
} else {
118+
commands_printf("This command requires one argument.\n");
119+
}
120+
}

blackmagic/bm_if.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,8 @@ void bm_change_swd_pins(stm32_gpio_t *swdio_port, int swdio_pin,
513513
bm_set_enabled(false);
514514
platform_swdio_port = swdio_port;
515515
platform_swdio_pin = swdio_pin;
516-
platform_swdio_port = swclk_port;
517-
platform_swdio_pin = swclk_pin;
516+
platform_swclk_port = swclk_port;
517+
platform_swclk_pin = swclk_pin;
518518
}
519519

520520
/**
@@ -524,6 +524,6 @@ void bm_default_swd_pins(void) {
524524
bm_set_enabled(false);
525525
platform_swdio_port = SWDIO_PORT_DEFAULT;
526526
platform_swdio_pin = SWDIO_PIN_DEFAULT;
527-
platform_swdio_port = SWCLK_PORT_DEFAULT;
528-
platform_swdio_pin = SWCLK_PIN_DEFAULT;
527+
platform_swclk_port = SWCLK_PORT_DEFAULT;
528+
platform_swclk_pin = SWCLK_PIN_DEFAULT;
529529
}
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

build_all/46_o_47/VESC_0005ohm.bin

0 Bytes
Binary file not shown.

build_all/46_o_47/VESC_33k.bin

0 Bytes
Binary file not shown.

build_all/46_o_47/VESC_default.bin

0 Bytes
Binary file not shown.

build_all/46_o_47/VESC_servoout.bin

0 Bytes
Binary file not shown.

build_all/46_o_47/VESC_ws2811.bin

0 Bytes
Binary file not shown.

build_all/46_o_47/VESC_ws2811_33k.bin

0 Bytes
Binary file not shown.

build_all/48/VESC_0005ohm.bin

0 Bytes
Binary file not shown.

build_all/48/VESC_default.bin

0 Bytes
Binary file not shown.

build_all/48/VESC_servoout.bin

0 Bytes
Binary file not shown.

build_all/48/VESC_ws2811.bin

0 Bytes
Binary file not shown.

build_all/60/VESC_default.bin

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

build_all/60/VESC_servoout.bin

0 Bytes
Binary file not shown.

build_all/60/VESC_ws2811.bin

0 Bytes
Binary file not shown.

build_all/75_300/VESC_default.bin

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

build_all/75_300/VESC_servoout.bin

0 Bytes
Binary file not shown.

build_all/75_300/VESC_ws2811.bin

0 Bytes
Binary file not shown.

build_all/75_300_R2/VESC_default.bin

0 Bytes
Binary file not shown.
Binary file not shown.

build_all/75_300_R2/VESC_servoout.bin

0 Bytes
Binary file not shown.

build_all/75_300_R2/VESC_ws2811.bin

0 Bytes
Binary file not shown.

build_all/AXIOM/VESC_default.bin

0 Bytes
Binary file not shown.

build_all/DAS_RS/VESC_default.bin

0 Bytes
Binary file not shown.

build_all/HD/VESC_default.bin

384 KB
Binary file not shown.
384 KB
Binary file not shown.

build_all/HD/VESC_servoout.bin

384 KB
Binary file not shown.

build_all/HD/VESC_ws2811.bin

384 KB
Binary file not shown.

build_all/UAVC_OMEGA/VESC_default.bin

384 KB
Binary file not shown.

build_all/rebuild_all

+55
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,58 @@ cd $FWPATH
272272
make clean
273273
cd $DIR
274274

275+
#################### HW UAVC_OMEGA ########################
276+
277+
COPYDIR=UAVC_OMEGA
278+
rm -f $COPYDIR/*
279+
280+
# default
281+
cd $FWPATH
282+
touch conf_general.h
283+
make -j8 build_args='-DHW_SOURCE=\"hw_uavc_omega.c\" -DHW_HEADER=\"hw_uavc_omega.h\"' USE_VERBOSE_COMPILE=no
284+
cd $DIR
285+
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_default.bin
286+
287+
# Clean
288+
cd $FWPATH
289+
make clean
290+
cd $DIR
291+
292+
#################### HW HD ########################
293+
294+
COPYDIR=HD
295+
rm -f $COPYDIR/*
296+
297+
# default
298+
cd $FWPATH
299+
touch conf_general.h
300+
make -j8 build_args='-DHW_SOURCE=\"hw_hd.c\" -DHW_HEADER=\"hw_hd.h\"' USE_VERBOSE_COMPILE=no
301+
cd $DIR
302+
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_default.bin
303+
304+
# default with HW limits disables
305+
cd $FWPATH
306+
touch conf_general.h
307+
make -j8 build_args='-DDISABLE_HW_LIMITS -DHW_SOURCE=\"hw_hd.c\" -DHW_HEADER=\"hw_hd.h\"' USE_VERBOSE_COMPILE=no
308+
cd $DIR
309+
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_default_no_hw_limits.bin
310+
311+
# ws2811
312+
cd $FWPATH
313+
touch conf_general.h
314+
make -j8 build_args='-DWS2811_ENABLE=1 -DHW_SOURCE=\"hw_hd.c\" -DHW_HEADER=\"hw_hd.h\"' USE_VERBOSE_COMPILE=no
315+
cd $DIR
316+
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_ws2811.bin
317+
318+
# servoout
319+
cd $FWPATH
320+
touch conf_general.h
321+
make -j8 build_args='-DSERVO_OUT_ENABLE=1 -DHW_SOURCE=\"hw_hd.c\" -DHW_HEADER=\"hw_hd.h\"' USE_VERBOSE_COMPILE=no
322+
cd $DIR
323+
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_servoout.bin
324+
325+
# Clean
326+
cd $FWPATH
327+
make clean
328+
cd $DIR
329+

0 commit comments

Comments
 (0)