Rotary Encoder Position Counter

On an Arduino Nano 33 BLE, decode a mechanical quadrature handwheel so that each full click counts once in the right direction, while contact chatter, rocking and invalid transitions never count, and a push button zeroes the position.

Board
Nano 33 BLE · Arduino
Schwierigkeit
Mittel
Thema
Data Handling & Algorithms
Zugang
Vollständiger Plan

Die Aufgabe

Rotary Encoder Position Counter

A small CNC router gets a manual handwheel for jogging the spindle. The wheel is a mechanical quadrature encoder with clicks (detents). Mechanical contacts bounce and operators rock the wheel back and forth, but a wrong step here moves a cutting tool, so every click must count exactly once, in the right direction, and nothing else may count.

Hardware

  • Arduino Nano 33 BLE (nRF52840, 3.3 V logic). Serial console on Serial1 (D0/D1), 115200 baud. Serial is USB and is not seen by the tests. The motion controller reads the console.
  • Encoder channels A on D2 and B on D3, common pin to GND. Use the internal pull-ups. At a click (rest position) both channels are HIGH.
  • Turning one click clockwise, A goes LOW first, then B goes LOW, then A returns HIGH, then B returns HIGH. Counter-clockwise is the same with B leading.
  • D5: the wheel's push button (zero), to GND, LOW = pressed.

Write the sketch in sketch/sketch.ino. In setup() open Serial1 at 115200 baud, start at position 0, then print READY. Never block with delay(): a loop that reads the pins all the time is fast enough.

Das ist der Anfang der Aufgabe. Melde dich mit dem vollständigen Plan an, um den Rest zu lesen und sie zu lösen.

Was du bekommst

  • Deine Firmware wird auf einem emulierten Board gebaut, ausgeführt und durch Hardware-Tests geprüft.
  • Eine schriftliche Erklärung der Lösung.
  • Kein Entwicklungsboard und keine lokale Toolchain nötig.

Neu bei Embedded? Starte mit der Roadmap: Embedded-Systeme lernen (Englisch)