STM32 Timer encoder mode with synchronization
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-19 6:51 AM - edited ‎2024-12-19 6:52 AM
I am using STM32H753.
My TIM2 is in Encoder mode, and I give two external signals from my incremental encoder to TIM2_CH1 and TIM2_CH2. My TIM2 is counts perfectly (Up or Down) when I move the encoder clockwise or anticlockwise.
Now i want to syncronize another two timer TIM1 and TIM8 (or any other ) with TIM2. so that when i move encoder Clockwise or Anticlockwise then conunts of all three timers are increase or decrease togather.
Is it possible ? How ?
As per Reference Manual Chepter of Timer synchronization, I can connect TRGO internally (For Update Event) to another Timer but will it be work in Encoder mode ? I mean how single line (TRGO) can send increment or decrement data to another timer ?
Solved! Go to Solution.
- Labels:
-
STM32H7 series
-
TIM
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-20 12:23 AM
As others said above, there's no way you can transfer the clock and direction from one timer to other, so you have to look for workarounds.
You certainly can use the remaining two channels of given timer (TIM2) to do the capture.
As suggested by @mÆŽALLEm above, you can connect several timers in parallel, all of them in encoder mode, so you'd need four timers for the eight input signals. That's not that far fetched and easy to accomplish, but will cost the extra pins.
Another option might be to trigger DMA transfer from TIM2_CNT to memory by the pins. There is some latency involved and that may or may not be an issue in your case. This is traditionally done via timer input capture, too, that capture not performing the capture itself but serving as a DMA trigger; but maybe in your 'H7 there are ways to trigger DMA from pins directly (EXTI), I am not familiar with the 'H7 and its DMAMUX.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-19 8:58 AM - edited ‎2024-12-19 9:00 AM
Hello,
I don't think you can propagate the increment/decrement behavior between timers. But what is your use case?
Why don't connect the encoder output in parallel to other TIMs channels then?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-19 11:38 AM
Why would you want two additional timers in sync doing the same thing? If it was possible, the CNT would be the same on all 3 timers and would not benefit you.
If you are trying to do something else using 3 timers in sync, maybe explain in more detail what you're trying to accomplish?
Don't worry, I won't byte.
TimerCallback tutorial! | UART and DMA Idle tutorial!
If you find my solution useful, please click the Accept as Solution so others see the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-19 9:08 PM - edited ‎2024-12-19 9:13 PM
@Karl Yamashita and @mÆŽALLEm Thanks for your replay.
I need to use other timers for scanning other external Eight Signals with respect to Encoder signals ( As Input capture ) So that i can get encoder count (Or encoder position) at Rissing or Falling Eadge of that Eight Signals.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-20 12:23 AM
As others said above, there's no way you can transfer the clock and direction from one timer to other, so you have to look for workarounds.
You certainly can use the remaining two channels of given timer (TIM2) to do the capture.
As suggested by @mÆŽALLEm above, you can connect several timers in parallel, all of them in encoder mode, so you'd need four timers for the eight input signals. That's not that far fetched and easy to accomplish, but will cost the extra pins.
Another option might be to trigger DMA transfer from TIM2_CNT to memory by the pins. There is some latency involved and that may or may not be an issue in your case. This is traditionally done via timer input capture, too, that capture not performing the capture itself but serving as a DMA trigger; but maybe in your 'H7 there are ways to trigger DMA from pins directly (EXTI), I am not familiar with the 'H7 and its DMAMUX.
JW
