Wiznet makers

TheoIm

Published March 06, 2026 ©

75 UCC

27 WCC

7 VAR

0 Contests

0 Followers

0 Following

Original Link

MATE-ROV-2025

STM32F4 firmware uses a W5500 Ethernet module to exchange micro-ROS messages over UDP (port 9999) and bridge CAN sensor data to ROS topics.

COMPONENTS
PROJECT DESCRIPTION

 

STM32F4 + WIZnet W5500 — micro-ROS UDP Communication Bridge

This STM32F4 firmware collects CAN sensor telemetry and publishes it to ROS topics using micro-ROS over UDP. Ethernet connectivity is implemented with a WIZnet W5500 module through the LoayEthernet library. The system bridges CAN frames into ROS messages while receiving control commands such as pump triggers from a micro-ROS agent.


What This Project Does

This firmware acts as a CAN-to-ROS telemetry bridge. It runs on an STM32F4 microcontroller and performs three main tasks: receiving sensor and system telemetry over CAN, converting the data into micro-ROS messages, and transmitting the messages to a micro-ROS agent via Ethernet.

The system also listens for ROS commands to control hardware such as a pump reset pin. Typical application scenarios include ROV telemetry systems, robotics sensor bridges, and embedded ROS edge nodes.


System Architecture

The architecture connects three different communication layers.

CAN sensor bus data flows into the STM32F4 MCU, where CAN parsing and ROS message creation occur. From there, data passes through the WIZnet W5500 Ethernet controller via SPI, then over UDP micro-ROS transport to a micro-ROS agent running on a PC or Linux system, and finally into the broader ROS2 ecosystem.

Core data pipeline: CAN Frame → ID Parsing → ROS Message Creation → micro-ROS Publish → UDP Transmission. Control messages travel in the reverse direction.


W5500 Ethernet Integration

The project integrates the WIZnet W5500 Ethernet controller through the LoayEthernet library. Initialization occurs through the micro-ROS transport configuration, which sets up the W5500 SPI interface, configures UDP transport to the micro-ROS agent, and registers a custom micro-ROS networking layer. The MCU communicates with the W5500 over SPI.


UDP Transport Implementation

Actual UDP communication occurs inside the micro-ROS transport layer. The implementation sends packets directly to the agent's IP address and port using a UDP client, with no TCP overhead. This makes it well-suited for continuous ROS telemetry streams. The default UDP port used in the project is 9999.


Hardware Configuration

The W5500 Ethernet module connects to the STM32F4 via SPI. Pin assignments are as follows: CS on PA15, SCLK on PA5 or PB3, MISO on PA6 or PB4, and MOSI on PA7 or PB5. The SPI bus operates at 8 MHz in MSBFIRST, SPI_MODE0 configuration.


CAN Telemetry Processing

The system reads CAN frames and converts them into ROS messages. Processing steps proceed as follows: a CAN frame is received, the CAN ID is parsed, raw values are converted to float, a ROS message is constructed, and it is published via micro-ROS.

Example topics in use: ROV/voltage for system voltage, ROV/current for motor current, ROV/indicators for indicator state, and ROV/pump for pump control.


ROS Command Handling

The firmware also subscribes to ROS topics. Upon receiving a command, it can toggle a reset pin for the pump system. This enables remote hardware control directly from a ROS environment.


Buffering and Performance

W5500 internal socket buffers define network throughput. The transmit and receive buffers are each set to 2 KB. Combined with the 8 MHz SPI link, this provides sufficient throughput for both CAN telemetry streaming and ROS message transport.


Runtime Flow

The firmware follows a structured initialization and loop model.

On boot, the system starts the serial debug interface, initializes reset pins, and initializes the CAN bus. During network initialization, the W5500 is brought up, a DHCP IP is assigned, and the micro-ROS UDP transport is registered. In the main runtime loop, the system continuously reads CAN frames, parses IDs, generates ROS messages, publishes to micro-ROS, and processes incoming ROS subscriptions.


Why WIZnet W5500 Matters in This Project

The W5500 plays a critical role in enabling Ethernet networking on the STM32 system. Its hardware TCP/IP stack handles Ethernet protocol processing independently of the MCU, significantly reducing firmware complexity. Without it, the developer would need to implement a full software TCP/IP stack along with PHY configuration and network drivers.

For micro-ROS, which relies heavily on UDP communication, the W5500 provides hardware socket buffers, deterministic packet transmission, and simple SPI integration — all essential for a reliable telemetry bridge.


FAQ

Why use W5500 for micro-ROS networking? The W5500 provides a hardware TCP/IP stack that simplifies Ethernet networking for embedded systems. It allows STM32 firmware to send UDP packets to a micro-ROS agent without implementing a full network stack in software.

How does this firmware send ROS data over Ethernet? The firmware converts CAN frames into ROS messages and sends them through micro-ROS using a custom UDP transport implemented on top of W5500 Ethernet networking.

What transport protocol does micro-ROS use here? The system uses UDP transport between the STM32 device and the micro-ROS agent.

How is the W5500 connected to the MCU? The W5500 is connected via an SPI bus using CS, SCLK, MOSI, and MISO pins defined in the firmware.

What happens if CAN initialization fails? In the debug firmware version, the system enters an infinite loop to prevent undefined behavior.


Tags

W5500 / WIZnet / micro-ROS / STM32 / CAN Bus / ROS2 / UDP Networking / Embedded Robotics / Telemetry Bridge


 

 


STM32F4 + WIZnet W5500 — micro-ROS UDP 통신 브리지

이 STM32F4 펌웨어는 CAN 센서 텔레메트리를 수집하고 micro-ROS를 통해 UDP로 ROS 토픽에 데이터를 발행합니다. 이더넷 연결은 LoayEthernet 라이브러리를 통해 WIZnet W5500 모듈로 구현되며, CAN 프레임을 ROS 메시지로 변환하는 동시에 micro-ROS 에이전트로부터 펌프 트리거 등의 제어 명령을 수신합니다.


프로젝트 개요

이 펌웨어는 CAN-to-ROS 텔레메트리 브리지 역할을 합니다. STM32F4 마이크로컨트롤러에서 동작하며 세 가지 핵심 기능을 수행합니다: CAN을 통한 센서 및 시스템 텔레메트리 수신, 데이터를 micro-ROS 메시지로 변환, 이더넷을 통해 micro-ROS 에이전트로 메시지 전송.

또한 펌프 리셋 핀 등의 하드웨어를 제어하는 ROS 명령도 수신합니다. 주요 적용 분야로는 ROV 텔레메트리 시스템, 로보틱스 센서 브리지, 임베디드 ROS 엣지 노드 등이 있습니다.


시스템 아키텍처

세 가지 서로 다른 통신 레이어를 연결하는 구조입니다.

CAN 센서 버스 데이터가 STM32F4 MCU로 유입되어 CAN 파싱과 ROS 메시지 생성이 이루어집니다. 이후 SPI를 통해 WIZnet W5500 이더넷 컨트롤러를 거쳐 UDP micro-ROS 전송으로 PC 또는 Linux 시스템의 micro-ROS 에이전트에 전달되고, 최종적으로 ROS2 생태계로 연결됩니다.

핵심 데이터 파이프라인: CAN 프레임 → ID 파싱 → ROS 메시지 생성 → micro-ROS 발행 → UDP 전송. 제어 메시지는 반대 방향으로 전달됩니다.


W5500 이더넷 통합

프로젝트는 LoayEthernet 라이브러리를 통해 WIZnet W5500 이더넷 컨트롤러를 통합합니다. 초기화는 micro-ROS 전송 설정 과정에서 이루어지며, W5500 SPI 인터페이스 구성, micro-ROS 에이전트로의 UDP 전송 설정, 커스텀 micro-ROS 네트워킹 레이어 등록이 함께 수행됩니다. MCU와 W5500 간의 통신은 SPI를 통해 이루어집니다.


UDP 전송 구현

실제 UDP 통신은 micro-ROS 전송 레이어 내부에서 처리됩니다. UDP 클라이언트를 사용해 에이전트의 IP 주소와 포트로 직접 패킷을 전송하며, TCP 오버헤드가 없어 연속적인 ROS 텔레메트리 스트리밍에 적합합니다. 프로젝트에서 사용하는 기본 UDP 포트는 9999입니다.


하드웨어 구성

W5500 이더넷 모듈은 SPI를 통해 STM32F4에 연결됩니다. 핀 구성은 CS: PA15, SCLK: PA5 또는 PB3, MISO: PA6 또는 PB4, MOSI: PA7 또는 PB5입니다. SPI 버스는 8MHz, MSBFIRST, SPI_MODE0 설정으로 동작합니다.


CAN 텔레메트리 처리

시스템은 CAN 프레임을 읽어 ROS 메시지로 변환합니다. 처리 흐름은 다음과 같습니다: CAN 프레임 수신 → CAN ID 파싱 → 원시 값을 float으로 변환 → ROS 메시지 구성 → micro-ROS를 통해 발행.

사용 중인 토픽 예시: ROV/voltage(시스템 전압), ROV/current(모터 전류), ROV/indicators(인디케이터 상태), ROV/pump(펌프 제어).


ROS 명령 처리

펌웨어는 ROS 토픽을 구독하기도 합니다. 명령을 수신하면 펌프 시스템의 리셋 핀을 토글하는 등의 동작을 수행합니다. 이를 통해 ROS 환경에서 하드웨어를 원격으로 제어할 수 있습니다.


버퍼링 및 성능

W5500 내부 소켓 버퍼가 네트워크 처리량을 결정합니다. 송신 및 수신 버퍼는 각각 2KB로 설정됩니다. 8MHz SPI 링크와 결합하여 CAN 텔레메트리 스트리밍과 ROS 메시지 전송 모두에 충분한 처리량을 제공합니다.


런타임 흐름

펌웨어는 체계적인 초기화 및 루프 구조를 따릅니다.

부팅 시 시리얼 디버그 인터페이스를 시작하고, 리셋 핀과 CAN 버스를 초기화합니다. 네트워크 초기화 단계에서는 W5500을 구동하고 DHCP로 IP를 할당받은 뒤 micro-ROS UDP 전송을 등록합니다. 메인 루프에서는 CAN 프레임 읽기, ID 파싱, ROS 메시지 생성, micro-ROS 발행, 수신 ROS 구독 처리를 지속적으로 반복합니다.


WIZnet W5500이 이 프로젝트에서 중요한 이유

W5500은 STM32 시스템에서 이더넷 네트워킹을 가능하게 하는 핵심 요소입니다. 하드웨어 TCP/IP 스택이 MCU와 독립적으로 이더넷 프로토콜 처리를 담당하여 펌웨어 복잡도를 크게 낮춥니다. W5500 없이는 소프트웨어 TCP/IP 스택 구현, PHY 설정, 네트워크 드라이버 작성이 모두 필요합니다.

UDP 통신에 크게 의존하는 micro-ROS에 있어 W5500은 하드웨어 소켓 버퍼, 결정론적 패킷 전송, 간단한 SPI 통합을 제공하며, 이는 안정적인 텔레메트리 브리지 구축에 필수적입니다.


자주 묻는 질문

micro-ROS 네트워킹에 W5500을 사용하는 이유는? W5500은 임베디드 시스템의 이더넷 네트워킹을 단순화하는 하드웨어 TCP/IP 스택을 제공합니다. 소프트웨어로 전체 네트워크 스택을 구현하지 않고도 STM32 펌웨어에서 micro-ROS 에이전트로 UDP 패킷을 전송할 수 있습니다.

이 펌웨어는 어떻게 ROS 데이터를 이더넷으로 전송하나요? CAN 프레임을 ROS 메시지로 변환한 뒤, W5500 이더넷 위에 구현된 커스텀 UDP 전송을 통해 micro-ROS로 전달합니다.

micro-ROS는 어떤 전송 프로토콜을 사용하나요? STM32 장치와 micro-ROS 에이전트 사이에 UDP 전송을 사용합니다.

W5500은 MCU에 어떻게 연결되나요? 펌웨어에 정의된 CS, SCLK, MOSI, MISO 핀을 통해 SPI 버스로 연결됩니다.

CAN 초기화에 실패하면 어떻게 되나요? 디버그 펌웨어 버전에서는 정의되지 않은 동작을 방지하기 위해 무한 루프에 진입합니다.


태그

W5500 / WIZnet / micro-ROS / STM32 / CAN 버스 / ROS2 / UDP 네트워킹 / 임베디드 로보틱스 / 텔레메트리 브리지

Documents
Comments Write