Labs / Electronic modules

GraftSense - EC11-based Rotary Encoder Module (Open Version)

Author: Li Zisheng · Source: FreakStudio open documentation, v1.4 · License: CC BY 4.0 · Driver code (input/rotaryencoder_driver): MIT License

Contents
GraftSense - EC11-based Rotary Encoder Module (Open Version)
GraftSense - EC11-based Rotary Encoder Module (Open Version)

I. Module Introduction

EC11-based Rotary Encoder Module is a EC11 -based rotary encoder module that integrates a filter circuit, status indicator light and sensor interface. With the EC11 encoder as the core, it can output two encoded signals, namely RE_DT and RE_CLK, and is equipped with a key function. Suitable for maker projects, electronic device development and other scenarios, it realizes precise rotary control and interactive feedback, and provides a reliable solution for system parameter adjustment, human-computer interaction and other demands.

II. Introduction to Major Chips

Here, we use the EC11 rotary encoder component with 20 pulses and 20 positioning points.

2.1 Chip Overview

EC11 series rotary encoder is an incremental encoder based on mechanical contacts, which is widely used in audio equipment, home appliance control, industrial electronics and human-machine interaction interfaces. Its main function is to convert rotary angular displacement into electrical pulse signals for detecting rotation direction and step position, and it can be optionally equipped with a key function.

GraftSense - EC11-based Rotary Encoder Module (Open Version)

2.2 Pin Definition

EC11 typically has 5 pins, as shown in the following figure:

GraftSense - EC11-based Rotary Encoder Module (Open Version)

2.3 Functional Block Diagram

20 pulses and 20 positioning points EC11 rotary encoder component has the following structure:

GraftSense - EC11-based Rotary Encoder Module (Open Version)

The names and functions of the respective components are as follows:

Its working principle is that EC11 outputs incremental rotation signals through two signal channels (Pin A and Pin B). During rotation, staggered pulses are generated in the A and B signal channels; by comparing the phase relationship between the two, the rotation direction (clockwise or counterclockwise) can be determined:

GraftSense - EC11-based Rotary Encoder Module (Open Version)

Simply put, it is as follows:

It is not difficult to find that whenever phase A or phase B undergoes a level transition, the rotation direction can be determined simply by detecting the state of the other phase:

At the same time, the number of rotation steps (increment) can be determined in combination with pulse counting.

Here, the EC11 rotary encoder also comes with a push switch (pins D and E): when the encoder is pressed, its internal mechanical structure triggers a key signal, which is commonly used for control or operation confirmation.

2.4 Performance Parameters

GraftSense - EC11-based Rotary Encoder Module (Open Version)
GraftSense - EC11-based Rotary Encoder Module (Open Version)
GraftSense - EC11-based Rotary Encoder Module (Open Version)
GraftSense - EC11-based Rotary Encoder Module (Open Version)
GraftSense - EC11-based Rotary Encoder Module (Open Version)
GraftSense - EC11-based Rotary Encoder Module (Open Version)

2.5 Reference Circuit

None.

2.6 Chip Configuration

None.

No communication interface.

2.8 PCB Routing Precautions

None.

III. Circuit Source Engineering and Module Usage Instructions

3.1 Circuit Source Engineering

To obtain the source project of the circuit, please follow the official account [Freak Embedded]

3.2 Module Usage Instructions

The schematic diagram of this module is shown below:

SCH_EC11-Based_Rotary_Encoder_Module_v1.0_2025-10-23.pdf 1.8 MB

GraftSense - EC11-based Rotary Encoder Module (Open Version)
GraftSense - EC11-based Rotary Encoder Module (Open Version)

This module provides an interface for outputting a pair of pulse signals (DIN0 and DIN1): The DIN0 interface corresponds to the RE_DT / A phase signal, and the DIN1 interface corresponds to the RE_CLK / B signal. As a pair of pulse signals output by the rotary encoder, they can be used to implement rotation direction identification and counting functions, and provide precise rotation control feedback for external devices such as microcontrollers.

Its working principle is that EC11 outputs incremental rotation signals through two signal channels (Pin A and Pin B). During rotation, staggered pulses are generated in the A and B signal channels; by comparing the phase relationship between the two, the rotation direction (clockwise or counterclockwise) can be determined:

GraftSense - EC11-based Rotary Encoder Module (Open Version)

Simply put, it is as follows:

It is not difficult to find that whenever phase A or phase B undergoes a level transition, the rotation direction can be determined simply by detecting the state of the other phase:

At the same time, the number of rotation steps (increment) can be determined in combination with pulse counting.

Here, our module does not have an output interface for the push switch (pin D, pin E).

3.3 Application Experiment

Here, we use the GraftPort-RP2040 development board for testing, and connect the EC11-based rotary encoder module to communicate with the main controller via the DIO interface.

Here, we first use the HY2.0-4P connection cable to connect the module to the GraftPort-RP2040 development board's DIO0 interface:

GraftSense - EC11-based Rotary Encoder Module (Open Version)

The module connections are shown in the following table:

Development Board Pins

Module Pins

Description

Pin 6

DIN0

Phase A signal input pin

Pin 7

DIN1

B phase signal input pin

Here, we need to search for the relevant driver packages on uPyPI: https://upypi.net/zh/

GraftSense - EC11-based Rotary Encoder Module (Open Version)

Enter rotaryencoder_driver to search, and the following will be displayed:

GraftSense - EC11-based Rotary Encoder Module (Open Version)

Click to copy the local installation command:

GraftSense - EC11-based Rotary Encoder Module (Open Version)

Here, we can use the mip tool to import module driver library code. Below are the usage commands for the mpremote tool:

mpremote mip install github:FreakStudioCN/GraftSense-Drivers-MicroPython/input/rotaryencoder_driver

After importing the rotary encoder driver - MicroPython driver code, copy the following main.py code into our project:

# Python env   : MicroPython v1.23.0
# -*- coding: utf-8 -*-        
# @Time    : 2024/9/19 7:46 PM
# @Author  : Li Qingshui
# @File    : main.py       
# @Description : Timer class experiment, read the value of a rotary encoder and use a timer for software debouncing

# ======================================== Import Modules =========================================

# Import time-related modules
import time
# Import custom driver module
from processbar import ProgressBar
from ec11encoder import EC11Encoder

# ======================================== Global Variables ============================================

# ======================================== Functions ============================================

# ======================================== Custom Classes ============================================

# ======================================== Initialization ==========================================

# Power-on delay of 3 s
time.sleep(3)
# Print debug information
print("FreakStudio : Using GPIO read Rotary Encoder value, use software debounce by timer")

# Create an EC11 rotary encoder object, using GPIO10 and GPIO11 as phase A and phase B, and GPIO12 as the button
# If you want to change the rotation direction in which the encoder count increases (for example, from counterclockwise increasing to clockwise increasing)
# just swap the values of the pin_a and pin_b parameters when initializing the encoder object
encoder = EC11Encoder(pin_a=6, pin_b=7)
# Create the terminal progress bar object to display progress; 20 rotations reach 100%
progress_bar = ProgressBar(max_value=20)

# ========================================  Main Program  ===========================================

# Get the rotation count and button state in the main loop
while True:
    # Get the rotation count
    current_rotation = encoder.get_rotation_count()
    print(f"Rotation count: {current_rotation}")
    # Update the progress bar
    progress_bar.update(current_rotation)
    # When the button is pressed, reset the progress bar
    if encoder.is_button_pressed():
        progress_bar.reset()
    # Update every 10ms
    time.sleep_ms(10)

Burn the code, open a terminal, and use the mpremote tool to connect to the main controller; the output is as follows:

It can be seen that when we select an encoder, the terminal output will increase or decrease synchronously:

IV. Drivers

rotaryencoder_driver.zip 12 KB

None.

VI. Revision History

Document Version

Date of Revision

Modifier

Modified Content

v1.0

2025-09-04

ben0i0d

Complete the initial version of schematic diagram and PCB design

v1.1

2025-10-23

Li Zisheng

Added Section 2.8 PCB Routing Notes

Revised Section 3, Instructions for Circuit Source Engineering and Module Usage, and added a secondary heading:

3.1 Circuit Source Engineering, 3.2 Module Usage Instructions, 3.3 Application Experiments

The BOM sheet has not been finally checked, the driver has not been re-verified, and the 3.3 application experiment

Not yet specified.

v1.2

2025-12-29

Li Zisheng

Added application experiments and production files

v1.3

2025-12-31

Xin Ruili

Create an open version of the document based on the internal document version v1.2.

v1.4

2026-03-29

Xin Ruili

Modified the application experiment section.

VII. Relevant Materials

7.1 Chip Datasheet

C470795_Rotary_Encoder_EC1110120201_Datasheet_WJ277337.PDF 2.4 MB

7.2 PCB Silkscreen Specific Icons

GraftSense - EC11-based Rotary Encoder Module (Open Version)