---
title: "LinuxCNC-RIO"
url: "https://maker.wiznet.io/scarlet/projects/linuxcnc-rio/"
markdown_url: "https://maker.wiznet.io/scarlet/projects/linuxcnc-rio/md"
type: "UCC: User Created Content"
author: "Oliver Dippel"
author_url: "https://github.com/multigcs/LinuxCNC-RIO"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "Oliver Dippel"
original_url: "https://github.com/multigcs/LinuxCNC-RIO"
published: "2023-08-22"
language: "en"
hardware: ["WIZnet W5500"]
likes: 0
views: 1603
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# LinuxCNC-RIO

> RealtimeIO for LinuxCNC based on an FPGA

Original author: Oliver Dippel (source: https://github.com/multigcs/LinuxCNC-RIO)

## Components

- **WIZnet W5500** x 1 ([docs](https://docs.wiznet.io/Product/Chip/Ethernet/W5500))

WIZnet parts: W5500 ([Datasheet](https://docs.wiznet.io/Product/Chip/Ethernet/W5500/datasheet?utm_source=maker&utm_medium=project&utm_campaign=w5500), [product hub](https://maker.wiznet.io/products/w5500/))

## Article

## LinuxCNC-RIO

RealtimeIO for LinuxCNC based on an FPGA

- no Soft-Core

- logic only

- no jitter

- fast and small

- communication via SPI (with Raspberry PI 4 or Ethernet-Bridge)

- generated verilog-code / setup via json files (free pin-selection)

- using free FPGA-Toolchain

- tested on ICE40UP5K, ICE40LP8K, ICE40HX8K, ECP5 and TangNano9K boards

[![tango](https://github.com/multigcs/LinuxCNC-RIO/raw/main/files/tango.jpg)](https://github.com/multigcs/LinuxCNC-RIO/blob/main/files/tango.jpg)

## Sample-Configs:

| Name | Description |
| --- | --- |
| [TangNano9K](https://github.com/multigcs/LinuxCNC-RIO/blob/main/configs/TangNano9K) | Tang Nano 9K with 5axis-BOB |
| [Tango-Board](https://github.com/multigcs/LinuxCNC-RIO/blob/main/configs/Tangoboard) | Tango-Board with Tang Nano 9K |
| [Olimex-ICE40HX8K-EVB_BOB](https://github.com/multigcs/LinuxCNC-RIO/blob/main/configs/Olimex-ICE40HX8K-EVB_BOB) | Olimex ICE40HX8K-EVB with 5axis-BOB |
| [TinyFPGA-BX_BOB](https://github.com/multigcs/LinuxCNC-RIO/blob/main/configs/TinyFPGA-BX_BOB) | TinyFPGA-BX with 5axis-BOB |
| [ICEBreakerV1.0e](https://github.com/multigcs/LinuxCNC-RIO/blob/main/configs/ICEBreakerV1.0e) | ICEBreakerV1.0e tests |
| [Lattice-iCE40HX8K_BOB](https://github.com/multigcs/LinuxCNC-RIO/blob/main/configs/Lattice-iCE40HX8K_BOB) | Lattice iCE40HX8K with custom bob |
| [Colorlight5A-75E](https://github.com/multigcs/LinuxCNC-RIO/blob/main/configs/Colorlight5A-75E) | Colorlight5A-75E tests |
| [Alhambra-II](https://github.com/multigcs/LinuxCNC-RIO/blob/main/configs/Alhambra-II) | Alhambra II FPGA board with 3 Axis SPI |

## Plugins:

| Type | Name | Description |
| --- | --- | --- |
| joint | [pwmdir](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/joint_pwmdir) | PWM Joint Output with DIR-Pin |
| joint | [rcservo](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/joint_rcservo) | RCSERVO Joint Output |
| joint | [stepper](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/joint_stepper) | Stepper Joint Output with STEP/DIR/ENABLE(optional) pins |
| vin | [frequency](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/vin_frequency) | Variable-Input for frequency measurement |
| vin | [pulsecounter](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/vin_pulsecounter) | Variable-Input for pulse counting with up to 3 pins (all optional) |
| vin | [pwmcounter](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/vin_pwmcounter) | Variable-Input for pulse width measurement |
| vin | [quadencoder](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/vin_quadencoder) | Variable-Input for Quad-Encoder (int32_t) |
| vin | [quadencoderz](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/vin_quadencoderz) | Variable-Input for Quad-Encoder with Z-Pin (int32_t) |
| vin | [sonar](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/vin_sonar) | Variable-Input for distance measurement via ultrasonic sonar sensor (HC-SR04) |
| vin | [sonar](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/vin_lm75) | Variable-Input for temperature measurement via LM75 sensor |
| vout | [frequency](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/vout_frequency) | Variable-Output for frequencys |
| vout | [pwm](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/vout_pwm) | Variable-Output for PWM-Signals with optional DIR pin |
| vout | [sinepwm](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/vout_sinepwm) | Variable-Output for Sine-Waves via PWM-Signal |
| vout | [spipoti](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/vout_spipoti) | Variable-Output using digital poti with SPI Interface (like MCP413X/415X/423X/425X) |
| vout | [udpoti](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/vout_udpoti) | Variable-Output using digital poti with UpDown/Incr. Interface (like X9C104) |
| din | [bit](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/din_bit) | Digital Input Pin (1bit) |
| dout | [bit](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/dout_bit) | Digital Output Pin (1bit) |
| expansion | [shiftreg](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/expansion_shiftreg) | Expansion to add I/O's via shiftregister's |
| interface | [spislave](https://github.com/multigcs/LinuxCNC-RIO/blob/main/plugins/interface_spislave) | communication interface ( RPI(Master) &lt;-SPI-> FPGA(Slave) ) |

## FPGA-Toolchain:

<https://github.com/YosysHQ/oss-cad-suite-build>

for the TangNano9K, you can also using the Gowin-IDE or Gowin-Shell (it's faster)

## interfacing with the raspberry

Interface: SPI

Chipselect: CE_1

do not reuse the chipselect pin of your SPI-Flash !!!

## interfacing via Ethernet

you can also use UDP2SPI bridge to communicate via Ethernet (UDP)

- [WT32-ETH01](https://github.com/multigcs/LinuxCNC-RIO/blob/main/UDP2SPI-Bridge/WT32-ETH01)

- [ESP32-PoE-ISO](https://github.com/multigcs/LinuxCNC-RIO/blob/main/UDP2SPI-Bridge/ESP32-PoE-ISO)

- [ESP32_W5500](https://github.com/multigcs/LinuxCNC-RIO/blob/main/UDP2SPI-Bridge/ESP32_W5500)

## test-tool

if you want to test the connection without LinuxCNC, you can use the python test-tool:

```plaintext
python3 Output/BOARD_NAME/Firmware/qt_spitest.py [IP]
```

## some hints

at the moment, you need at least configure one item of each of the following sections: vin, vout, din, dout, joints

## buildtool

you can select a config via make argument:

```plaintext
make CONFIG=configs/TinyFPGA-BX_BOB/config.json build
```

## Structure:

buildtool.py plugins: python scripts to generates the verilog files from a configuration

configs: here are the config files for a specific setup (Target-FPGA / Pins)

Output: the generated files per config

## some demo videos

### LinuxCNC-RIO with TinyFPGA-BX and 5Axis BOB - ATC-Test

[![LinuxCNC-RIO with TinyFPGA-BX and 5Axis BOB - ATC-Test](https://img.youtube.com/vi/G5V5OM_ORsk/0.jpg)](https://www.youtube.com/shorts/G5V5OM_ORsk)

### linuxcnc with tinyfpga-bx

[![linuxcnc with tinyfpga-bx](https://img.youtube.com/vi/0nTmo4afwWs/0.jpg)](https://www.youtube.com/shorts/0nTmo4afwWs)

### Mini Closed-Loop DC-Servo on LinuxCNC-RIO

[![Mini Closed-Loop DC-Servo on LinuxCNC-RIO](https://img.youtube.com/vi/0cOvUS33U_s/0.jpg)](https://www.youtube.com/shorts/0cOvUS33U_s)

### Linuxcnc RIO with ICEBreaker FPGA

[![Linuxcnc RIO with ICEBreaker FPGA](https://img.youtube.com/vi/58RNJSGD0qs/0.jpg)](https://www.youtube.com/watch?v=58RNJSGD0qs)

### LinuxCNC-RIO mixed joint types (on TangNano9K - FPGA)

[![LinuxCNC-RIO mixed joint types (on TangNano9K - FPGA)](https://img.youtube.com/vi/ZfTr1BNUK_0/0.jpg)](https://www.youtube.com/shorts/ZfTr1BNUK_0)

### LinuxCNC-RIO with TinyFPGA-BX and 5Axis BOB

[![LinuxCNC-RIO with TinyFPGA-BX and 5Axis BOB](https://img.youtube.com/vi/urRHtw4bcsI/0.jpg)](https://www.youtube.com/watch?v=urRHtw4bcsI)

### LinuxCNC with ICE40 for stepgen

[![LinuxCNC with ICE40 for stepgen](https://img.youtube.com/vi/m4zXuHERiFU/0.jpg)](https://www.youtube.com/shorts/m4zXuHERiFU)

### Linuxcnc RIO with Tang Nano 20k FPGA with esp32 and w5500 Ethernet

[![Linuxcnc RIO with Tang Nano 20k FPGA with esp32 and w5500 Ethernet](https://img.youtube.com/vi/inAFxSs9Hak/0.jpg)](https://www.youtube.com/watch?v=inAFxSs9Hak)

---

Thanks to the <https://github.com/scottalford75/Remora> Project, i'm using a modified version of it's Linux-Component

---

Source: https://maker.wiznet.io/scarlet/projects/linuxcnc-rio/
