Rotary encoder with blue pill

Post here all questions related to LibMaple core if you can't find a relevant section!
rsonnicksen
Posts: 9
Joined: Fri Dec 16, 2022 4:28 pm

Re: Rotary encoder with blue pill

Post by rsonnicksen »

@dannyf,
Yes, I could poll the pins, but that would require my loop speed to be very fast. My encoder has 1024 pulses per revolution, so my loop time would need to be very short. Or, driving the polling with a timer would require the use of interrupts, which CAN be very useful, but I definitely try to avoid them if I can because if you're not careful they can have adverse effects on your program. I am using a timer interrupt in InputCapture mode to read the PPM signal from an RC receiver.
The whole beauty of using peripherals (timer/counter) in encoder mode, is to completely eliminate the need for any software to track the encoder position. My issue turned out to be that I wasn't properly disabling and updating the timer during the configuration, so it wasn't keeping the new configuration. I got the program from sigi that worked, and reverse engineered it to find my mistake.
The only downside to using the timer peripheral for encoder tracking is that there are only a limited number of timers (4) in the BluePill (STM32F103C8) so each encoder uses up the whole timer.
In my application I want to control 3 axis each with a quadrature encoder and a DC motor driven by a PWM motor controller. That will require the use of all 4 timers right there, so any other functions requiring timers are not possible.
It may mean I need to divide my application into two areas, each controlled by a separate BluePill and have them communicate to each other via some form of serial interface (I2C, Serial, SPI) which is not really a desirable situation.

Thanks for your feedback!!
sigi
Posts: 57
Joined: Mon Sep 28, 2020 3:17 pm

Re: Rotary encoder with blue pill

Post by sigi »

@ rsonnicksen

when u do not want to use 2 bluepills in the same project because u need more timers, pins etc u need a bigger compatible bluepill ! (in the case u wanted in that way)

look for a STM32F103Z, "Z", or R, T V... they have more pins and/or memory and are 100% compatible with the normal bluepill code...
The problem is they are a litle more hard to find in boards flavor...

See attachment...

link to one ..
https://www.aliexpress.com/item/1005004 ... t95zw5Dkbk

Image
Attachments
Comparative.rar
(9.72 KiB) Downloaded 106 times
Post Reply

Return to “General discussion”