2019-12-14 08:53 PM
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!
Solved! Go to Solution.
2020-02-12 12:43 AM
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
2019-12-19 12:09 AM
Hello,
With the checkbox "reverse counting direction" you can reverse the signals wires of the encoder.
The corresponding code :
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
2019-12-19 06:50 PM
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.
2019-12-20 01:05 AM
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
2019-12-23 08:25 AM
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)
2020-02-12 12:43 AM
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