cancel
Showing results for 
Search instead for 
Did you mean: 

Encoder input, Bug o limitation?

DBran.1
Associate II

I want to use TIM4 for the encoder, but the ST Motor Control Workbench only allow this if I choose Three shunt current sensing. If I choose One shunt, TIM4 is no longer available for the Encoder interface. The encoder has no timing relations to either ADC sampling or pwm, so I cannot see why I shouldn't be able to use TIM4. I also tried to generate the code with TIM3 and replaced it afterwards, but I the ADC3 interrupt never executes. So I assume there may be some limitation but I cannot understand what...

See attached screen dumps

6 REPLIES 6
Fred V.
ST Employee

Hello,

The current sensing implementation for the one-shunt topology requires two more channels on the PWM timer than the three-shunt one. If the timer used for PWM generation does not have enough channels (6), then another timer is used in addition for the extra channels. This other timer cannot be chosen freely because it needs to be synchronized with the PWM one. This is the reason why TIM4 is not available anymore when you switch to one-shunt current sensing topology. Whether the PWM timer has enough channels or not depends on the MCU you are using. It may be possible to work around this issue by changing the PWM timer between TIM1 and TIM8 if you have TIM8 on your MCU. Not sure though as this depends on your MCU. Note also that changing the PWM Timer may entail a change in the current sensing ADC: the extra timer channels are used to trigger ADC conversions and not all timers can trigger all ADCs...

Best Regards,

Fred V.

DBran.1
Associate II

Hi Fred and thank you for your reply. I still not understand, because as you say, another timer is used to trigger the ADC, but it's timer5 not timer4. I have manually changed the encoder from using timer3 to timer4, and the encoder works fine. On the other hand I cannot get the ADC to trig regardless if I change the encoder timer or not (ADC Interrupt task never executes), If I just change the MCU to a STM32F407 and download it to my Discovery card the ADC irq executes ok. I made a support request for this yesterday (https://community.st.com/s/case/5000X000024QiDy/timer-trig-adc-injected-mode), but if you have some idea about it your welcome.

Thanks again for your reply.

Fred V.
ST Employee

Hi again,

If I understand it well, in single shunt, the ADC for current sensing is never triggered on your hardware. this sounds like an issue on Motor Control workbench side indeed. On the other hand, it may be due to the fact that the MCU you use is not (yet) supported by ST MC SDK. What MCU do you use in your own hardware?

Best Regards,

Fred V.

DBran.1
Associate II

The MCU is a STM32F103RCT6. There is a example project (SDK 5.1.0) in the Workbench that use the STM32F103RC. I have also tried that without any modification except that I change from external to internal oscillator. Same issue, the ADC Irq never executes. I haven't gone deeply to try to understand what the "T6" means, but I'm guessing it has something to do with temperature range. According to the graphic in stm32CUBEMX the change of oscillator should not affect, especially when everything else work just fine. On the other hand, why is not the internal oscillator an option in the Workbench?! If I change to a STM32F302R8, than you have an option to choose Internal Oscillator.

I Tried to find the 5.1.0 version of the SDK, but it seems like it's not available for download. Only latest version.

I know I should just give up and order a supported card (I have actually done that already), but I have spent so much time already on this, and I very seldom give up...

I just don't want to die with this unsolved... 🙂

Thanks again.

Laurent Ca...
Lead II

Dear @DBran.1​ 

Do you have still this problem to solve?

Best regards

Laurent Ca...

Laurent Ca...
Lead II

Dear @DBran.1​ 

I guess you don't have to solve this problem anymore, therefore I consider this thread closed.

If not, feel free to reopen it by posting a new answer.

Best regards

Laurent Ca...

note: personally I cannot access to the link you have provided (perhaps too old).