Skip to main content
Frakk
Associate
Dec 15, 2019 4:53 AM UTC
Solved

Encoder "reverse counting direction" checkbox not working in ST MC Workbench 5.4.3. What am I missing?

Hi all,

I have been pulling my hair out trying different ways to reverse my encoder counting direction.

The checkbox "reverse counting direction" in Speed Sensing section does not seem to make any difference. I am using Attolic TrueSTUDIO IDE, and the Monitor in WB to check my speed.

The corresponding code "#define ENC_INVERT_SPEED        DISABLE" in drive_parameters.h stays "DISABLE" no matter what I set in WB, but if I change measurement errors or FIFO depth settings, they will be changed in the very same source file.

I also tried to manually change the code to ENABLE, with no change. Also tried to edit the TIM2 Initialization code and tried downcounting mode (instead of upcounting) with no success.

Has anyone had similar issues? Any help and feedback would be greatly appreciated!

This topic has been closed for replies.
AntoineC
AntoineCBest answer
ST Employee
Feb 12, 2020 8:43 AM UTC

Hello,

You have to "Generate" in the wokbench because it is considered as a change of your Hardware.

"Update" is only for software modification.

Thanks and Best Regards

Antoine

5 replies

AntoineC
ST Employee
Dec 19, 2019 8:09 AM UTC

Hello,

With the checkbox "reverse counting direction" you can reverse the signals wires of the encoder.

The corresponding code :

  • Reversed

0690X00000BunVsQAJ.png

  • Not reversed

0690X00000BunVnQAJ.png

You can find more details in the reference manual of your STM32. Have a look to the 'TIMx_CCER' register and 'Encoder Interface Mode'.

Antoine

Frakk
FrakkAuthor
Associate
Dec 20, 2019 2:50 AM UTC

Hi Antoine,

Thank you very much for your response. I will try this again and change it manually but as I the title says, the checkbox in the WB does not make any difference in the generated code. The reversal/inversion is always disabled.

AntoineC
ST Employee
Dec 20, 2019 9:05 AM UTC

Hello,

In fact, yes, "#define ENC_INVERT_SPEED" is not used in the generated code. The checkbox in the WB make differences in the main .c. It changes polarity like the pictures I sent you in my previous answer and you can use the polarity to make the inversion enabled.

Antoine

Frakk
FrakkAuthor
Associate
Dec 23, 2019 4:25 PM UTC

I further investigated and were able to make it work.

The main issue I had was the fact that WB did not Update the code in main.c whet I clicked "Update". I must click "Generate" for the change to happen. I hope this is not on purpose because simple things like this should just update.

On an other bug: Calling HAL_TIM_SlaveConfigSynchronization(&htim1, &sSlaveConfig) in main.c always throws an error because a typo.

Correct function: HAL_TIM_SlaveConfigSynchro(&htim1, &sSlaveConfig)

AntoineC
AntoineCBest answer
ST Employee
Feb 12, 2020 8:43 AM UTC

Hello,

You have to "Generate" in the wokbench because it is considered as a change of your Hardware.

"Update" is only for software modification.

Thanks and Best Regards

Antoine