mirror of https://github.com/rusefi/bldc.git
Added UAVCAN raw throttle modes
This commit is contained in:
parent
d0e66ea0c1
commit
55096f93cc
|
@ -22,6 +22,8 @@
|
|||
* Added hall sensor interpolation ERPM config option.
|
||||
* Use fast speed estimator for RPM limit.
|
||||
* Avoid accumulated rounding error when using PID position angle division.
|
||||
* Added UAVCAN raw throttle drive mode (current or duty cycle control).
|
||||
* Added MT6816 encoder support. See https://github.com/vedderb/bldc/pull/238
|
||||
|
||||
=== FW 5.01 ===
|
||||
* Fixed PPM bug in previous release.
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
#ifndef APPCONF_UAVCAN_ESC_INDEX
|
||||
#define APPCONF_UAVCAN_ESC_INDEX 0
|
||||
#endif
|
||||
#ifndef APPCONF_UAVCAN_RAW_MODE
|
||||
#define APPCONF_UAVCAN_RAW_MODE UAVCAN_RAW_MODE_CURRENT
|
||||
#endif
|
||||
#ifndef APPCONF_SEND_CAN_STATUS_RATE_HZ
|
||||
#define APPCONF_SEND_CAN_STATUS_RATE_HZ 50
|
||||
#endif
|
||||
|
|
|
@ -1102,7 +1102,7 @@ void commands_process_packet(unsigned char *data, unsigned int len,
|
|||
bool is_ext = data[ind++];
|
||||
|
||||
if (is_ext) {
|
||||
comm_can_transmit_eid_replace(id, data + ind, len - ind, true);
|
||||
comm_can_transmit_eid(id, data + ind, len - ind);
|
||||
} else {
|
||||
comm_can_transmit_sid(id, data + ind, len - ind);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#define FW_VERSION_MAJOR 5
|
||||
#define FW_VERSION_MINOR 02
|
||||
// Set to 0 for building a release and iterate during beta test builds
|
||||
#define FW_TEST_VERSION_NUMBER 13
|
||||
#define FW_TEST_VERSION_NUMBER 14
|
||||
|
||||
#include "datatypes.h"
|
||||
|
||||
|
|
|
@ -178,6 +178,7 @@ int32_t confgenerator_serialize_appconf(uint8_t *buffer, const app_configuration
|
|||
buffer[ind++] = conf->shutdown_mode;
|
||||
buffer[ind++] = conf->can_mode;
|
||||
buffer[ind++] = (uint8_t)conf->uavcan_esc_index;
|
||||
buffer[ind++] = conf->uavcan_raw_mode;
|
||||
buffer[ind++] = conf->app_to_use;
|
||||
buffer[ind++] = conf->app_ppm_conf.ctrl_type;
|
||||
buffer_append_float32_auto(buffer, conf->app_ppm_conf.pid_max_erpm, &ind);
|
||||
|
@ -488,6 +489,7 @@ bool confgenerator_deserialize_appconf(const uint8_t *buffer, app_configuration
|
|||
conf->shutdown_mode = buffer[ind++];
|
||||
conf->can_mode = buffer[ind++];
|
||||
conf->uavcan_esc_index = buffer[ind++];
|
||||
conf->uavcan_raw_mode = buffer[ind++];
|
||||
conf->app_to_use = buffer[ind++];
|
||||
conf->app_ppm_conf.ctrl_type = buffer[ind++];
|
||||
conf->app_ppm_conf.pid_max_erpm = buffer_get_float32_auto(buffer, &ind);
|
||||
|
@ -782,6 +784,7 @@ void confgenerator_set_defaults_appconf(app_configuration *conf) {
|
|||
conf->shutdown_mode = APPCONF_SHUTDOWN_MODE;
|
||||
conf->can_mode = APPCONF_CAN_MODE;
|
||||
conf->uavcan_esc_index = APPCONF_UAVCAN_ESC_INDEX;
|
||||
conf->uavcan_raw_mode = APPCONF_UAVCAN_RAW_MODE;
|
||||
conf->app_to_use = APPCONF_APP_TO_USE;
|
||||
conf->app_ppm_conf.ctrl_type = APPCONF_PPM_CTRL_TYPE;
|
||||
conf->app_ppm_conf.pid_max_erpm = APPCONF_PPM_PID_MAX_ERPM;
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
// Constants
|
||||
#define MCCONF_SIGNATURE 3199002916
|
||||
#define APPCONF_SIGNATURE 664237692
|
||||
#define MCCONF_SIGNATURE 789840453
|
||||
#define APPCONF_SIGNATURE 3725342318
|
||||
|
||||
// Functions
|
||||
int32_t confgenerator_serialize_mcconf(uint8_t *buffer, const mc_configuration *conf);
|
||||
|
|
|
@ -719,6 +719,12 @@ typedef enum {
|
|||
CAN_MODE_COMM_BRIDGE
|
||||
} CAN_MODE;
|
||||
|
||||
typedef enum {
|
||||
UAVCAN_RAW_MODE_CURRENT = 0,
|
||||
UAVCAN_RAW_MODE_CURRENT_NO_REV_BRAKE,
|
||||
UAVCAN_RAW_MODE_DUTY
|
||||
} UAVCAN_RAW_MODE;
|
||||
|
||||
typedef struct {
|
||||
// Settings
|
||||
uint8_t controller_id;
|
||||
|
@ -734,6 +740,7 @@ typedef struct {
|
|||
// CAN modes
|
||||
CAN_MODE can_mode;
|
||||
uint8_t uavcan_esc_index;
|
||||
UAVCAN_RAW_MODE uavcan_raw_mode;
|
||||
|
||||
// Application to use
|
||||
app_use app_to_use;
|
||||
|
|
|
@ -205,7 +205,27 @@ static void onTransferReceived(CanardInstance* ins, CanardRxTransfer* transfer)
|
|||
|
||||
if (uavcan_equipment_esc_RawCommand_decode_internal(transfer, transfer->payload_len, &cmd, &tmp, 0, true) >= 0) {
|
||||
if (cmd.cmd.len > app_get_configuration()->uavcan_esc_index) {
|
||||
mc_interface_set_duty(((float)cmd.cmd.data[app_get_configuration()->uavcan_esc_index]) / 8192.0);
|
||||
float raw_val = ((float)cmd.cmd.data[app_get_configuration()->uavcan_esc_index]) / 8192.0;
|
||||
|
||||
switch (app_get_configuration()->uavcan_raw_mode) {
|
||||
case UAVCAN_RAW_MODE_CURRENT:
|
||||
mc_interface_set_current_rel(raw_val);
|
||||
break;
|
||||
|
||||
case UAVCAN_RAW_MODE_CURRENT_NO_REV_BRAKE:
|
||||
if (raw_val >= 0.0) {
|
||||
mc_interface_set_current_rel(raw_val);
|
||||
} else {
|
||||
mc_interface_set_brake_current_rel(-raw_val);
|
||||
}
|
||||
break;
|
||||
|
||||
case UAVCAN_RAW_MODE_DUTY:
|
||||
mc_interface_set_duty(raw_val);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
timeout_reset();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue