Skip to the content
2 layers99.1 × 99.1 mmI2CHWC, the printed circuit board in 3D

A hardware controller providing rotary encoders, switches and potentiometer values via I2C

Size
99.1 × 99.1 mm
Copper layers
2
Thickness
1.6 mm
Parts
79
Nets
99
Pads
345
Tracks, vias
439, 39
Routed
Yes
KiCad
KiCad 5 (file 20171130)
Created
10 Mar 2019
Updated
28 Apr 2020

Overview

I2CHWC is an open-source printed circuit board by riban-bw, from the riban-bw/I2C-Hardware-Controller repository on GitHub, published under the GPL-3.0 licence. It is a 2-layer board of 99.1 × 99.1 mm with 79 parts on 99 nets, routed with 439 tracks and 39 vias.

Its parts include 59 diodes, 8 resistors, 6 connectors, 1 IC and 1 switch.

README

README.md

I2C-Hardware-Controller

A hardware controller providing rotary encoders, switches and potentiometers, interfacing with a host / master device via I2C 2-wire serial link and interrupt pin.

I2C Hardware Controller provides an interface to other applications via 30 continuous rotary encoders, 50 on / off switches and 64 end-stopped variable resistors (potentiometers). The link to the host device is via I2C which requires a clock and data signal. Power may be provided by the host as 3.3V or 5V. (Both devices must have a common ground.) The host may continuously poll the hardware controller (HWC) for changes or use a dedicated GPI signal to trigger interrupts (or similar event handling routine). Several HWC may be cascaded to increase the quantity of controls as required sharing I2C bus but each with its own individual interrupt GPI.

Rotary encoders provide the value of change since last read which is a positive integer for clockwise rotation and negative for counter-clockwise rotation. Slow rotation changes value by one unit whilst faster rotation changes value by ten units. It is the responsibility of the host device / application to store the absolute value calculated from the relative position values sent by the HWC.

Switches provide on / off value with contact bounce filtering to avoid false re-triggering. Rotary encoders commonly include a push switch which may be wired as a switch control or separate push buttons / toggle switches / slide switches / etc. may be attached.

Note: Switches and rotary encoders are X-Y multiplexed so cannot use a common ground, i.e. both polls of each switch and all three pins of a rotary encoder need to be connected to the HWC matrix. To simplify wiring, each rotary encoder and associated swich share a common matrix pin resulting in each rotary encoder / switch combination requiring 4 wires.

End-stopped variable resistance (potentiometer) controls provide a maximum of 12-bit resolution. A noise filter is applied which increases the latency and / or reduces the resolution of ADC. (Each bit reduction improves latency by one sample period and reduces noise.) Noise is the re-triggering of analogue values when there is no physical change of knob position. At 12-bit resolution this is quite common but reducing to 10-bits (default) cleans the signal significantly. The required filter may depend on the quality of potentiometer and wiring.

Note: End-stopped controls are multiplexed but share common +3.3V and 0V supply rails which may ease wiring but care should be taken to avoid electrical noise.

The core of the HWC is a STM32F103 from STMicroelectronics in the form of a Maple Leaf Mini development board. (Blue Pill board may be used with some modification to code - this may be accomodated in a future code update. Blue Pill shares common digital and analogue supplies so may be liable to more noise interference.) This board accepts 5V or 3.3V supply. It operates at 3.3V with some 5V tolerant pins. The HWC is designed to interface with 3.3V devices, e.g. Raspberry Pi but may work with 5V devices without modification.

8 potentiometers may be connected directly to the ADC inputs or up to 64 potentiometers may be connected via 8 x CD4051B analogue multiplex chips. To use the multiplexers, configuration bit 6 must be set with a jumper. Unused inputs are tied to ground to avoid false trigger due to noise. Separation of analogue and digital supply and ground is recommend as provided by the Maple Leaf Mini (but not the Blue Pill board). Suitable noise filtering capacitors should be placed between the analogue supply rails periodically.

The switches and rotary encoders (which are just a pair of bi-phase oriented switches) are connected as a X-Y matrix with a 1N4148 signal diode between one switch pole and the matrix bus. Fewer switches or rotary encoders may be connected as required.

The HWC acts as a I2C slave with I2C address configurable at boot time (via 6 DIP switches giving address range 0x08 - 0x47). The default with no links is 0x08. Connections to the master device is via 3 signal wires and 2 power wires thus:

text
    ---------------------                      -----------------------
    |                   |-------3.3/5V-------->|                     |
    | Master I2C device |-------I2C CLK------->| Hardware Controller |
    | e.g. Raspberry Pi |<------I2C SDA------->|                     |
    |                   |<--------INT----------|                     |
    |                   |---------0V-----------|                     |
    ---------------------                      -----------------------

The INT pin is held high under normal condition and goes low (0V) when there has been a change of value of any controller on the HWC. When all changed values have been read by the I2C master the INT signal returns high.

I2C Signal Flow

The I2C master may request the value of any control by sending the control number (1...144) as a single byte message then reading a 16-bit (two byte) response. If the I2C master sends a request for controller zero, the next I2C read will return the index of the first controller with a value that has changed since its last read. Pseudo code may look like:

text
while(GPI_INT == 0) {
  reg = I2C_GET_REG(0);
  if(reg != 0) {
    value = I2C_GET_REG(reg);
  }
}

Data value for potentiometers is a positive integer range 0..(2^n - 1) where n=number of bits, e.g. 0..4095 for 12-bit ADC. Data value for switches is 0 for off (open) and 1 for on (closed). Data value for rotary encoders is -1 for single counter-clockwise rotation detent and +1 for single clockwise rotation detent. If rotated faster than queried by I2C master then the relative offset increases accordingly, e.g. if rotated clockwise by 4 detents since last query, the next query result will be +4. This value must be read as a 16-bit signed integer.

The HWC has 144 registers, one for each possible control. Unpopulated controls will return a zero value.

RegisterUseRange
0Index of next control that has changed0 - 144 (0 for no change)
1 - 64Potentiometers 1 - 640 - 4096
65 - 114Switches 1 - 500 - 1
115 - 144Encoders 1 - 30-32768 - 32767

It is possible to write a command to register 0.

Command IDCommandParameters
0ResetResets all values to zero and clears dirty flags (and hence interrupt)

Parts

79
QtyValueFootprintReferences
591N4148Diode_THT:D_DO-35_SOD27_P10.16mm_HorizontalD1, D2, D10, D11, D21, D22, D23, D24, D200, D201, D202, D203, D204, D205, D206, D207 +43
8100KResistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR1, R2, R3, R4, R5, R6, R7, R8
4MountingHole_PadMountingHole:MountingHole_3.2mm_M3_Pad_ViaH1, H2, H3, H4
1ADCConnector_PinHeader_2.54mm:PinHeader_2x05_P2.54mm_VerticalJ3
1CONFIGButton_Switch_THT:SW_DIP_SPSTx08_Slide_9.78x22.5mm_W7.62mm_P2.54mmSW1
1EXTConnector_PinHeader_2.54mm:PinHeader_2x10_P2.54mm_VerticalJ4
1Encoders 1-10Connector_PinHeader_2.54mm:PinHeader_2x20_P2.54mm_VerticalJ5
1INT SELConnector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_VerticalJ2
1Maple_MiniModule:Maple_MiniU9
1PWR/I2CConnector_PinHeader_2.54mm:PinHeader_2x03_P2.54mm_VerticalJ1
1Switches 41-50Connector_PinHeader_2.54mm:PinHeader_2x20_P2.54mm_VerticalJ6

More from riban-bw/I2C-Hardware-Controller

3
  • 2 layers66 × 99.1 mmI2CHWC DIGEXT, the printed circuit board in 3D

    I2CHWC DIGEXT

    riban-bw/I2C-Hardware-Controller

    A hardware controller providing rotary encoders, switches and potentiometer values via I2C

    67 parts4GPL-3.0
  • 2 layers66 × 99.1 mmI2CHWC ADCEXT, the printed circuit board in 3D

    I2CHWC ADCEXT

    riban-bw/I2C-Hardware-Controller

    A hardware controller providing rotary encoders, switches and potentiometer values via I2C

    22 parts4GPL-3.0
  • 2 layers25.4 × 16.5 mmEncoder, the printed circuit board in 3D

    Encoder

    riban-bw/I2C-Hardware-Controller

    A hardware controller providing rotary encoders, switches and potentiometer values via I2C

    2 parts4GPL-3.0

Similar boards

  • 2 layers36.8 × 34.7 mmTinylab proto1, the printed circuit board in 3D

    Tinylab proto1

    espotek-org/Labrador

    EspoTek Labrador is a USB device that transforms your PC or smartphone into a fully-featured electronics lab. This repo holds all of the source code!

    79 parts1.2k
  • 2 layers128.8 × 99.5 mmWarriorAttend, the printed circuit board in 3D

    WarriorAttend

    hackclub/OnBoard

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

    79 parts915
  • 2 layers80 × 107.5 mmMinino, the printed circuit board in 3D

    Minino

    ElectronicCats/Minino

    Minino is an original multiprotocol and multiband board made for sniffing, communicating, and attacking IoT devices. It was designed as a mini Cat that integrates the powerful ESP32C6, GPS, microSD and OLED.

    79 parts183GPL-3.0
  • 2 layers151.3 × 120.8 mmTairakb, the printed circuit board in 3D

    Tairakb

    strayer/taira-keyboard

    A wireless low-profile split mechanical keyboard with 66 keys inspired by the ErgoDash and Corne Chocolate

    79 parts164MIT
  • 2 layers100 × 100 mmStack, the printed circuit board in 3D

    Stack

    imihajlow/ccpu

    A 8-bit computer made of 74xx series logic gates and memory ICs.

    79 parts145
  • 2 layers22 × 56 mmEsp32s2-funprog, the printed circuit board in 3D

    Esp32s2-funprog

    cnlohr/cnhardware

    My dumping grounds for all my kicad projects and random hardware bringup.

    79 parts114
  • 2 layers40.1 × 96.9 mmMultimult board, the printed circuit board in 3D

    Multimult board

    tpcarlson/synth-diy

    Mostly Eurorack projects

    79 parts107

Questions

How big is the I2CHWC PCB?

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

What parts does the I2CHWC use?

79 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 I2CHWC KiCad files?

From the riban-bw/I2C-Hardware-Controller repository on GitHub, at the commit this page was made from: the board is hardware/I2CHWC.kicad_pcb. PCBKit opens the board in the browser, with nothing to install.

Can I use the I2CHWC 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).