{"id":49184372,"url":"https://github.com/tinic/rp2040-encoder","last_synced_at":"2026-05-28T17:01:06.603Z","repository":{"id":299471893,"uuid":"1003119098","full_name":"tinic/rp2040-encoder","owner":"tinic","description":"USB bridge that splices into an existing 5V TTL DRO (TOAUTO, Sino, Ditron, glass/magnetic scales) and mirrors position to LinuxCNC as   a HAL component. RP2040 + ISO7760 galvanic isolation.","archived":false,"fork":false,"pushed_at":"2026-05-28T16:08:30.000Z","size":1164,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-28T16:09:09.695Z","etag":null,"topics":["cnc","digital-readout","dro","galvanic-isolation","glass-scale","hal-component","iso7760","linuxcnc","magnetic-scale","retrofit","rp2040","usb"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tinic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-16T16:47:24.000Z","updated_at":"2026-05-28T16:08:34.000Z","dependencies_parsed_at":"2025-06-17T17:46:57.941Z","dependency_job_id":"804c4bc0-8141-4ace-8ed6-db534a856758","html_url":"https://github.com/tinic/rp2040-encoder","commit_stats":null,"previous_names":["tinic/pico-hal-dro","tinic/rp2040-encoder"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/tinic/rp2040-encoder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinic%2Frp2040-encoder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinic%2Frp2040-encoder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinic%2Frp2040-encoder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinic%2Frp2040-encoder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinic","download_url":"https://codeload.github.com/tinic/rp2040-encoder/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinic%2Frp2040-encoder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33617718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cnc","digital-readout","dro","galvanic-isolation","glass-scale","hal-component","iso7760","linuxcnc","magnetic-scale","retrofit","rp2040","usb"],"created_at":"2026-04-23T03:07:56.249Z","updated_at":"2026-05-28T17:01:06.593Z","avatar_url":"https://github.com/tinic.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RP2040 LinuxCNC HAL Quadrature Encoder Interface\n\n**Bridge an existing 5 V TTL DRO (Digital Read Out) — TOAUTO, Sino, Ditron, generic glass-scale kits — into LinuxCNC over USB without removing the DRO.** Think of it as *TouchDRO's spirit, but the host is LinuxCNC instead of an Android tablet*: splice into the existing DB9 cabling, keep the original DRO display working, and mirror the X/Y/Z position counts into LinuxCNC as a HAL component.\n\n## Overview\n\nThis project connects existing DRO scales with TTL-level A/B quadrature signals to LinuxCNC through a simple USB connection. It splices into the existing DB9 connectors/cables so the original DRO continues to function. Common brands which work include [TOAUTO](https://www.toautotool.com/products/2-3-axis-dro-kit-standard-scales), Sino, Ditron, and other 5 V TTL quadrature glass-scale and magnetic-scale kits.\n\nThe hardware is intentionally minimal:\n\n**Waveshare RP2040-Zero** — compact RP2040 board, USB-C, built-in WS2812 status LED.\n\n[\u003cimg src=\"./hardware/rp2040-zero.jpg\" alt=\"Waveshare RP2040-Zero board\" width=\"200px\"/\u003e](./hardware/rp2040-zero.jpg)\n\n**Texas Instruments ISO7760FDBQR digital isolator** — 6-channel forward, SSOP-16, default-LOW *F* variant. Provides 5 kVrms galvanic isolation between the machine-side electrical environment and the USB host PC, important on machines with VFDs, servo drives, or noisy ground references. See [`hardware/README.md`](hardware/README.md) for the full pinout and a startup-glitch caveat tied to the F suffix.\n\n## Finished board\n\n[\u003cimg src=\"./hardware/IMG_8394.jpg\" alt=\"RP2040-Zero with ISO7760F digital isolator on a hand-wired board\" width=\"300px\"/\u003e](./hardware/IMG_8394.jpg)\n\nSpliced into the existing DRO via DB9 breakouts — there are likely nicer-looking solutions than this:\n\n[\u003cimg src=\"./hardware/IMG_8388.jpg\" alt=\"USB DRO bridge installed on a CNC machine, tapping into glass scale cables\" width=\"300px\"/\u003e](./hardware/IMG_8388.jpg)\n\n## Features\n\n- 3 DRO scales (X, Y, Z) with TTL A/B quadrature signals; firmware supports a 4th channel if hardware is extended\n- PIO-based edge counting on the RP2040 — no software polling loop, no missed transitions\n- DMA reload pair per channel drains the PIO RX FIFO into memory with **zero CPU involvement**, so position counts cannot drop regardless of scale velocity\n- 32-bit signed position counters per axis\n- USB vendor-class device + LinuxCNC HAL userspace component\n- Configurable per-axis scale factors (compile-time defaults overridable at runtime over USB or via HAL pins)\n- Built-in test mode (sine / circular / linear / random) for development and debugging without scales attached\n- Hardware watchdog: automatic reboot + USB re-enumeration on firmware hang\n- 5 kVrms galvanic isolation between machine and host PC\n\n## Quick Start\n\nSee the individual directories for detailed instructions:\n- [`rp2040-firmware/`](rp2040-firmware/) — RP2040 firmware (Pico SDK 2.2.0, C++23)\n- [`linuxcnc-hal/`](linuxcnc-hal/) — LinuxCNC HAL component (`halcompile --install`)\n- [`hardware/`](hardware/) — Hardware setup, isolator wiring, and DB9 splice diagrams\n\n## How this compares to other projects\n\nThe DIY DRO and LinuxCNC encoder-interface space has a few well-known projects; this one occupies a specific niche.\n\n| Project | Host | Connection | Goal |\n|---------|------|------------|------|\n| **This project** | LinuxCNC | USB | Mirror an existing DRO into LinuxCNC as position feedback, preserve the original display |\n| [TouchDRO (Yuriy Krushelnytskiy)](https://www.touchdro.com/resources/adapters/diy/) | Android / Fire tablet | Bluetooth | Replace a physical DRO display with a tablet UI |\n| [atrex66/stepper-ninja](https://github.com/atrex66/stepper-ninja) | LinuxCNC | UDP / Ethernet | RP2040 as a deterministic motion controller (step generation + encoder feedback) |\n| [Remora](https://github.com/scottalford75/Remora) | LinuxCNC on RPi | SPI | STM32/LPC176x as a realtime co-processor for motion |\n| [Mesa hostmot2 cards](https://linuxcnc.org/docs/html/man/man9/hostmot2.9.html) | LinuxCNC | PCI / Ethernet | FPGA-based deterministic motion + encoder, commercial gold standard |\n| [adamgreen/QuadratureDecoder](https://github.com/adamgreen/QuadratureDecoder) | (library only) | — | PIO+DMA RP2040 quadrature library; no USB/CNC integration |\n\n**Why USB and not Ethernet?** USB is non-deterministic by design and is the wrong tool for LinuxCNC's realtime motion loop. It's the right tool for **position display / DRO mirroring**, where missing a single millisecond update doesn't matter and only the integral count needs to be correct — which is exactly what this project does. If you need closed-loop motion feedback for servoing, look at Mesa, Remora, or stepper-ninja.\n\n**Why an isolator rather than a level shifter?** Glass-scale cables run through the machine alongside power and motor wiring. Galvanic isolation between the machine ground and the host PC's USB ground avoids ground loops, VFD/servo noise injection, and reduces the blast radius of a wiring fault. The earlier revision of this project used a TXS0108E bidirectional level shifter; the current design uses an ISO7760FDBQR digital isolator.\n\n## Keywords\n\nLinuxCNC, DRO, digital readout, glass scale, magnetic scale, quadrature encoder, TTL, 5V TTL, RP2040, Raspberry Pi Pico, ISO7760, digital isolator, galvanic isolation, USB, HAL component, TOAUTO, Sino, Ditron, CNC, milling machine, lathe, retrofit, splice, position feedback, TouchDRO alternative.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinic%2Frp2040-encoder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinic%2Frp2040-encoder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinic%2Frp2040-encoder/lists"}