2023-09-05 08:29 AM - last edited on 2023-09-05 09:05 AM by Sarra.S
For speed measure of a dc-motor we want to capture the pwm-period as described here: Solved: I have a timer set up to measure the input pwm period ... ,
I will use TIM2 and set up to 'PWM Input on CH1', with channel_1 read pwm-period, channel_2 read pulse width (Pin: PA6), the motor encoder gives 100 ticks per rotation and runs with max 3000 rpm,
Additional, when the input signal is stopped (dc-motor don't run), the capture registers has to reset to 0 (to indicate frequency=speed=0),
Questions: How to do all the nessesary configurations right in CubeMX? The lab experiments runs later directly from Matlab 2022B / Simulink.
And how can I use TIM2 CH3 to do the reset stuff as described in tread and how to config the right trigger?
Ty in advance.
2023-09-05 01:08 PM
For testing I do following steps:
1. Step: config TIM1 as 'PWM Generation', 400Hz, Pin PA8
2. Step: config TIM2 as Combined Channels 'PWM Input on CH1', PSC=1, Pin PB8
Then running the Simulink Model in real time gives wrong value from TIM2_CH1: 1024,
Any kind of help would be appreciated! Thanks