Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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.

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

...