PaulStoffregen / Encoder/ Encoder requires interrupt pins, but this board does not have any

Post here first, or if you can't find a relevant section!
Post Reply
GreenBrainArc
Posts: 1
Joined: Mon Jul 27, 2020 6:21 am

PaulStoffregen / Encoder/ Encoder requires interrupt pins, but this board does not have any

Post by GreenBrainArc »

Hello, first of all sorry for my bad English
I have the following problem:
I would like to control the LCDML with a rotary encoder.
Unfortunately I am missing in interrupt_pins.h
the definition for the STM32F103C
Can someone help me there?
Ollie
Posts: 6
Joined: Wed Mar 18, 2020 4:46 am

Re: PaulStoffregen / Encoder/ Encoder requires interrupt pins, but this board does not have any

Post by Ollie »

The STM32F103C has 16 EXTI lines that can be programmed to trigger interrupts from the GPIO pins. That is not the proper method in case there is no electronic RC filtering of the signals. In practice, it is very difficult to have the proper values for the RC filtering.

A better method is to use software filtering. For example, you can have a timer to generate an interrupt on every 125 us to read the all the rotary encoder input values. In that routine, you can detect if a new value has been unchanged for 500 us. If less than that, the value is part of the normal contact bouncing and should be ignored. This has very low CPU loading and detects the real changes very fast. The interrupt routine can do at the same time the normal A and B channel processing.
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: PaulStoffregen / Encoder/ Encoder requires interrupt pins, but this board does not have any

Post by dannyf »

you may find it helpful that a small capacitor is much simpler and more robust a solution here.

If you have to go down the software path, i would rely on 1) a solution based on a state machine - it is much more resistant to switch bounces; and 2) see if you can slow down the read. For example, once a change of state has been detected, read the pin sometime later.

something like this:
Pin change ISR:
set a flag;
disable pin change interrupt;

in the main code:
if (pin change flag is set) time stamp a variable
if (pin change flag is set and enough time has passed) {
read the pin;
clear the pin change flag;
re-enable pin change interrupt;
}
unless you are dealing with really fast fingers, a few ms is good enough.
Post Reply

Return to “General discussion”