Skip to the content
2 layers147.8 × 133.6 mmPICO DEV M3 KEYPAD, the printed circuit board in 3D

A library for setting up magnetic rotary encoding in C/C++ & MicroPython, The library also features a haptics controller which allows you to connect and control a vibration motor as a step count haptic feedback.

Size
147.8 × 133.6 mm
Copper layers
2
Thickness
1.6 mm
Parts
50
Nets
41
Pads
261
Tracks, vias
672, 52
Pours
1
Routed
Yes
KiCad
KiCad 6 (file 20211014)
Created
8 May 2019
Updated
4 May 2023

Overview

PICO DEV M3 KEYPAD is an open-source printed circuit board by ahmsville, from the ahmsville/Magnetic_rotary_encoding repository on GitHub, published under the GPL-3.0 licence. It is a 2-layer board of 147.8 × 133.6 mm with 50 parts on 41 nets, routed with 672 tracks and 52 vias.

Its parts include 15 resistors, 12 capacitors, 5 connectors and 1 IC. It belongs with the keyboards and input boards and the RP2040 boards of this library.

README

README.md

Magnetic_Rotary_Encoding

Learn more about this project -

BUILD INSTRUCTIONS

Hardware Options

20221123_121114_1_2

1. Magnetic Rotary Encoder

This is standalone encoder made to connect to a seperate microcontroller like an Arduino board, this version has a base resolution of 72, extendable up to 72000 steps per revolution. magnetic rotary encoder pinout

Features:

  • Capacitive touch / button input
  • Addressable Led ring (18 LEDs)

Supported Boards / Platform:

  • All Arduino Boards
  • Raspberry Pi Pico C/C++ SDK
  • All Micropython-Supported Boards

2. Magnetic Rotary Encoder MINI

This is standalone encoder similar to the first option, only with a small form factor, this version has a base resolution of 36, extendable up to 36000 steps per revolution. magnetic rotary encoder mini pinout

Features:

  • Capacitive touch / button input
  • Addressable Led ring (12 LEDs)

Supported Boards / Platform:

  • All Arduino Boards
  • Raspberry Pi Pico C/C++ SDK
  • All Micropython-Supported Boards

3. Pico Dev M3

This is a full fledged development board combined with the magnetic rotary encoder, its built with the Raspberry Pi RP2040 microcontroller chip with a base resolution of 36, extendable up to 36000 steps per revolution. pico dev m3 pinout

Features:

  • RP2040 chip, Dual-core Arm Cortex-M0+ processor at 133 MHz
  • 264kB on-chip SRAM
  • 128Mb on-board QSPI flash
  • 19 multifunction GPIO pins, with 2 analog inputs
  • 2 UARTs
  • 2 SPI controllers
  • 2 I2C controllers
  • 16 PWM channels
  • USB 1.1 controller with host and device support
  • 8 PIO state machines
  • USB type C
  • Lipo charging
  • onboard Button input
  • Addressable Led ring (18 LEDs)

Supported Platform:

  • RP2040 C/C++ SDK
  • Micropython

How to connect and use the Ahmsville labs magnetic rotary encoder.

There are three ways to connect the magnetic rotary encoder, all with their benefits and draw backs.

1. Analog only Detection:

in this mode the library uses just the signals from the hall effect sensors to make sense of the rotation of the encoder. the benefit of this mode is that you only need two analog pins to do all the rotation encoding, also been analog means you can use the libraries built in interpolation mode for an extremely high and granular resolution. The drawback is, this mode requires constant polling of the sensors which is not ideal for a complex system, also if the board does not have analog pins or if your setup cannot spare any of them, then you cannot use this mode.

Connection

To use this mode, simply connect ENC-1 and ENC-2 to two analog input pins, you may also connect the LED pin to any available pin on the board. VCC should be connected to the same voltage level used by the microcontroller on the boards, so power the encoder with 5v if the board uses 5v, and power it with 3.3v it the board uses 3.3v, you should offcus also connect the GND pin.

Asset 1

Code

To test the example code, all you have to do is activate the analog only mode and change the pin assignment according to your connections. For the mode, you have the option to choose continuous rotation detection which returns a continuous count in either direction, or absolute positioning, which returns a value within the encoder’s base resolution, you can also choose the extended interpolated resolution mode for a super-duper high resolution.

C/C++

c++
#define ENCMODE 1 // BASE RESOLUTION ANALOG ONLY
//#define ENCMODE 2 // BASE RESOLUTION ANALOG ONLY ABSOLUTE POSITIONING
//#define ENCMODE 3 // EXTENDED RESOLUTION ANALOG ONLY
//#define ENCMODE 4 // BASE RESOLUTION ANALOG AND DIGITAL
//#define ENCMODE 5 // BASE RESOLUTION ANALOG AND DIGITAL ABSOLUTE POSITIONING
//#define ENCMODE 6 // EXTENDED RESOLUTION ANALOG AND DIGITAL
//#define ENCMODE 7 // BASE RESOLUTION DIGITAL ONLY
//#define ENCMODE 8 // BASE RESOLUTION DIGITAL ONLY ABSOLUTE POSITIONING
c++
#define E1_ADC_PIN 26 // ADC PIN for hall sensor 1
#define E2_ADC_PIN 27 // ADC PIN for hall sensor 2

MicroPython

python
ENCMODE = 1 # BASE RESOLUTION ANALOG ONLY
#ENCMODE  = 2 # BASE RESOLUTION ANALOG ONLY ABSOLUTE POSITIONING
#ENCMODE  = 3 # EXTENDED RESOLUTION ANALOG ONLY
#ENCMODE  = 4 # BASE RESOLUTION ANALOG AND DIGITAL
#ENCMODE  = 5 # BASE RESOLUTION ANALOG AND DIGITAL ABSOLUTE POSITIONING
#ENCMODE  = 6 # EXTENDED RESOLUTION ANALOG AND DIGITAL
#ENCMODE  = 7 # BASE RESOLUTION DIGITAL ONLY
#ENCMODE  = 8 # BASE RESOLUTION DIGITAL ONLY ABSOLUTE POSITIONING
python
E1_ADC_PIN = 26  # ADC PIN for hall sensor 1
E2_ADC_PIN = 27  # ADC PIN for hall sensor 2

2. Analog and Digital Detection:

in this mode the library uses the signals from the hall effect sensors together with two additional digital interrupt enabled input pins. This mode has all the same features and benefits as the analog only detection mode without the need for constant polling of the hall effect sensors, this is extremely usefull for complex systems, as the interrupt pins notify the code of when a rotation occurs, so constant polling is not needed, this mode is in fact the mode used on the Ahmsville Dial V2. Please note that the code will return to constant polling if you select the Extended Resolution mode, since this process requires interpolation between the encoder’s steps.

Connection

To use this mode, simply connect ENC-1 and ENC-2 to two analog input pins, and E1-INT1 and E2-INT1 to two interrupt enabled pins on the board, you may also connect the LED pin to any available pins on the board. VCC should be connected to the same voltage level used by the microcontroller on the boards, so power the encoder with 5v if the board uses 5v, and power it with 3.3v it the board uses 3.3v, you should offcus also connect the GND pin.

Asset 2

Depending on your encoder version, you may also need to bridge the config pads on the PCB to use this mode. ASDADASDASDASDAS

Code

To test the code, all you have to do is activate the analog and digital mode and also change the pin assignment according to your connections. For this mode, you also have the option to choose continuous rotation detection which returns a continuous count in either direction, or absolute positioning, which returns a value within the encoder’s base resolution, you can also choose the extended interpolated resolution mode for a super-duper high resolution.

C/C++

c++
//#define ENCMODE 1 // BASE RESOLUTION ANALOG ONLY
//#define ENCMODE 2 // BASE RESOLUTION ANALOG ONLY ABSOLUTE POSITIONING
//#define ENCMODE 3 // EXTENDED RESOLUTION ANALOG ONLY
#define ENCMODE 4 // BASE RESOLUTION ANALOG AND DIGITAL
//#define ENCMODE 5 // BASE RESOLUTION ANALOG AND DIGITAL ABSOLUTE POSITIONING
//#define ENCMODE 6 // EXTENDED RESOLUTION ANALOG AND DIGITAL
//#define ENCMODE 7 // BASE RESOLUTION DIGITAL ONLY
//#define ENCMODE 8 // BASE RESOLUTION DIGITAL ONLY ABSOLUTE POSITIONING
c++
#define E1_INT1 16 // hall sensor 1 interrupt pin 1
#define E2_INT1 18 // hall sensor 2 interrupt pin 1

#define E1_ADC_PIN 26 // ADC PIN for hall sensor 1
#define E2_ADC_PIN 27 // ADC PIN for hall sensor 2

MicroPython

python
#ENCMODE = 1 # BASE RESOLUTION ANALOG ONLY
#ENCMODE  = 2 # BASE RESOLUTION ANALOG ONLY ABSOLUTE POSITIONING
#ENCMODE  = 3 # EXTENDED RESOLUTION ANALOG ONLY
ENCMODE  = 4 # BASE RESOLUTION ANALOG AND DIGITAL
#ENCMODE  = 5 # BASE RESOLUTION ANALOG AND DIGITAL ABSOLUTE POSITIONING
#ENCMODE  = 6 # EXTENDED RESOLUTION ANALOG AND DIGITAL
#ENCMODE  = 7 # BASE RESOLUTION DIGITAL ONLY
#ENCMODE  = 8 # BASE RESOLUTION DIGITAL ONLY ABSOLUTE POSITIONING
python
E1_INT1 = 16 # hall sensor 1 interrupt pin 1
E2_INT1 = 18 # hall sensor 2 interrupt pin 1

E1_ADC_PIN = 26 # ADC PIN for hall sensor 1
E2_ADC_PIN = 27 # ADC PIN for hall sensor 2

3. Digital only Detection:

in this mode the library uses only digital interrupt enabled input pins; four of them. This mode is similar in operation to traditional rotary switches, the analog signals from the hall effect sensors have been converted to digital signals using comparators, so no analog input pins are required. This mode was developed for systems that don’t have or cannot spare analog input pins, its also the fastest mode and requires zero polling, which is why I used it to encode the Pick N Place Wheel. Because this mode uses digital signals alone, you cannot use the interpolated extended resolution mode that is available in the previous modes.

Connection

To use this mode, simply connect E1-INT1, E1-INT2, E2-INT1 and E2-INT2 to four interrupt enabled pins on the board, you may also connect the LED pin to any available pins on the board. VCC should be connected to the same voltage level used by the microcontroller on the boards, so power the encoder with 5v if the board uses 5v, and power it with 3.3v it the board uses 3.3v, also connect the GND pin.

Asset 3

Code

To test the code, all you have to do is activate the digital only mode and also change the pin assignments according to your connections. For this mode, you have the option to choose continuous rotation detection which returns a continuous count in either direction, or absolute positioning, which returns a value within the encoder’s base resolution.

C/C++

c++
//#define ENCMODE 1 // BASE RESOLUTION ANALOG ONLY
//#define ENCMODE 2 // BASE RESOLUTION ANALOG ONLY ABSOLUTE POSITIONING
//#define ENCMODE 3 // EXTENDED RESOLUTION ANALOG ONLY
//#define ENCMODE 4 // BASE RESOLUTION ANALOG AND DIGITAL
//#define ENCMODE 5 // BASE RESOLUTION ANALOG AND DIGITAL ABSOLUTE POSITIONING
//#define ENCMODE 6 // EXTENDED RESOLUTION ANALOG AND DIGITAL
#define ENCMODE 7 // BASE RESOLUTION DIGITAL ONLY
//#define ENCMODE 8 // BASE RESOLUTION DIGITAL ONLY ABSOLUTE POSITIONING
c++
#define E1_INT1 16 // hall sensor 1 interrupt pin 1
#define E1_INT2 17 // hall sensor 1 interrupt pin 2
#define E2_INT1 18 // hall sensor 2 interrupt pin 1
#define E2_INT2 19 // hall sensor 2 interrupt pin 2

MicroPython

python
#ENCMODE = 1 # BASE RESOLUTION ANALOG ONLY
#ENCMODE  = 2 # BASE RESOLUTION ANALOG ONLY ABSOLUTE POSITIONING
#ENCMODE  = 3 # EXTENDED RESOLUTION ANALOG ONLY
ENCMODE  = 4 # BASE RESOLUTION ANALOG AND DIGITAL
#ENCMODE  = 5 # BASE RESOLUTION ANALOG AND DIGITAL ABSOLUTE POSITIONING
#ENCMODE  = 6 # EXTENDED RESOLUTION ANALOG AND DIGITAL
#ENCMODE  = 7 # BASE RESOLUTION DIGITAL ONLY
#ENCMODE  = 8 # BASE RESOLUTION DIGITAL ONLY ABSOLUTE POSITIONING
python
E1_INT1 = 16  # hall sensor 1 interrupt pin 1
E1_INT2 = 17  # hall sensor 1 interrupt pin 2
E2_INT1 = 18  # hall sensor 2 interrupt pin 1
E2_INT2 = 19  # hall sensor 2 interrupt pin 2

Complimentary Input on the Encoder

You have two options when it comes to complimentary input on the encoder, you can choose to use capacitive touch or a normal push button, both the capacitive touch and the push button will be included with the kit if you buy it from my store. To use capacitive touch, you will need an Arduino board, if you use other development boards like the ESP32 or Raspberry PI Pico, you will have to use the push button.

SAGSAFFF zczczczcc

Capacitive touch

To use the capacitive touch on an Arduino, you must have assembled the encoder according to the instructions, so that you can simply connect CT1 and CT2 to two available pins and then update the pin assignment in the example code accordingly.

C/C++

c++
#define CT1 5 // CAPACITIVE TOUCH (CT1)
#define CT2 6 // CAPACITIVE TOUCH (CT2)

Push button

To use the push button, you should solder the included button to the encoder board and then connect only CT1 to an available pin on the development board.

C/C++

c++
#define CT1 15 // PUSH BUTTON (CT1)

MicroPython

python
CT1 = 15 # PUSH BUTTON (CT1)

Parts

50
QtyValueFootprintReferences
120.1ufCapacitor_SMD:C_0603_1608MetricC1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12
125.1KResistor_SMD:R_0603_1608MetricR3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14
12Gateron_SwitchMY CUSTOM LIBRARY:GATERON SWITCHMK1, MK2, MK3, MK4, MK5, MK6, MK7, MK8, MK9, MK10, MK11, MK12
31KResistor_SMD:R_0603_1608MetricR1, R2, R15
3LOGOLOGOG***, G***, G***
1clipboard:35357825-467e-4df7-85c8-061ca90a2ec3
1Conn_01x02_FemaleConnector_PinSocket_2.54mm:PinSocket_1x02_P2.54mm_VerticalJ2
1Conn_01x04_FemaleConnector_PinSocket_2.54mm:PinSocket_1x04_P2.54mm_VerticalJ1
1Conn_01x05_FemaleConnector_PinSocket_2.54mm:PinSocket_1x05_P2.54mm_VerticalJ4
1Conn_01x06_FemaleConnector_PinSocket_2.54mm:PinSocket_1x06_P2.54mm_VerticalJ5
1Conn_01x08_FemaleConnector_PinSocket_2.54mm:PinSocket_1x08_P2.54mm_VerticalJ3
1PICO_DEV_M3MY CUSTOM LIBRARY:PICO DEV M3U1
1RJ45_LED_ShieldedMY CUSTOM LIBRARY:RJ45_LED_SHIELDEDSERIAL_CONN1

More from ahmsville/Magnetic_rotary_encoding

1
  • 2 layers87.6 × 83.8 mmPi Pico Stepper controller, the printed circuit board in 3D

    Pi Pico Stepper controller

    ahmsville/Magnetic_rotary_encoding

    A library for setting up magnetic rotary encoding in C/C++ & MicroPython, The library also features a haptics controller which allows you to connect and control a vibration motor as a step count haptic feedback.

    25 parts131GPL-3.0

Similar boards

  • 2 layers187.2 × 26.6 mmBlade12, the printed circuit board in 3D

    Blade12

    opulo-inc/lumenpnp

    The LumenPnP is an open source pick and place machine.

    50 parts3.7k
  • 2 layers45.7 × 25.9 mmAccessory, the printed circuit board in 3D

    Accessory

    usbarmory/usbarmory

    USB armory - The open source compact secure computer

    50 parts1.5k
  • 2 layers21 × 31.5 mmK1-aioc, the printed circuit board in 3D

    K1-aioc

    skuep/AIOC

    Ham Radio All-in-one-Cable

    50 parts1.4kMIT
  • 2 layers42 × 32.5 mmLipoboard, the printed circuit board in 3D

    Lipoboard

    hackclub/OnBoard

    💡 Join 1,000 teenagers and make your first PCB with a $100 grant!

    50 parts915
  • 2 layers101 × 31.5 mmManagement, the printed circuit board in 3D

    Management

    dennisss/dacha

    Monorepo for awesome tools/projects/libraries

    50 parts397Apache-2.0
  • 2 layers123.9 × 94.4 mmRoba R, the printed circuit board in 3D

    Roba R

    kumamuk-git/roBa

    50 parts363GPL-3.0
  • 2 layers50 × 25 mmMbus master, the printed circuit board in 3D

    Mbus master

    roarfred/AmsToMqttBridge

    Minimalistic system to read AMS/HAN data from electrical meter

    50 parts223

Questions

How big is the PICO DEV M3 KEYPAD PCB?

It measures 147.8 × 133.6 mm and has 2 copper layers, 1.6 mm thick.

What parts does the PICO DEV M3 KEYPAD use?

50 parts. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the PICO DEV M3 KEYPAD KiCad files?

From the ahmsville/Magnetic_rotary_encoding repository on GitHub, at the commit this page was made from: the board is PICO DEV M3/PICO DEV M3 KEYPAD/PICO DEV M3 KEYPAD.kicad_pcb and its schematic PICO DEV M3/PICO DEV M3 KEYPAD/KEYS.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the PICO DEV M3 KEYPAD design in my own project?

Its repository publishes it under the GPL-3.0 licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).