Skip to content

ufnalski/absolute_encoder_amt232av_ssi_g431kb

Repository files navigation

Absolute encoder with SSI interface (STM32G431KB)

An STM32 HAL example of communicating with an absolute encoder over the SSI interface. A single-turn 14-bit encoder from CUI Devices is taken as an example. The relevant evaluation kit is AMT232B-V. Both blocking and non-blocking (_IT) modes are implemented.

CUI Devices AMT23 in action

The main motivation behind this submission is to encourage you to get familiar with an SSI interface. And the "an" here is to point out that SSI is kind of a loosely defined standard and many modified versions exist. You should then pay a special attention to timing waveforms provided by a manufacturer of a device you are going to deal with. The differences may be in the physical layer (differential vs. single-ended lines) as well as in the presence of the CS line or its lack (as in the initial specification). You may also encounter some naming inconsistencies. The SSI without the CS line uses the first SCK transition from high to low to start the communication with the slave and the consecutive transition from low to high to inform the slave that it is time to push the first bit of information. The bits should be then sampled at the CLK falling edges. The SSI with the CS line may still keep the original "additional" clock cycle or skip it, as the CS line can now serve its purpose, turning into the regular SPI, yet still called in some datasheets an SSI.

For example, to communicate with the absolute encoder AMT23, we have to reproduce the following waveforms:

CUI Devices AMT23 timing waveform

Source: CUI Devices AMT23 datasheet

We are going to use a regular SPI peripheral to do that. Note that the SPI uses CS to initialize pushing the bits. The SPI then samples the MISO line also at the red falling edge what is needless here. Also note that the STM32 SPI peripheral can be configured to read from 4 to 16 bits. We will then use HAL_SPI_TransmitReceive() to read 16 logical states (the spare red one and the 15 green bits of information). Then we will read the last bit of information (the blue one) using HAL_GPIO_ReadPin() before pulling up the CS line.

Missing files?

Don't worry 🙂 Just hit Alt-K to generate /Drivers/CMCIS/ and /Drivers/STM32G4xx_HAL_Driver/ based on the .ioc file. After a couple of seconds your project will be ready for building.

Libraries

Hardware

Tools

DSLogic Plus in action

Tips and tricks

Tabby in action

Readings

SSI

SPI

BiSS (hardware compatible to SSI but offers additional features and options)

Call for action

Create your own home laboratory/workshop/garage! Get inspired by ControllersTech, DroneBot Workshop, Andreas Spiess, GreatScott!, ElectroBOOM, Phil's Lab, atomic14, That Project, Paul McWhorter, and many other professional hobbyists sharing their awesome projects and tutorials! Shout-out/kudos to all of them!

Warning

Control in power electronics and drives - do try this at home ❗

190+ challenges to start from: Control Engineering for Hobbyists at the Warsaw University of Technology.

Stay tuned!

Releases

No releases published

Packages

No packages published