This project contains reading data from internal Temperature Sensor Channel
and Vrefint Channel
using ADC and DMA. It controls a DC motor and LED using PWM.
If the temperature exceeds a certain threshold, the PWM duty cycle will be increased/decreased, consequently increasing/decreasing LED brightness and DC motor speed.
- transistor BJT NPN BD135
- resistor 1 kΩ
- a Schottky diode was used as a flyback diode.
- capacitor 1000 µF
- The capacitor was added to improve the smoothness of DC motor work and to boost performance at low
PWM_DutyCycle
. - In my case, instead of a capacitor, the Timer/PWM frequency (known as
Update_event
) can be reduced from 1000 Hz to, for example 100 Hz.Update_event = TIM_CLK/((PSC + 1)*(ARR + 1)*(RCR + 1))
- The capacitor was added to improve the smoothness of DC motor work and to boost performance at low
You can find Temperature
calculations in stm32f4xx_it.c
file.