Skip to content

Commit

Permalink
Merge branch 'rc-v0.5.0' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
madcowswe committed Aug 4, 2020
2 parents bf15485 + 48449f2 commit 3760c7b
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 11 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Unreleased Features
Please add a note of your changes below this heading if you make a Pull Request.

# Releases
## [0.5.0] - 2020-08-03
### Added
* AC Induction Motor support.
* Tracking of rotor flux through rotor time constant
Expand Down Expand Up @@ -48,7 +50,6 @@ Please add a note of your changes below this heading if you make a Pull Request.
* Fixed a numerical issue in the trajectory planner that could cause sudden jumps of the position setpoint
* `input_pos`, `input_vel`, `pos_estimate_linear`, `pos_estimate_circular`, are now in units of [turns] or [turns/s] instead of [counts] or [counts/s]

# Releases
## [0.4.12] - 2020-05-06
### Fixed
* Fixed a numerical issue in the trajectory planner that could cause sudden jumps of the position setpoint
Expand Down
1 change: 1 addition & 0 deletions Firmware/MotorControl/axis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ bool Axis::run_closed_loop_control_loop() {
controller_.input_pos_ = *controller_.pos_estimate_linear_src_;
}
}
controller_.input_pos_updated();

// Avoid integrator windup issues
controller_.vel_integrator_torque_ = 0.0f;
Expand Down
11 changes: 9 additions & 2 deletions Firmware/MotorControl/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ bool Encoder::run_direction_find() {
// and the encoder state 0.
// TODO: Do the scan with current, not voltage!
bool Encoder::run_offset_calibration() {
static const float start_lock_duration = 1.0f;
static const int num_steps = (int)(config_.calib_scan_distance / config_.calib_scan_omega * (float)current_meas_hz);
const float start_lock_duration = 1.0f;
const int num_steps = (int)(config_.calib_scan_distance / config_.calib_scan_omega * (float)current_meas_hz);

// Require index found if enabled
if (config_.use_index && !index_found_) {
Expand Down Expand Up @@ -311,6 +311,7 @@ void Encoder::sample_now() {
case MODE_SPI_ABS_AMS:
case MODE_SPI_ABS_CUI:
case MODE_SPI_ABS_AEAT:
case MODE_SPI_ABS_RLS:
{
axis_->motor_.log_timing(TIMING_LOG_SAMPLE_NOW);
// Do nothing
Expand Down Expand Up @@ -400,6 +401,11 @@ void Encoder::abs_spi_cb(){
pos = rawVal & 0x3fff;
} break;

case MODE_SPI_ABS_RLS: {
uint16_t rawVal = abs_spi_dma_rx_[0];
pos = (rawVal >> 2) & 0x3fff;
} break;

default: {
set_error(ERROR_UNSUPPORTED_ENCODER_MODE);
return;
Expand Down Expand Up @@ -470,6 +476,7 @@ bool Encoder::update() {
delta_enc -= 6283;
} break;

case MODE_SPI_ABS_RLS:
case MODE_SPI_ABS_AMS:
case MODE_SPI_ABS_CUI:
case MODE_SPI_ABS_AEAT: {
Expand Down
8 changes: 4 additions & 4 deletions Firmware/MotorControl/low_level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
/* Private macros ------------------------------------------------------------*/
/* Private typedef -----------------------------------------------------------*/
/* Global constant data ------------------------------------------------------*/
const float adc_full_scale = (float)(1 << 12);
const float adc_ref_voltage = 3.3f;
constexpr float adc_full_scale = static_cast<float>(1UL << 12UL);
constexpr float adc_ref_voltage = 3.3f;
/* Global variables ----------------------------------------------------------*/

// This value is updated by the DC-bus reading ADC.
Expand Down Expand Up @@ -454,7 +454,7 @@ float get_adc_voltage_channel(uint16_t channel)
//--------------------------------

void vbus_sense_adc_cb(ADC_HandleTypeDef* hadc, bool injected) {
static const float voltage_scale = adc_ref_voltage * VBUS_S_DIVIDER_RATIO / adc_full_scale;
constexpr float voltage_scale = adc_ref_voltage * VBUS_S_DIVIDER_RATIO / adc_full_scale;
// Only one conversion in sequence, so only rank1
uint32_t ADCValue = HAL_ADCEx_InjectedGetValue(hadc, ADC_INJECTED_RANK_1);
vbus_voltage = ADCValue * voltage_scale;
Expand Down Expand Up @@ -493,7 +493,7 @@ static void decode_hall_samples(Encoder& enc, uint16_t GPIO_samples[num_GPIO]) {
// TODO: Document how the phasing is done, link to timing diagram
void pwm_trig_adc_cb(ADC_HandleTypeDef* hadc, bool injected) {
#define calib_tau 0.2f //@TOTO make more easily configurable
static const float calib_filter_k = CURRENT_MEAS_PERIOD / calib_tau;
constexpr float calib_filter_k = CURRENT_MEAS_PERIOD / calib_tau;

// Ensure ADCs are expected ones to simplify the logic below
if (!(hadc == &hadc2 || hadc == &hadc3)) {
Expand Down
6 changes: 3 additions & 3 deletions Firmware/MotorControl/motor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ void Motor::DRV8301_setup() {

// Solve for exact gain, then snap down to have equal or larger range as requested
// or largest possible range otherwise
static const float kMargin = 0.90f;
static const float kTripMargin = 1.0f; // Trip level is at edge of linear range of amplifer
static const float max_output_swing = 1.35f; // [V] out of amplifier
constexpr float kMargin = 0.90f;
constexpr float kTripMargin = 1.0f; // Trip level is at edge of linear range of amplifer
constexpr float max_output_swing = 1.35f; // [V] out of amplifier
float max_unity_gain_current = kMargin * max_output_swing * hw_config_.shunt_conductance; // [A]
float requested_gain = max_unity_gain_current / config_.requested_current_range; // [V/V]

Expand Down
2 changes: 1 addition & 1 deletion Firmware/communication/can_simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <cstring>

static const uint8_t NUM_NODE_ID_BITS = 6;
static constexpr uint8_t NUM_NODE_ID_BITS = 6;
static constexpr uint8_t NUM_CMD_ID_BITS = 11 - NUM_NODE_ID_BITS;

void CANSimple::handle_can_message(can_Message_t& msg) {
Expand Down
3 changes: 3 additions & 0 deletions Firmware/odrive-interface.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,9 @@ valuetypes:
SpiAbsAeat:
value: 0x102
doc: not yet implemented
SpiAbsRls:
value: 0x103
doc: RLS Encoders

ODrive.Controller.ControlMode:
values:
Expand Down

0 comments on commit 3760c7b

Please sign in to comment.