Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f3298ec
trigger docs build
samuelsadok Aug 11, 2022
146b67f
[docs] fix version indicator
samuelsadok Aug 11, 2022
e2df8e9
Merge pull request #730 from odriverobotics/devel
Wetmelon Apr 29, 2023
e37a25f
Merge branch 'docs-v0.5.5'
samuelsadok May 2, 2023
a308314
fix release action
samuelsadok May 2, 2023
58fdd3f
Update CHANGELOG.md
samuelsadok May 9, 2023
6c3cefd
add note about compatibility
samuelsadok Mar 21, 2024
ca13288
fix compile on GCC 12
samuelsadok Oct 2, 2024
f9b5419
Remove unused buggy FreeRTOS functions
samuelsadok Oct 2, 2024
3a2e4dd
update deprecated action dependencies
samuelsadok Jan 20, 2026
c9d473b
Trigger GitHub Actions CI build for v3.6-56V
Apr 4, 2026
f2d0665
Add ci-v3.6-56V branch to workflow triggers
Apr 4, 2026
e1595dd
Fix deprecated upload-artifact action version
Apr 4, 2026
ffb07ac
Fix macOS pip install for externally managed Python environment
Apr 4, 2026
5956e49
Remove macOS matrix to avoid unsupported runner failure
Apr 4, 2026
1744f2e
Fix: AS5048A SPI encoder communication issue
beihia Apr 6, 2026
78035e4
Fix: try alternate AMS SPI phase
Apr 6, 2026
1ad9c32
Fix: add SPI CS setup delay
Apr 6, 2026
8c7d458
Fix: reconstruct AMS parity bit
Apr 6, 2026
8c95624
Fix: poll AMS SPI in sampling IRQ
Apr 6, 2026
9bcbdfd
Revert "Fix: poll AMS SPI in sampling IRQ"
Apr 6, 2026
87dce31
Fix: ignore in-flight AMS SPI transactions
Apr 6, 2026
00ec4bf
Fix AS5048A SPI mode and frame parsing
Apr 15, 2026
963771a
Tune AS5048A SPI fallback parsing
Apr 15, 2026
b828c75
Try shifted-frame recovery for AS5048A
Apr 15, 2026
096ad12
Fix AS5048A frame corruption: SPI mode 1 and strict parity check
Oct 18, 2026
b7b4756
Add temporary AS5048A SPI frame diagnostics
Oct 18, 2026
4b34d02
Diagnose AS5048A error flag: read magnitude and AGC registers
Oct 18, 2026
87fde1a
Add temporary switch to accept AS5048A frames with the error flag set
Oct 18, 2026
4390a76
Remove AS5048A register probes, keep read-only frame diagnostics
Oct 18, 2026
35ed8e7
Make the AS5048A error-flag override a persisted config option
Oct 18, 2026
2442c66
Document the real root cause and closed-loop result for axis0
Oct 18, 2026
2782458
Add a banner to the commissioning log pointing at the corrected analysis
Oct 18, 2026
3bff58a
Reject implausible AS5048A frame jumps before they reach the PLL
Oct 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/actions/upload-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ inputs:
odrive_api_key:
description: 'Key to our release index server'
required: true
product:
description: 'ODrive product name (for firmware releases only).'
board:
description: 'ODrive board version triplet ("PRODUCT_LINE.VERSION.VARIANT") (for firmware releases only).'
required: false
app:
description: 'Firmware app name (default, bootloader) (for firmware releases only).'
Expand Down Expand Up @@ -95,6 +95,7 @@ runs:
shell: python
run: |
import asyncio
import re
import sys

import aiohttp
Expand All @@ -115,8 +116,8 @@ runs:
release_api = PrivateReleaseApi(api_client)

qualifiers = {}
if '${{ inputs.product }}':
qualifiers['product'] = '${{ inputs.product }}'
if '${{ inputs.board }}':
qualifiers['board'] = tuple(int(i) for i in re.match(r'^([0-9]+)\.([0-9]+).([0-9]+)$', '${{ inputs.board }}').groups())
if '${{ inputs.app }}':
qualifiers['app'] = '${{ inputs.app }}'
if '${{ inputs.variant }}':
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
print("::set-output name=version::" + version)

- name: Cache pip
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-sphinx-sphinx-tabs-sphinx-design-sphinx_copybutton-sphinx_panels-sphinx_rtd_theme
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/firmware.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ on:
pull_request:
branches: [master, devel]
push:
branches: [master, devel]
branches: [master, devel, ci-v3.6-56V]
tags: ['fw-v*']

jobs:
compile:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest, windows-latest]
board_version: [v3.6-56V]
debug: [true]

Expand Down Expand Up @@ -80,11 +80,12 @@ jobs:
# See https://github.com/osxfuse/osxfuse/issues/801#issuecomment-833419942
brew install --cask macfuse
brew install gromgit/fuse/tup-mac
pip3 install PyYAML Jinja2 jsonschema
python3 -m pip install --user PyYAML Jinja2 jsonschema
echo 'export PATH="$HOME/.local/bin:$PATH"' >> $GITHUB_ENV


- name: Cache chocolatey
uses: actions/cache@v2
uses: actions/cache@v4
if: startsWith(matrix.os, 'windows-')
with:
path: C:\Users\runneradmin\AppData\Local\Temp\chocolatey\gcc-arm-embedded
Expand Down Expand Up @@ -134,7 +135,7 @@ jobs:

- name: Upload binary as artifact
if: ${{ matrix.os == 'ubuntu-latest' && matrix.debug == false }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: firmware-${{ matrix.board_version }}
path: |
Expand All @@ -147,6 +148,14 @@ jobs:
mkdir ${{ github.workspace }}/out
cp ${{ github.workspace }}/Firmware/build/ODriveFirmware.elf ${{ github.workspace }}/out/firmware.elf

- name: Parse and format matrix.board_version
if: ${{ matrix.os == 'ubuntu-latest' }}
id: format-board-version
run: |
formatted_version=$(echo "${{ matrix.board_version }}" | sed 's/v\([0-9]\+\)\.\([0-9]\+\)-\([0-9]\+\)V/\1.\2.\3/')
echo "Formatted board version: $formatted_version"
echo "::set-output name=formatted_board_version::$formatted_version"

- name: Upload firmware to ODrive release system
if: ${{ steps.release-info.outputs.channel == 'master' && matrix.os == 'ubuntu-latest' && matrix.debug == false && (startsWith(matrix.board_version, 'v3.5-') || startsWith(matrix.board_version, 'v3.6-')) }}
uses: ./.github/actions/upload-release
Expand All @@ -157,7 +166,7 @@ jobs:
do_access_key: ${{ secrets.DIGITALOCEAN_ACCESS_KEY }}
do_secret_key: ${{ secrets.DIGITALOCEAN_SECRET_KEY }}
odrive_api_key: ${{ secrets.ODRIVE_API_KEY }}
product: ODrive ${{ matrix.board_version }}
board: ${{ steps.format-board-version.outputs.formatted_board_version }}
app: default
variant: public

Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

## [0.5.6] - Unreleased
## [0.5.6] - 2023-04-29

### Fixed

Expand Down
4 changes: 4 additions & 0 deletions Firmware/Drivers/STM32/stm32_spi_arbiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ bool Stm32SpiArbiter::start() {
__HAL_SPI_ENABLE(hspi_);
}
task.ncs_gpio.write(false);
// Give the slave a brief setup time before the first SPI clock edge.
for (volatile int i = 0; i < 64; ++i) {
__NOP();
}

HAL_StatusTypeDef status = HAL_ERROR;

Expand Down
63 changes: 55 additions & 8 deletions Firmware/MotorControl/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ void Encoder::setup() {
.Mode = SPI_MODE_MASTER,
.Direction = SPI_DIRECTION_2LINES,
.DataSize = SPI_DATASIZE_16BIT,
// AS5048A (AMS) is an SPI mode 1 device: CPOL=0 (idle low), CPHA=1 (sample on 2nd edge).
// Using 1EDGE here samples one bit too early, which shifts the whole frame and
// makes the parity check fail on almost every transfer.
.CLKPolarity = (mode_ == MODE_SPI_ABS_AEAT || mode_ == MODE_SPI_ABS_MA732) ? SPI_POLARITY_HIGH : SPI_POLARITY_LOW,
.CLKPhase = SPI_PHASE_2EDGE,
.NSS = SPI_NSS_SOFT,
.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16,
// ~2.6MHz (@168MHz APB2): well inside the AS5048A 10MHz limit with margin for wiring.
.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32,
.FirstBit = SPI_FIRSTBIT_MSB,
.TIMode = SPI_TIMODE_DISABLE,
.CRCCalculation = SPI_CRCCALCULATION_DISABLE,
Expand Down Expand Up @@ -535,6 +539,7 @@ bool Encoder::abs_spi_start_transaction() {
spi_task_.on_complete = [](void* ctx, bool success) { ((Encoder*)ctx)->abs_spi_cb(success); };
spi_task_.on_complete_ctx = this;
spi_task_.next = nullptr;
abs_spi_transaction_pending_ = true;

spi_arbiter_->transfer_async(&spi_task_);
} else {
Expand Down Expand Up @@ -562,18 +567,57 @@ uint8_t cui_parity(uint16_t v) {
void Encoder::abs_spi_cb(bool success) {
uint16_t pos;

abs_spi_transaction_pending_ = false;

if (!success) {
goto done;
}

switch (mode_) {
case MODE_SPI_ABS_AMS: {
uint16_t rawVal = abs_spi_dma_rx_[0];
// check if parity is correct (even) and error flag clear
if (ams_parity(rawVal) || ((rawVal >> 14) & 1)) {

// --- temporary bring-up diagnostics ---
for (int i = 7; i > 0; --i) {
dbg_raw_[i] = dbg_raw_[i - 1];
}
dbg_raw_[0] = rawVal;
dbg_total_++;

if (ams_parity(rawVal)) {
dbg_parity_fail_++;
goto done;
}
// bit 14: AS5048A magnetic field error flag
if ((rawVal >> 14) & 1) {
dbg_flag_fail_++;
if (!config_.abs_spi_ignore_error_flag) {
goto done;
}
}
dbg_ok_++;
pos = rawVal & 0x3fff;

// Plausibility filter: at 8 kHz a 3.6 turn/s machine moves less
// than 8 counts per control period, so a frame that jumps further
// than 64 counts is corrupted (bit errors can keep even parity and
// slip past the parity check). Such a jump would spike the velocity
// estimate to hundreds of turn/s and trip the overspeed fault.
if (abs_spi_have_last_pos_) {
int32_t delta = (int32_t)pos - (int32_t)abs_spi_last_pos_;
if (delta > config_.cpr / 2) {
delta -= config_.cpr;
}
if (delta < -config_.cpr / 2) {
delta += config_.cpr;
}
if (std::abs(delta) > 64) {
dbg_jump_reject_++;
goto done;
}
}
abs_spi_last_pos_ = pos;
abs_spi_have_last_pos_ = true;
} break;

case MODE_SPI_ABS_CUI: {
Expand Down Expand Up @@ -734,11 +778,14 @@ bool Encoder::update() {
case MODE_SPI_ABS_AEAT:
case MODE_SPI_ABS_MA732: {
if (abs_spi_pos_updated_ == false) {
// Low pass filter the error
spi_error_rate_ += current_meas_period * (1.0f - spi_error_rate_);
if (spi_error_rate_ > 0.05f) {
set_error(ERROR_ABS_SPI_COM_FAIL);
return false;
// Don't count a transfer as failed while its DMA transaction is still in flight.
if (!abs_spi_transaction_pending_) {
// Low pass filter the error
spi_error_rate_ += current_meas_period * (1.0f - spi_error_rate_);
if (spi_error_rate_ > 0.05f) {
set_error(ERROR_ABS_SPI_COM_FAIL);
return false;
}
}
} else {
// Low pass filter the error
Expand Down
16 changes: 16 additions & 0 deletions Firmware/MotorControl/encoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class Encoder : public ODriveIntf::EncoderIntf {
uint16_t abs_spi_cs_gpio_pin = 1;
uint16_t sincos_gpio_pin_sin = 3;
uint16_t sincos_gpio_pin_cos = 4;
// Accept AS5048A frames even though the encoder asserts its magnetic
// field error flag (bit 14). Only enable this when the angle has been
// verified to read correctly over the full range: the flag itself
// indicates the magnet is out of spec (air gap, centring, type).
bool abs_spi_ignore_error_flag = false;


// custom setters
Expand Down Expand Up @@ -137,6 +142,7 @@ class Encoder : public ODriveIntf::EncoderIntf {
void abs_spi_cb(bool success);
void abs_spi_cs_pin_init();
bool abs_spi_pos_updated_ = false;
bool abs_spi_transaction_pending_ = false;
Mode mode_ = MODE_INCREMENTAL;
Stm32Gpio abs_spi_cs_gpio_;
uint32_t abs_spi_cr1;
Expand All @@ -145,6 +151,16 @@ class Encoder : public ODriveIntf::EncoderIntf {
uint16_t abs_spi_dma_rx_[1];
Stm32SpiArbiter::SpiTask spi_task_;

// --- AS5048A bring-up diagnostics ---
uint16_t dbg_raw_[8] = {0}; // last 8 raw frames, dbg_raw_[0] = newest
uint32_t dbg_total_ = 0; // completed SPI transactions
uint32_t dbg_parity_fail_ = 0;
uint32_t dbg_flag_fail_ = 0;
uint32_t dbg_ok_ = 0;
uint32_t dbg_jump_reject_ = 0; // frames dropped by the plausibility filter
uint16_t abs_spi_last_pos_ = 0;
bool abs_spi_have_last_pos_ = false;

constexpr float getCoggingRatio(){
return 1.0f / 3600.0f;
}
Expand Down
2 changes: 1 addition & 1 deletion Firmware/MotorControl/nvm_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

// IMPORTANT: if you change, reorder or otherwise modify any of the fields in
// the config structs without changing its total length, make sure to increment this number:
static constexpr uint16_t config_version = 0x0001;
static constexpr uint16_t config_version = 0x0002;

/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
Expand Down
Loading