Skip to content

Commit 346f85c

Browse files
committed
VESC Release 5.03 for GESC
1 parent 9988d4d commit 346f85c

File tree

5 files changed

+591
-60
lines changed

5 files changed

+591
-60
lines changed

applications/app_dpv.c

+22-20
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#define SPEED_STEP 0.05
1616
#define SPEED_MAX 1.00
17-
#define SPEED_MIN 0.20
17+
#define SPEED_MIN 0.10
1818
#define SPEED_OFF 0.00
1919

2020
//private variables
@@ -60,6 +60,9 @@ void app_custom_start(void) {
6060
// Start the dv thread
6161
chThdCreateStatic(dpv_thread_wa, sizeof(dpv_thread_wa), NORMALPRIO, dpv_thread, NULL);
6262

63+
hw_start_i2c();
64+
app_uartcomm_start(UART_PORT_COMM_HEADER);
65+
app_uartcomm_start(UART_PORT_BUILTIN);
6366
chSysLock();
6467
chVTSetI(&dpv_vt, MS2ST(1), update, NULL);
6568
chSysUnlock();
@@ -121,27 +124,26 @@ static THD_FUNCTION(dpv_thread, arg) {
121124

122125
static systime_t last_time = 0;
123126
static float motorSpeed_val_ramp = 0.0;
124-
float ramp_time;
125-
126-
if ( ! palReadPad(HW_HALL_TRIGGER_GPIO, HW_HALL_TRIGGER_PIN)) {
127-
motorSpeed=targetSpeed;
128-
} else {
129-
motorSpeed=SPEED_OFF;
130-
}
131-
ramp_time = fabsf(motorSpeed) > fabsf(motorSpeed_val_ramp) ? 5.0 : 0.5;
127+
float ramp_time;
128+
if ( ! palReadPad(HW_HALL_TRIGGER_GPIO, HW_HALL_TRIGGER_PIN)) {
129+
motorSpeed=targetSpeed;
130+
} else {
131+
motorSpeed=SPEED_OFF;
132+
}
133+
ramp_time = fabsf(motorSpeed) > fabsf(motorSpeed_val_ramp) ? 5.0 : 0.5;
132134
if (fabsf(motorSpeed) > 0.01) {
133-
ramp_time = fminf(3.0, 3.0);
135+
ramp_time = fminf(3.0, 3.0);
134136
}
135-
if (ramp_time > 0.01) {
136-
const float ramp_step = (float)ST2MS(chVTTimeElapsedSinceX(last_time)) / (ramp_time * 1000.0);
137-
utils_step_towards(&motorSpeed_val_ramp, motorSpeed, ramp_step);
138-
last_time = chVTGetSystemTimeX();
139-
motorSpeed = motorSpeed_val_ramp;
137+
if (ramp_time > 0.01) {
138+
const float ramp_step = (float)ST2MS(chVTTimeElapsedSinceX(last_time)) / (ramp_time * 1000.0);
139+
utils_step_towards(&motorSpeed_val_ramp, motorSpeed, ramp_step);
140+
last_time = chVTGetSystemTimeX();
141+
motorSpeed = motorSpeed_val_ramp;
140142
}
141-
mc_interface_set_duty(utils_map(motorSpeed, 0, 1.0, 0, mcconf->l_max_duty));
142-
// mc_interface_set_pid_speed(motorSpeed*mcconf->l_max_erpm);
143-
chThdSleepMilliseconds(10);
144-
// Reset the timeout
145-
timeout_reset();
143+
//mc_interface_set_pid_speed(motorSpeed*mcconf->l_max_erpm);
144+
mc_interface_set_duty(motorSpeed*mcconf->l_max_duty);
145+
chThdSleepMilliseconds(5);
146+
// Reset the timeout
147+
timeout_reset();
146148
}
147149
}

conf_general.h

+15-10
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,19 @@
6666
//#define HW_SOURCE "hw_410.c" // Also for 4.11 and 4.12
6767
//#define HW_HEADER "hw_410.h" // Also for 4.11 and 4.12
6868

69-
//#define HW_SOURCE "hw_gesc.c"
70-
//#define HW_HEADER "hw_gesc.h"
69+
// Benjamins first HW60 PCB with PB5 and PB6 swapped
70+
//#define HW60_VEDDER_FIRST_PCB
71+
72+
//#define HW_SOURCE "hw_60.c"
73+
//#define HW_HEADER "hw_60.h"
74+
75+
#define HW_SOURCE "hw_gesc.c"
76+
#define HW_HEADER "hw_gesc.h"
7177

7278
// Mark3 version of HW60 with power switch and separate NRF UART.
7379
//#define HW60_IS_MK3
7480
//#define HW60_IS_MK4
75-
#define HW60_IS_MK5
76-
77-
#define HW_SOURCE "hw_60.c"
78-
#define HW_HEADER "hw_60.h"
81+
//#define HW60_IS_MK5
7982

8083
//#define HW_SOURCE "hw_r2.c"
8184
//#define HW_HEADER "hw_r2.h"
@@ -103,7 +106,7 @@
103106

104107
// Second revision with separate UART for NRF51
105108
//#define HW75_300_REV_2
106-
#define HW75_300_REV_3
109+
//#define HW75_300_REV_3
107110

108111
//#define HW_SOURCE "hw_75_300.c"
109112
//#define HW_HEADER "hw_75_300.h"
@@ -226,27 +229,29 @@
226229
* Select default user motor configuration
227230
*/
228231
//#include "mcconf_default.h"
229-
//#include "mcconf_china_60kv.h"
232+
#include "mcconf_60kv.h"
230233

231234
/*
232235
* Select default user app configuration
233236
*/
234237
//#include "appconf_example_ppm.h"
235-
//#include "appconf_custom.h"
238+
//#include "appconf_dpv.h"
236239

237240
/*
238241
* Set APP_CUSTOM_TO_USE to the name of the main C file of the custom application.
239242
*/
240243
//#define APP_CUSTOM_TO_USE "app_custom_template.c"
244+
#define APP_CUSTOM_TO_USE "app_dpv.c"
241245
//#define APP_CUSTOM_TO_USE "app_motor_heater.c"
246+
#define APP_CUSTOM_TO_USE "app_dpv.c"
242247
//#include "er/app_erockit_conf_v2.h"
243248
//#include "finn/app_finn_az_conf.h"
244249
//#include "vccu/app_vccu_conf.h"
245250
//#include "pitch/app_pitch_conf.h"
246251

247252
// CAN-plotter
248253
//#define APP_CUSTOM_TO_USE "app_plot_can.c"
249-
//#define APPCONF_APP_TO_USE APP_CUSTOM
254+
#define APPCONF_APP_TO_USE APP_CUSTOM
250255
//#define APPCONF_CAN_BAUD_RATE CAN_BAUD_75K
251256

252257
#include "hw.h"

hwconf/hw_gesc.c

-6
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include "lora/lora.h"
3737
#endif
3838

39-
// Threads
4039
THD_FUNCTION(mag_thread, arg);
4140
static THD_WORKING_AREA(mag_thread_wa, 512);
4241
static bool mag_thread_running = false;
@@ -56,7 +55,6 @@ static const I2CConfig i2cfg = {
5655
STD_DUTY_CYCLE
5756
};
5857

59-
6058
void hw_init_gpio(void) {
6159
// GPIO clock enable
6260
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
@@ -144,8 +142,6 @@ void hw_init_gpio(void) {
144142
0,
145143
terminal_cmd_doublepulse);
146144
#endif
147-
//start uart for log
148-
//app_uartcomm_start(UART_PORT_COMM_HEADER);
149145
}
150146

151147
void hw_setup_adc_channels(void) {
@@ -221,7 +217,6 @@ void hw_start_i2c(void) {
221217
PAL_STM32_OTYPE_OPENDRAIN |
222218
PAL_STM32_OSPEED_MID1 |
223219
PAL_STM32_PUDR_PULLUP);
224-
225220
i2cStart(&HW_I2C_DEV, &i2cfg);
226221
i2c_running = true;
227222
}
@@ -260,7 +255,6 @@ void hw_try_restore_i2c(void) {
260255
PAL_STM32_OTYPE_OPENDRAIN |
261256
PAL_STM32_OSPEED_MID1 |
262257
PAL_STM32_PUDR_PULLUP);
263-
264258
palSetPad(HW_I2C_SCL_PORT, HW_I2C_SCL_PIN);
265259
palSetPad(HW_I2C_SDA_PORT, HW_I2C_SDA_PIN);
266260

hwconf/hw_gesc.h

+24-24
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
// HW properties
2626
#define HW_HAS_3_SHUNTS
2727
#define HW_HAS_PHASE_SHUNTS
28-
//#define HW_HAS_PHASE_FILTERS
28+
#define HW_HAS_PHASE_FILTERS
2929
#define INVERTED_SHUNT_POLARITY
3030
#define HW_HAS_NO_CAN
3131
#define HW_HAS_LORA
@@ -151,13 +151,13 @@
151151
#define HW_UART_RX_PORT GPIOB
152152
#define HW_UART_RX_PIN 11
153153

154-
//#define HW_UART_P_BAUD 115200
155-
//#define HW_UART_P_DEV SD4
156-
//#define HW_UART_P_GPIO_AF GPIO_AF_UART4
157-
//#define HW_UART_P_TX_PORT GPIOC
158-
//#define HW_UART_P_TX_PIN 10
159-
//#define HW_UART_P_RX_PORT GPIOC
160-
//#define HW_UART_P_RX_PIN 11
154+
#define HW_UART_P_BAUD 115200
155+
#define HW_UART_P_DEV SD4
156+
#define HW_UART_P_GPIO_AF GPIO_AF_UART4
157+
#define HW_UART_P_TX_PORT GPIOC
158+
#define HW_UART_P_TX_PIN 10
159+
#define HW_UART_P_RX_PORT GPIOC
160+
#define HW_UART_P_RX_PIN 11
161161

162162
// ICU Peripheral for servo decoding
163163
#define HW_USE_SERVO_TIM4
@@ -172,7 +172,7 @@
172172

173173
// I2C Peripheral
174174
#define HW_USE_I2CD1
175-
#define HW_I2C_DEV I2CD1
175+
#define HW_I2C_DEV I2CD1
176176
#define HW_I2C_GPIO_AF GPIO_AF_I2C1
177177
#define HW_I2C_SCL_PORT GPIOB
178178
#define HW_I2C_SCL_PIN 8
@@ -225,18 +225,18 @@
225225
#ifdef HW_HAS_LORA
226226
#define HW_LORA_SPI_DEV SPID1
227227
#define HW_LORA_SPI_GPIO_AF GPIO_AF_SPI1
228-
#define HW_LORA_SPI_PORT_NSS GPIOA
229-
#define HW_LORA_SPI_PIN_NSS 4
230-
#define HW_LORA_SPI_PORT_SCK GPIOA
231-
#define HW_LORA_SPI_PIN_SCK 5
232-
#define HW_LORA_SPI_PORT_MOSI GPIOA
233-
#define HW_LORA_SPI_PIN_MOSI 7
234-
#define HW_LORA_SPI_PORT_MISO GPIOA
235-
#define HW_LORA_SPI_PIN_MISO 6
236-
#define HW_LORA_SPI_PORT_DIO0 GPIOC
237-
#define HW_LORA_SPI_PIN_DIO0 5
238-
#define HW_LORA_SPI_PORT_RESET GPIOB
239-
#define HW_LORA_SPI_PIN_RESET 2
228+
#define HW_LORA_SPI_PORT_NSS GPIOB
229+
#define HW_LORA_SPI_PIN_NSS 3
230+
#define HW_LORA_SPI_PORT_SCK GPIOB
231+
#define HW_LORA_SPI_PIN_SCK 6
232+
#define HW_LORA_SPI_PORT_MOSI GPIOB
233+
#define HW_LORA_SPI_PIN_MOSI 4
234+
#define HW_LORA_SPI_PORT_MISO GPIOB
235+
#define HW_LORA_SPI_PIN_MISO 5
236+
#define HW_LORA_SPI_PORT_DIO0 GPIOB
237+
#define HW_LORA_SPI_PIN_DIO0 12
238+
#define HW_LORA_SPI_PORT_RESET GPIOB
239+
#define HW_LORA_SPI_PIN_RESET 2
240240
#endif
241241

242242
// Measurement macros
@@ -252,14 +252,14 @@
252252

253253

254254
// Override dead time. See the stm32f4 reference manual for calculating this value.
255-
#define HW_DEAD_TIME_NSEC 660.0
255+
#define HW_DEAD_TIME_NSEC 360.0
256256

257257
// Default setting overrides
258258
#ifndef MCCONF_L_MIN_VOLTAGE
259259
#define MCCONF_L_MIN_VOLTAGE 12.0 // Minimum input voltage
260260
#endif
261261
#ifndef MCCONF_L_MAX_VOLTAGE
262-
#define MCCONF_L_MAX_VOLTAGE 50.0 // Maximum input voltage
262+
#define MCCONF_L_MAX_VOLTAGE 57.0 // Maximum input voltage
263263
#endif
264264
#ifndef MCCONF_DEFAULT_MOTOR_TYPE
265265
#define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC
@@ -284,7 +284,7 @@
284284
#define HW_LIM_CURRENT -120.0, 120.0
285285
#define HW_LIM_CURRENT_IN -120.0, 120.0
286286
#define HW_LIM_CURRENT_ABS 0.0, 160.0
287-
#define HW_LIM_VIN 12.0, 50.0
287+
#define HW_LIM_VIN 12.0, 60.0
288288
#define HW_LIM_ERPM -200e3, 200e3
289289
#define HW_LIM_DUTY_MIN 0.0, 0.1
290290
#define HW_LIM_DUTY_MAX 0.0, 0.99

0 commit comments

Comments
 (0)