- Understand what your sensor is measuring and read the datasheet associated with your sensor. I would spend some time understanding why the sensor is necessary in the big picture of the vehicle
- Understand the output data from the sensor and how you will interface with the sensor. Whether that is reading ADC values in the case of analog signals or reading data over I2C/SPI. Its important to understand the fundamentals of the technologies you are using before you start tackling the task
- Read through the associated Hardware Abstraction Language (HAL) functions associated with the interface that you will be using. To find these Google “STM32 HAL I2C” if you are looking for the I2C functions. You should be looking for init functions, how to configurate the interface and the format of the data you will be receiving. This will certainly take a lot of your time. Once again, I want to stress the importance of understanding all the details of the functions you are using before you start testing/drafting code
- Once your code is written, you will be using a Nucleo board that has a similar processor to all our boards. You will validate that your code works/debug it and ensure that you are able to get the physical value of the sensor in code
Datasheet: https://www.mouser.com/datasheet/2/670/amt10-3159318.pdf
Wheel Encoders
Wheel encoders in cars measure the rotational speed and direction of the wheels by outpitting pulses according to the movement of a rotating shaft. Those pieces of information are crucial for other control and safety systems, e.g. traction control systems (TCS) and odometer/speedometer displays.
- Picture of internal parts of AMT102-V Encoder:

Pinout
- This is an incremental quadrature encoder with 3 data channels. The pinout is as follows:

PPR, RPM
- PPR is number of high pulses (rising edges) an encoder has
What are A, B, X channels?
- A quadrature encoder contains two tracks or disks, denoted Channel A and Channel B. A quadrature configuration indicates 90 electrical degrees out of phase.
- “Channel A leads B for CCW encoder rotation (viewed from front)”

- Note: we can use any of the two channels to determine the rotated angle by simply counting the pulses of the signal. To determine rotation direction, we need to consider both.
- Apart from direction, position can be monitored using Channel X (reference index).
- Provides a reference position, putputs one pulse per 360 degree encoder revolution.
- Useful for absolute positioning; this allows us to set a home, reset, or zero point of reference.
Reading data
- d
Pseudocode
Sources: