2024-11-22 02:15 PM - edited 2024-11-23 01:57 PM
Hi,
I am working on the electronics design and configuring the micro through CubeMX to decide which pins to connect to which pins.
We need to read a quadrature encoder (ideally also with the index) and at the moment we have wired the micro/PCB as per attached IOC file.
The pins that we would like to use are: uC_IO_EXP_1, uC_IO_EXP_2, uC_IO_EXP_3 and uC_IO_EXP_4 because they are the ones that go to the external PCBs (currently set to "pinned" in the IOC file). But with the current timer configuration the encoder mode does not seem to be available on those pins despite being timer pins.
I tried rearranging timers and functionality, but haven't yet found a way to enable the encoder functionality. Could someone kindly help with the configuration (or suggestions about it)?
The only constraint is that as long as the other PWM signals (they are named with "PWM" in them) provide a PWM output on those pins, the timer currently assigned to them can be changed to another one.
If it is not possible then could you please suggest the next lowest CPU intensive solution that use some peripheral (i.e. not GPIO interrupts because the speed of the encoder can sometimes be quite high and we want to leave plenty of room for CPU to do very many CPU intensive other tasks in the future).
Any suggestion is very much appreciated.
Thank you as always :)
Solved! Go to Solution.
2024-11-26 10:00 AM
You've already answered yourself: any solution which does not involve hardware redesign, is software intensive.
The canonical encoder readout in software is through a periodical process, where period is shorter than half of the shortest anticipated distance between input signal edges. Although in German, a very good treatise of the problem is at https://www.mikrocontroller.net/articles/Drehgeber .
JW
2024-11-26 09:41 AM - edited 2024-11-26 09:42 AM
Could anybody please help with this?
It would be very much appreciated :)
2024-11-26 10:00 AM
You've already answered yourself: any solution which does not involve hardware redesign, is software intensive.
The canonical encoder readout in software is through a periodical process, where period is shorter than half of the shortest anticipated distance between input signal edges. Although in German, a very good treatise of the problem is at https://www.mikrocontroller.net/articles/Drehgeber .
JW
2024-12-01 03:32 PM
Thank you @waclawek.jan