Skip to content

Commit 23e6192

Browse files
committed
FW upload compression support, TS5700N8501 support
1 parent 3789c1a commit 23e6192

Some content is hidden

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

72 files changed

+392
-51
lines changed

CHANGELOG

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
=== FW 3.63 ===
2+
* NRF remote power meter is now unaffected by temperature decrease and speed limits.
3+
* Added LZO compression support to firmware upload, making firmware updates 30% - 50% faster.
4+
* Added LZO compression support to SWD upload.
5+
* Made serial interrupts priority higher than PWM so that higher speed UART is possible.
6+
* Added support for TS5700N8501 encoder (via COMM port).
7+
* Better observer gain calculation.
8+
19
=== FW 3.62 ===
210
* Added COMM_BM_MEM_READ.
311
* Merged EUC app (experimental).

applications/app_custom_template.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "comm_can.h"
3030
#include "hw.h"
3131
#include "commands.h"
32+
#include "timeout.h"
3233

3334
#include <math.h>
3435
#include <string.h>
@@ -109,9 +110,11 @@ static THD_FUNCTION(my_thread, arg) {
109110
return;
110111
}
111112

113+
timeout_reset(); // Reset timeout if everything is OK.
114+
112115
// Run your logic here. A lot of functionality is available in mc_interface.h.
113116

114-
chThdSleepMicroseconds(10);
117+
chThdSleepMilliseconds(10);
115118
}
116119
}
117120

applications/app_uartcomm.c

+15-12
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,12 @@ void app_uartcomm_start_permanent(void) {
129129
}
130130

131131
void app_uartcomm_stop(void) {
132-
sdStop(&HW_UART_DEV);
133-
palSetPadMode(HW_UART_TX_PORT, HW_UART_TX_PIN, PAL_MODE_INPUT_PULLUP);
134-
palSetPadMode(HW_UART_RX_PORT, HW_UART_RX_PIN, PAL_MODE_INPUT_PULLUP);
135-
uart_is_running = false;
132+
if (uart_is_running) {
133+
sdStop(&HW_UART_DEV);
134+
palSetPadMode(HW_UART_TX_PORT, HW_UART_TX_PIN, PAL_MODE_INPUT_PULLUP);
135+
palSetPadMode(HW_UART_RX_PORT, HW_UART_RX_PIN, PAL_MODE_INPUT_PULLUP);
136+
uart_is_running = false;
137+
}
136138

137139
// Notice that the processing thread is kept running in case this call is made from it.
138140
}
@@ -151,9 +153,8 @@ void app_uartcomm_send_packet(unsigned char *data, unsigned int len) {
151153
void app_uartcomm_configure(uint32_t baudrate, bool permanent_enabled) {
152154
uart_cfg.speed = baudrate;
153155

154-
if (thread_is_running) {
156+
if (thread_is_running && uart_is_running) {
155157
sdStart(&HW_UART_DEV, &uart_cfg);
156-
uart_is_running = true;
157158
}
158159

159160
#ifdef HW_UART_P_DEV
@@ -193,17 +194,19 @@ static THD_FUNCTION(packet_process_thread, arg) {
193194
while (rx) {
194195
rx = false;
195196

196-
msg_t res = sdGetTimeout(&HW_UART_DEV, TIME_IMMEDIATE);
197-
if (res != MSG_TIMEOUT) {
197+
if (uart_is_running) {
198+
msg_t res = sdGetTimeout(&HW_UART_DEV, TIME_IMMEDIATE);
199+
if (res != MSG_TIMEOUT) {
198200
#ifdef HW_UART_P_DEV
199-
from_p_uart = false;
201+
from_p_uart = false;
200202
#endif
201-
packet_process_byte(res, PACKET_HANDLER);
202-
rx = true;
203+
packet_process_byte(res, PACKET_HANDLER);
204+
rx = true;
205+
}
203206
}
204207

205208
#ifdef HW_UART_P_DEV
206-
res = sdGetTimeout(&HW_UART_P_DEV, TIME_IMMEDIATE);
209+
msg_t res = sdGetTimeout(&HW_UART_P_DEV, TIME_IMMEDIATE);
207210
if (res != MSG_TIMEOUT) {
208211
from_p_uart = true;
209212
packet_process_byte(res, PACKET_HANDLER_P);
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/A200S_V21/VESC_default.bin

0 Bytes
Binary file not shown.

build_all/A200S_V22/VESC_default.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

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

build_all/HD/VESC_servoout.bin

0 Bytes
Binary file not shown.

build_all/HD/VESC_ws2811.bin

0 Bytes
Binary file not shown.

build_all/UAVC_OMEGA/VESC_default.bin

0 Bytes
Binary file not shown.

chconf.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#define _CHCONF_H_
3030

3131
#define CHPRINTF_USE_FLOAT TRUE
32-
#define CORTEX_SIMPLIFIED_PRIORITY FALSE
32+
#define CORTEX_SIMPLIFIED_PRIORITY TRUE
3333
#define PORT_IDLE_THREAD_STACK_SIZE 64
3434
#define PORT_INT_REQUIRED_STACK 128
3535

commands.c

+35-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#if HAS_BLACKMAGIC
4646
#include "bm_if.h"
4747
#endif
48+
#include "minilzo.h"
4849

4950
#include <math.h>
5051
#include <string.h>
@@ -222,16 +223,39 @@ void commands_process_packet(unsigned char *data, unsigned int len,
222223
reply_func(send_buffer, ind);
223224
} break;
224225

226+
case COMM_WRITE_NEW_APP_DATA_ALL_CAN_LZO:
225227
case COMM_WRITE_NEW_APP_DATA_ALL_CAN:
228+
if (packet_id == COMM_WRITE_NEW_APP_DATA_ALL_CAN_LZO) {
229+
chMtxLock(&send_buffer_mutex);
230+
memcpy(send_buffer_global, data + 6, len - 6);
231+
int32_t ind = 4;
232+
lzo_uint decompressed_len = buffer_get_uint16(data, &ind);
233+
lzo1x_decompress_safe(send_buffer_global, len - 6, data + 4, &decompressed_len, NULL);
234+
chMtxUnlock(&send_buffer_mutex);
235+
len = decompressed_len + 4;
236+
}
237+
226238
if (nrf_driver_ext_nrf_running()) {
227239
nrf_driver_pause(2000);
228240
}
229241

230242
data[-1] = COMM_WRITE_NEW_APP_DATA;
243+
231244
comm_can_send_buffer(255, data - 1, len + 1, 2);
232245
/* Falls through. */
233246
/* no break */
247+
case COMM_WRITE_NEW_APP_DATA_LZO:
234248
case COMM_WRITE_NEW_APP_DATA: {
249+
if (packet_id == COMM_WRITE_NEW_APP_DATA_LZO) {
250+
chMtxLock(&send_buffer_mutex);
251+
memcpy(send_buffer_global, data + 6, len - 6);
252+
int32_t ind = 4;
253+
lzo_uint decompressed_len = buffer_get_uint16(data, &ind);
254+
lzo1x_decompress_safe(send_buffer_global, len - 6, data + 4, &decompressed_len, NULL);
255+
chMtxUnlock(&send_buffer_mutex);
256+
len = decompressed_len + 4;
257+
}
258+
235259
int32_t ind = 0;
236260
uint32_t new_app_offset = buffer_get_uint32(data, &ind);
237261

@@ -948,6 +972,7 @@ void commands_process_packet(unsigned char *data, unsigned int len,
948972
case COMM_PING_CAN:
949973
case COMM_BM_CONNECT:
950974
case COMM_BM_ERASE_FLASH_ALL:
975+
case COMM_BM_WRITE_FLASH_LZO:
951976
case COMM_BM_WRITE_FLASH:
952977
case COMM_BM_REBOOT:
953978
case COMM_BM_DISCONNECT:
@@ -1162,7 +1187,7 @@ static THD_FUNCTION(blocking_thread, arg) {
11621187

11631188
COMM_PACKET_ID packet_id;
11641189
static mc_configuration mcconf, mcconf_old;
1165-
static uint8_t send_buffer[384];
1190+
static uint8_t send_buffer[512];
11661191

11671192
packet_id = data[0];
11681193
data++;
@@ -1410,7 +1435,16 @@ static THD_FUNCTION(blocking_thread, arg) {
14101435
}
14111436
} break;
14121437

1438+
case COMM_BM_WRITE_FLASH_LZO:
14131439
case COMM_BM_WRITE_FLASH: {
1440+
if (packet_id == COMM_BM_WRITE_FLASH_LZO) {
1441+
memcpy(send_buffer, data + 6, len - 6);
1442+
int32_t ind = 4;
1443+
lzo_uint decompressed_len = buffer_get_uint16(data, &ind);
1444+
lzo1x_decompress_safe(send_buffer, len - 6, data + 4, &decompressed_len, NULL);
1445+
len = decompressed_len + 4;
1446+
}
1447+
14141448
int32_t ind = 0;
14151449
uint32_t addr = buffer_get_uint32(data, &ind);
14161450

conf_general.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,8 @@ bool conf_general_measure_flux_linkage_openloop(float current, float duty,
798798
const int max_time = 15000;
799799

800800
while (fabsf(mc_interface_get_duty_cycle_now()) < duty) {
801-
mcpwm_foc_set_openloop(current, mcconf.m_invert_direction ? -rpm_now : rpm_now);
802801
rpm_now += erpm_per_sec / 1000.0;
802+
mcpwm_foc_set_openloop(current, mcconf.m_invert_direction ? -rpm_now : rpm_now);
803803

804804
chThdSleepMilliseconds(1);
805805
cnt++;
@@ -841,13 +841,13 @@ bool conf_general_measure_flux_linkage_openloop(float current, float duty,
841841
float id_avg = 0.0;
842842
float samples2 = 0.0;
843843

844-
for (int i = 0;i < 1000;i++) {
844+
for (int i = 0;i < 30000;i++) {
845845
vq_avg += mcpwm_foc_get_vq();
846846
vd_avg += mcpwm_foc_get_vd();
847847
iq_avg += mcpwm_foc_get_iq();
848848
id_avg += mcpwm_foc_get_id();
849849
samples2 += 1.0;
850-
chThdSleepMilliseconds(1);
850+
chThdSleep(1);
851851
}
852852

853853
vq_avg /= samples2;
@@ -1131,7 +1131,7 @@ int conf_general_detect_apply_all_foc(float max_power_loss,
11311131
float bw = 1.0 / (tc * 1e-6);
11321132
float kp = l * bw;
11331133
float ki = r * bw;
1134-
float gain = 0.001 / (lambda * lambda);
1134+
float gain = (0.00001 / r) / (lambda * lambda);
11351135

11361136
mcconf_old.motor_type = MOTOR_TYPE_FOC;
11371137
mcconf_old.foc_motor_r = r;

conf_general.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
// Firmware version
2424
#define FW_VERSION_MAJOR 3
25-
#define FW_VERSION_MINOR 62
25+
#define FW_VERSION_MINOR 63
2626

2727
#include "datatypes.h"
2828

@@ -151,14 +151,15 @@
151151
//#include "appconf_custom.h"
152152
//#include "appconf_ellwee.h"
153153

154-
#include "hw.h"
155-
#include "mcconf_default.h"
156-
#include "appconf_default.h"
157-
158154
/*
159155
* Set APP_CUSTOM_TO_USE to the name of the main C file of the custom application.
160156
*/
161157
//#define APP_CUSTOM_TO_USE "app_custom_template.c"
158+
//#include "app_erockit_conf.h"
159+
160+
#include "hw.h"
161+
#include "mcconf_default.h"
162+
#include "appconf_default.h"
162163

163164
/*
164165
* Enable blackmagic probe output on SWD port

confgenerator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <stdbool.h>
99

1010
// Constants
11-
#define MCCONF_SIGNATURE 503309878
11+
#define MCCONF_SIGNATURE 3875075384
1212
#define APPCONF_SIGNATURE 783041200
1313

1414
// Functions

datatypes.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ typedef enum {
129129
SENSOR_PORT_MODE_ABI,
130130
SENSOR_PORT_MODE_AS5047_SPI,
131131
SENSOR_PORT_MODE_AD2S1205,
132-
SENSOR_PORT_MODE_SINCOS
132+
SENSOR_PORT_MODE_SINCOS,
133+
SENSOR_PORT_MODE_TS5700N8501
133134
} sensor_port_mode;
134135

135136
typedef struct {
@@ -687,6 +688,9 @@ typedef enum {
687688
COMM_PLOT_SET_GRAPH,
688689
COMM_GET_DECODED_BALANCE,
689690
COMM_BM_MEM_READ,
691+
COMM_WRITE_NEW_APP_DATA_LZO,
692+
COMM_WRITE_NEW_APP_DATA_ALL_CAN_LZO,
693+
COMM_BM_WRITE_FLASH_LZO
690694
} COMM_PACKET_ID;
691695

692696
// CAN commands

0 commit comments

Comments
 (0)