cancel
Showing results for 
Search instead for 
Did you mean: 

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

Frakk
Associate II

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!

1 ACCEPTED SOLUTION

Accepted Solutions
AntoineC
ST Employee

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

View solution in original post

5 REPLIES 5
AntoineC
ST Employee

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
Associate II

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

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
Associate II

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
ST Employee

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