Skip to content

DM105 Rotary

This module connects two knobs, four buttons, and an OLED display to the LIN bus.

Prototype

The initial protoype was built on a breadboard, using an STM32C011 board, a combined rotary encoder + 2 buttons + 128x64 OLED board, and a second separate rotary encoder.

This 20-pin µC has just enough pins to connect each of the two encoders to its own hardware timer. The timers are configured in "Quadrature Encoder" mode: they'll automatically handle the incoming pulses without losing track and without any CPU involvement.

A knob counts 20 pulses per revolution: only the lower 6 bits of the timer counts are used.

Each knob can be pressed as "button" and there are two more buttons, labeled CONFIRM and BACK. So that's two 6-bit counts and 4 on/off buttons, for a total of 16 bits.

The plan is to have the top-left knob select the parameter and the right one its value.

Info

The OLED display is connected and initialised, but not yet used or associated with LIN packets.

Cable version

I've constructed a more permanent setup. It includes a cable with a 2.5mm audio plug as power + LIN bus connection. This board is a bit large for an expansion base, but more importantly: when connected with a cable, these knobs can be placed where they're most convenient, away from all the breadboard jumpers.

LIN device

Since LIN is a bus, multiple devices can be connected in parallel, as long as each one responds to a different ID.

This module responds as slave ID 1 on the LIN bus. When queried, it sends 2 bytes:

  • byte 1: right knob pressed (b7), confirm (b6), right knob position (b5..b0)
  • byte 2: left knob pressed (b7), back (b6), left knob position (b5..b0)

Connections

OLED + rotary:
    OLED I2C: A10 + A9 (I2C1: sda,scl)
    Rotary:   A0 + A1 (encoder: TIM1 CH 1+2), A5 (push)
    Buttons:  A6 (confirm), A7 (back)
2nd encoder:
    Rotary:   B7 + C14 (encoder: TIM3 CH 1+2), A8 (push)
LIN bus:
    USART1:   B6 (USART1: tx)
    Cable:    5V + LIN + GND (tip,ring,sleeve)

Board

This module was manually constructed using a 7x5 cm proto board.

Components

  • WeAct STM32C011F6 board see GitHub and AliExpress
    • on-board PC14 + PC15 solder jumpers need to be closed
  • SAMIROB OLED module (AliExpress) - 1.3" OLED, rotary encoder, and 2 buttons
  • rotary encoder - with 10 detents and push-button function (scrap box item)
  • 2.5mm plug + cable (AliExpress) - "2.5mm 3Pole Male"

Schematics

  • WeAct STM32C011F6: see GitHub
  • SAMIROB OLED module: see AliExpress link above

Software

See https://codeberg.org/jcw/dobb/src/branch/main/mods/dm10x/rotary.cpp.