Skip to main content
Frakk
Associate
December 15, 2019
Solved

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

  • December 15, 2019
  • 5 replies
  • 2029 views

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.
Best answer by AntoineC

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
December 19, 2019

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
December 20, 2019

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
December 20, 2019

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
December 23, 2019

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
February 12, 2020

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