ABS Project - Development of Software (I)

Hello everyone,

I have started developing software for ABS diagnostic tester.

I am going to use STM32F4 Discovery kit which has 32 bits ARM microcontroller on it.



As a first part of flow char, we should initialize PWM, interrupts, encoder counter with timer unit, and USART to send data back and forth to host device.

Below function initializes TIM5 as an PWM generator by using GPIOA 1. pin as an PWM output. 


Since it is hard to remember CCR2 value, I'll create function to be able to set PWM output with percentage.

We need to set interrupt for button to start program. It might be handled with a simple loop that always looks button input. However, this loop spends sources unnecessarily. Here is the initialization code to set up button intterrupt.

 
ABS signal output will generate either 5V or GND based on tone wheel position. This signal will trigger interrupt. This interrupts will be used to count encoder input. If there is correct match we can assume that tone wheel has perfect inner shape. Here is the interrupt that will trigger interrupt function where we will count encoder output to see if there is match.


We are almost done with with all initialization. Now we need to setup timer unit as counter to count encoder output. Since I used quadrature encoder, it has two channel outputs that create +-90 degree phase difference between channels. If motor turns clockwise, phase difference is 90 degree, on contrary it is -90 degree for counter clockwise. Here is the timer setting to be able to use it as a counter.

We need to initialize USART lastly to communicate host device to show messages, result and other human interfaces.


We completed initialization and definations. Here are codes are scatter since aim of this note is to explain details. If you want to see neat codes please visit my GitHub.

Comments