Ethernet CAN Gateway

components
Hardware Components
W5100S-EVB-Pico
X 1
Main board
MCP2515
X 1
CAN module
OLED
X 1
For display info
LED
X 2
Indicator
Resistor (220)
X 2
For LED
Software Apps and online services
CANdevStudio
opensource GUI tool for CAN
QCanBus
opensource Qt plug-in
Project Description

For more readable page, Click me!

Overview

There are many tools for controlling CAN devices. Among them, there is one of the open-source projects called Qt-based 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.


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.

Main PartQtyNote
W5100S-EVB-Pico1MCU with W5100S for ethernet
MCP2515 CAN1CAN module (w/ transceiver)
OLED1Display device information (network, etc.)
LED2TX/RX Indicator
Resister2(220Ω) For LED voltage
Button2

PCB 3D model

Case 3D model


Software

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.

Core 0Core 1
SystemManager
(OLED, UserButton)Ethernet Manager
CAN Manager
Ethernet2CAN

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, which used the Cannelloni protocol, and created a more general plug-in that could be used without Cannelloni.


Results


Development Notes (Korean)


Step by Step Guide

Step 0. Get your parts

Main PartQtyNote
W5100S-EVB-Pico1MCU with W5100S for ethernet
MCP2515 CAN1CAN module (w/ transceiver)
OLED1Display device information (network, etc.)
LED2TX/RX Indicator
Resister2(220Ω) For LED voltage
Button2

Step 1. Assembly parts

Pin Map

 MCP2515 CAN Module

PICO Board Pin No.GPIOFunctionMCP2515MCP2515 Pin No.
10GPIO7GPIOINT1
14GPIO10SPI1 SCKSCK2
15GPIO11SPI1 MOSISI3
16GPIO12SPI1 MISOSO4
17GPIO13GPIOCS5
GNDGND6
39VSYS3.3VVCC7
OLED

PICO Board Pin No.GPIOFunctionOLEDOLED Pin No.
19GPIO14I2C1 SDASDA4
20GPIO15I2C1 SCLSCL3
363.3VVCC2
GNDGNDGND1
Reset Pin
PICO Board Pin No.GPIO비고
30RUN
User Pin
PICO Board Pin No.GPIO비고
9GPIO6Low Active
LED
PICO Board Pin No.GPIONote
4GPIO2Low Active
5GPIO3Low Active

(method 1) Using Breadboard

(method 2) Circuit board

(method 2) PCB - more expensive but compact

Step 2. (Optional) Housing

Step 3. Build & Download Firmware (CMake based Project)

Installation

Set environment

- For ARM gcc compiler, (only Windows) windows build tools, MinGW GCC

# for linux -> env.linux
# for macOS -> env.osx
"terminal.integrated.env.windows": {
        "PATH": "${env:PATH};D:/tools/build_tools/xpack-windows-build-tools-4.2.1-2/bin;C:/fw/tools/xpack-arm-none-eabi-gcc-10.2.1-1.1/bin;D:/tools/mingw32/bin",
},

Clone code from repository

cd
git clone git@github.com:RRTstar/wiznet_can_gateway.git
cd wiznet_can_gateway
git submodule update --init
cd external\\pico-sdk
git submodule update --init

Build

cd wiznet_can_gateway
cmake -S . -B build -G "MinGW Makefiles" -DPICO_BOARD=pico
cmake --build build -j4

Download (Just Drag & Drop)

 

Step 4. Build Qt GUI Plug-in

Install Qt 5.15.2

  • (Only for windows) CHECK MinGW 8.1.0 64bit for additional installation

Clone code

git clone git@github.com:RRTstar/QtWiznetCanBus.git

Open Project & Build

  • Execute Qt Creator
  • Select [File] → [Open File or Project] on top menu bar

  • Select & Open [CMakeLists.txt] in the folder cloned above.

  • Configure Project (depend on your environment)

- MinGW is for just only Windows

- Opened! Yeeeeeah!!

  • Build
Crtl + B  # shortcut

Copy dll file to Qt plugins folder

Test Plug-in

  • Open CAN Bus example (default by Qt)

  • Build & Run
Crtl + B  # For build
Crtl + R  # For run

 

- Select wiznet_can

- Enter your devices IP Address:Port (Check your OLED on your device)

 

Step 5. Build CANdevStudio

Clone code

git clone --recursive git@github.com:GENIVI/CANdevStudio.git

Open Project & Build & Run

  • Execute Qt Creator
  • Select [File] → [Open File or Project] on top menu bar
  • Select & Open [CMakeLists.txt] in the folder cloned above.
  • Build & Run
Crtl + B  # For build
Crtl + R  # For run
  • Select [New Project...]

  • Enter your devices IP Address:Port (Check your OLED on your device)

  • Add & connect [CanRawVeiw] component to view CAN messages received.

  • Check operation status

 
documents
Code
wiznet_can_gateway
firmware
QtWiznetCanBus
Qt plug-in for CAN UDP
Schematics
Expansion Board
for compact
Expansion Board Gerber
gerber file
Others
Case
for compact

1
COMMENTS

Please Login to comment
1 Comment authors
ronpang Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
ronpang
Member

Hi chcbaram,
I’m Ron from WIZnet HK. Could I post your article to our WIZnet HK instagram account?

BTW, do you have a instagram account that I could tag you?

Best Regards,
Ron

POSTED BY
W5100S Series Library
Reusable S/W