Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the AS5x47U encoder #511

Merged
merged 6 commits into from
Jul 24, 2022
Merged

Add support for the AS5x47U encoder #511

merged 6 commits into from
Jul 24, 2022

Conversation

ZachOB
Copy link
Contributor

@ZachOB ZachOB commented Jul 20, 2022

This adds support for the SPI based AS5147U and AS5247U encoders. These are basically the same encoder, with the AS5247U just consisting of two AS5147U's stacked on top of each other in the same package.

This encoder is similar to the already supported AS5047 encoder, but includes extra hardware error detection and an 8 bit CRC instead of a parity bit, allowing it to reach automotive ISO26262 safety levels. I have also added an additional fault to better report internal errors reported by the encoder.

The encoder is connected to hardware SPI on the COMM port, requiring the UART app to be disabled and preventing use of ADC2, ADC3, and I2C. The SPI communication is implemented via DMA, resulting in extremely low CPU load. I've also tested to ensure the SPI and DMA are able to recover from all types of errors (disconnection, short to ground, and short to vcc of all 4 wires).

PR to update the VESC tool is here.

ZachOB and others added 6 commits July 18, 2022 14:25
Comment on lines -45 to +52
palSetPadMode(cfg->sck_gpio, cfg->sck_pin, PAL_MODE_ALTERNATE(6) | PAL_STM32_OSPEED_HIGHEST);
palSetPadMode(cfg->miso_gpio, cfg->miso_pin, PAL_MODE_ALTERNATE(6) | PAL_STM32_OSPEED_HIGHEST);
palSetPadMode(cfg->nss_gpio, cfg->nss_pin, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
palSetPadMode(cfg->mosi_gpio, cfg->mosi_pin, PAL_MODE_ALTERNATE(6) | PAL_STM32_OSPEED_HIGHEST);
palSetPadMode(cfg->sck_gpio, cfg->sck_pin,
PAL_MODE_ALTERNATE(cfg->spi_af) | PAL_STM32_OSPEED_HIGHEST);
palSetPadMode(cfg->miso_gpio, cfg->miso_pin,
PAL_MODE_ALTERNATE(cfg->spi_af) | PAL_STM32_OSPEED_HIGHEST);
palSetPadMode(cfg->nss_gpio, cfg->nss_pin,
PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
palSetPadMode(cfg->mosi_gpio, cfg->mosi_pin,
PAL_MODE_ALTERNATE(cfg->spi_af) | PAL_STM32_OSPEED_HIGHEST);
Copy link
Contributor Author

@ZachOB ZachOB Jul 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started with this file as a base, and discovered that the alternate pin function was incorrect (at least for the 75_300). I modified the hardware SPI config to include a pin alternate function that is set using a define from hw_config

@vedderb
Copy link
Owner

vedderb commented Jul 24, 2022

Looks nice, thanks for the PR!

@vedderb vedderb merged commit 1cffcd2 into vedderb:master Jul 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants