1. Introduction
Volume knobs on car stereos and scroll wheels on infotainment systems both use exactly this component to sense both how far and which direction a knob has been turned. In this experiment, a rotary encoder is wired to the STM32F070RB, and by reading two signals that are slightly out of phase with each other, the microcontroller determines not just that rotation occurred, but which direction it happened in, maintaining a running position count.
2. Scope
This experiment covers understanding quadrature encoding and how the relative phase relationship between two digital signals reveals rotation direction, configuring an external interrupt on one encoder channel, and reading the second channel's state at the moment of interrupt to determine direction. This introduces quadrature decoding, a technique that derives directional information purely from the relative timing of two signals.
3. Prerequisite
3.1 Hardware
-
STM32 Nucleo-F070RB development board
-
Rotary encoder module, such as a KY-040 or similar, with CLK, DT, and SW pins
-
Breadboard and jumper wires
-
Micro-USB cable
-
PC with PuTTY
3.2 Software
-
STM32CubeMX (standalone)
-
STM32CubeIDE
-
ST-LINK USB driver
-
PuTTY, or an equivalent serial terminal application
Community Q&A
0 questionsAsk questions and get answers from our community and staff moderators.
No questions yet — be the first to start the conversation!
Ask a Question
Please log in to ask a question or post a reply.
Login to Participate