Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 8 Next »

Software

MCU config tool

https://www.st.com/en/development-tools/stm32cubemx.html

IDE

https://www.st.com/en/development-tools/stm32cubeide.html

STM32CubeProgrammer

https://www.st.com/en/development-tools/stm32cubeprog.html

Input capture with timers

Code example: https://controllerstech.com/input-capture-in-stm32/

SPI

HAL doc:

good overviews:

https://deepbluembedded.com/stm32-spi-tutorial/

https://deepbluembedded.com/how-to-receive-spi-with-stm32-dma-interrupt/

https://www.st.com/content/ccc/resource/training/technical/product_training/group0/3e/ee/cd/b7/84/4b/45/ee/STM32F7_Peripheral_SPI/files/STM32F7_Peripheral_SPI.pdf/_jcr_content/translations/en.STM32F7_Peripheral_SPI.pdf

Wheel encoder

The STM32 is setup with four timers and four input capture interrupts, one for each wheel. Each timer is free running and with each interrupt we store the current counter. When we have encountered two falling edges or two interrupt events on one channel we can calculate the difference in time and get the current rotational speed.

The system clock is at 2.097MHz, the timers have a clock divider of 16 which means each count is 7,629947544us.

2.097MHz/16 = 131,0625kHz

We have a 16bit counter → 65536

1/131,0625kHz * 65536 = ~0.5 or 2Hz would be the lowest speed we could capture.

The difference is stored in a 16 bit value which then is divided by two and stored in a 8 byte arrary. The difference is the raw count value (0 → 65536 ) of the timer so the conversion to Hz or RPM need to be done else ware.

Front Right B[0]: MSB B[1]:LSB

Front Left B[2]: MSB B[3]:LSB

Back Right B[4]: MSB B[5]:LSB

Back Left B[6]: MSB B[7]:LSB

To get the value from the STM32 simply clock out 8x8 clock pulses. It dose not matter if there is data on the MOSI line.

Example

Hardware

Guidelines: https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwj0qp_xh8_1AhVOKBoKHYoyAdoQFnoECBUQAQ&url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fapplication_note%2Fdm00112257-getting-started-with-stm32l0xx-hardware-development-stmicroelectronics.pdf&usg=AOvVaw37RwynR9X34bcA7xiW6fb1

Pinout

page 37 for pin description: https://www.st.com/content/ccc/resource/technical/document/datasheet/42/c0/ab/e5/71/7a/47/0b/DM00206508.pdf/files/DM00206508.pdf/jcr:content/translations/en.DM00206508.pdf

Footprint

  • No labels