---
title: "Ethernet CAN Gateway"
url: "https://maker.wiznet.io/WIZnet/projects/ethernet-can-gateway-by-WIZnet/"
markdown_url: "https://maker.wiznet.io/WIZnet/projects/ethernet-can-gateway-by-WIZnet/md"
type: "UCC: User Created Content"
author: "chcbaram"
author_url: "https://oldmaker.wiznet.io/2022/01/08/ethernet-can-gateway/"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "chcbaram"
original_url: "https://oldmaker.wiznet.io/2022/01/08/ethernet-can-gateway/"
published: "2023-02-17"
language: "en"
hardware: ["WIZnet W5100S-EVB-Pico", "Microchip MCP2515", "WAVESHARE General 0.91inch OLED display Module"]
likes: 3
views: 215
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# Ethernet CAN Gateway

> WIZnet Ethernet HAT Contest Winner Project

Original author: chcbaram (source: https://oldmaker.wiznet.io/2022/01/08/ethernet-can-gateway/)

## Components

- **WIZnet W5100S-EVB-Pico** x 1 ([docs](https://docs.wiznet.io/Product/Chip/Ethernet/W5100S/w5100s-evb-pico))
- **Microchip MCP2515** x 1
- **WAVESHARE General 0.91inch OLED display Module** x 1
- Software: **GENIVI Alliance CANdevStudio**
- Software: **QT Group QCanBus**

## Article

## Overview

There are many tools for controlling CAN devices. Among them, there is one of the open-source projects called Qt-based [CANDevStudio](https://github.com/GENIVI/CANdevStudio).

CANDev Studio uses a common plug-in called Qt CAN plug-in, which can be used on a Qt basis. However, there was no plug-in here between CAN and Ethernet heterogeneous protocols except Virtual. So, we wanted to create a plug-in that can be used on the Qt base and a gateway that can control CAN devices via Etherent through that plug-in, and that's the project.

## Component Diagram

What should be done in the project was clear, as explained in Overview. Therefore, we decided to draw a component diagram to clarify what needs to be done, and to figure out if there is any problem with the composition first.

- **Qt App**: Qt-based application with GUI to control CAN devices easily.

- **QtWiznetCanBus**: A plug-in which use in Qt-based applications.

- **W5100S**: The main character of this project. For Ethernet.

- **Gateway**: Firmware running on WIZnet W5100S-Pico-EVB board to handle Ethernet packets, CAN packets and etc.

- **User Interface**: Hardware interfaces to use firmware on the board easily.

![](https://rrtstar.notion.site/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F4901e91a-0be3-4396-8ce7-64b252aa22b3%2FUntitled.png?id=f5fc8f73-b72f-405d-8bfe-7550291166ad&table=block&spaceId=d8016268-ef4b-4fcb-8867-6f0a1cd156db&width=2000&userId=&cache=v2)

## Hardware

- [Link for hardware files](https://github.com/RRTstar/wiznet_can_gateway/tree/master/hardware)

We determined the necessary hardware configuration from the diagram above, and designed and built a PCB/case for a more compact design and configuration.

### **PCB 3D model**

![](https://rrtstar.notion.site/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F04bee8f2-7d1f-45d7-8a37-a9397d539b97%2FECG_3D_PCB_2022-Apr-08_10-00-31AM-000_CustomizedView21427437757_png.png?id=febaeca9-ee16-40aa-a201-bfb755c15ae6&table=block&spaceId=d8016268-ef4b-4fcb-8867-6f0a1cd156db&width=1340&userId=&cache=v2)

### **Case 3D model**

![](https://rrtstar.notion.site/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fa5bde316-bf2b-4610-b4ad-5262c2a5da99%2FUntitled.png?id=8d9d28c3-e634-4f3f-b991-41437c7aa25b&table=block&spaceId=d8016268-ef4b-4fcb-8867-6f0a1cd156db&width=2000&userId=&cache=v2)

## Software

- [GitHub link for Firmware](https://github.com/RRTstar/wiznet_can_gateway)

- [GitHub link for Qt Plug-ins](https://github.com/RRTstar/QtWiznetCanBus)

The software was used as a combination of WIZnet ioLibrary + pico + CMake to minimize platform dependence.

### Cores

Since the PICO has dual core, roles of these cores are separated as shown below for smooth packet processing.

### Shared Memory

We implemented queue buffers in shared memory between two cores to allow each manager (CAN, Ethernet) **to operate non-blocking**.

### Event-Based Socket

In the case of Ethernet Socket, it was created **based on Event**, making it possible to operate differently depending on the OnWritable() and OnReadable() implementations.

However, due to the nature of the project's configuration, it is made to create only a single socket, so if you want to create multiple sockets, you need to modify the object more extensively.

### QtCanBus Plug-in (Only UDP)

We referred to the [Cannelloni Can Bus plug-in project](https://github.com/tuvok/qtCannelloniCanBus), which used the Cannelloni protocol, and **created a more general plug-in** that could be used without Cannelloni.

![](https://rrtstar.notion.site/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fdceb979d-a970-4be2-ab7c-33d0dc8bdf4d%2FUntitled.png?id=f647f943-33ef-49ff-8039-f7ea08523e05&table=block&spaceId=d8016268-ef4b-4fcb-8867-6f0a1cd156db&width=1550&userId=&cache=v2)

## Results

[Embedded media](https://www.youtube.com/embed/5QxDcNw12uQ)

![](https://rrtstar.notion.site/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F877f2c35-e5d9-410b-a244-05d71404e292%2FUntitled.png?id=725f83e0-7c0a-4b2c-9ed7-bea2f87aeca1&table=block&spaceId=d8016268-ef4b-4fcb-8867-6f0a1cd156db&width=1550&userId=&cache=v2)

![](https://rrtstar.notion.site/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F0922af49-43c9-4147-95ca-db5f8884fda7%2FUntitled.png?id=9c329e2b-ab40-43e4-bf31-5c8c8bf4c68e&table=block&spaceId=d8016268-ef4b-4fcb-8867-6f0a1cd156db&width=1830&userId=&cache=v2)

[Embedded media](https://www.youtube.com/embed/b_YnLaDCx6I)

---

Source: https://maker.wiznet.io/WIZnet/projects/ethernet-can-gateway-by-WIZnet/
