Wiznet makers

irina

Published February 27, 2026 ©

152 UCC

5 WCC

102 VAR

0 Contests

0 Followers

0 Following

Original Link

plc-stm32

Robust industrial PLC using STM32 MCU and W5500 Ethernet controller. Supports 12 inputs, 16 relays, and Modbus TCP/RTU for stable real-time control systems.

COMPONENTS
PROJECT DESCRIPTION

Summary

이 프로젝트는 STM32F407VGT6를 기반으로 설계된 PLC 컨트롤러 하드웨어로, Ethernet 인터페이스에 WIZnet W5500 하드웨어 TCP/IP 오프로드 칩을 사용합니다. 시스템은 12개의 디지털 입력, 16개의 2A 릴레이 출력, RS485 통신, 그리고 ESP32 기반 Wi-Fi 옵션을 포함합니다. W5500은 전용 Ethernet 컨트롤러로 동작하며, STM32의 RAM과 CPU 자원을 소모하지 않고 안정적인 유선 네트워크 통신을 제공합니다.

What the Project Does

이 저장소는 산업용 자동화를 목표로 한 소형 PLC 보드의 하드웨어 설계 파일을 포함하고 있습니다. 주요 구성 요소는 다음과 같습니다.

  • MCU: STM32F407VGT6 (Cortex-M4)
  • 디지털 입력: 12채널
  • 릴레이 출력: 16채널 (2A 정격)
  • Ethernet: W5500
  • RS485: 산업용 시리얼 통신
  • Wi-Fi: ESP32-WROOM-32U

이 PLC 보드는 다음과 같은 기능을 수행하도록 설계되었습니다.

  • 센서 및 스위치 입력 모니터링
  • 릴레이를 통한 액추에이터 제어
  • Ethernet 기반 통신 (예: Modbus TCP 또는 커스텀 프로토콜)
  • RS485 기반 산업 프로토콜 통신 (예: Modbus RTU)
  • 선택적 Wi-Fi 연결 지원

저장소 구조(eagle-pcb/, 이미지 파일, README 등)를 보면 현재는 PCB 및 회로도 설계 중심이며, 펌웨어 소스 코드는 포함되어 있지 않습니다.

즉, 이 프로젝트는 Ethernet PLC를 위한 하드웨어 플랫폼을 정의하고 있지만, W5500을 실제로 구동하는 네트워크 스택 구현은 포함되어 있지 않습니다.

WIZnet W5500의 역할

산업용 환경에서는 Wi-Fi보다 유선 Ethernet이 선호됩니다. EMI(전자기 간섭)에 강하고 지연 시간(Latency)이 예측 가능하기 때문입니다.

W5500은 STM32와 SPI로 통신하며 다음과 같은 이점을 제공합니다.

  • MCU 자원 보존: TCP/IP 처리를 하드웨어가 담당하므로 STM32의 RAM 사용량을 획기적으로 줄여줍니다.
  • 독립적 소켓 관리: 8개의 하드웨어 소켓을 지원하여 Modbus TCP 서버와 데이터 로그 전송을 동시에 처리할 수 있습니다.
  • 안정성: 소프트웨어 스택에서 발생할 수 있는 메모리 누수나 크래시로부터 자유롭습니다.

펌웨어 구현 가이드 (Conceptual)

현재 해당 저장소는 하드웨어 설계(Eagle PCB) 중심입니다. W5500을 구동하기 위해서는 WIZnet ioLibrary를 활용한 SPI 통신 설정이 필요합니다.

// W5500 네트워크 초기화 예시
#include "wizchip_conf.h"

void wizchip_init_network(void) {
    uint8_t txSize[8] = {2,2,2,2,2,2,2,2}; // 소켓별 버퍼 설정
    uint8_t rxSize[8] = {2,2,2,2,2,2,2,2};
    
    wizchip_init(txSize, rxSize);

    wiz_NetInfo netInfo = {
        .mac = {0x00, 0x08, 0xdc, 0x01, 0x02, 0x03},
        .ip  = {192, 168, 1, 100},
        .sn  = {255, 255, 255, 0},
        .gw  = {192, 168, 1, 1}
    };
    wizchip_setnetinfo(&netInfo);
}

실전 구축을 위한 팁 (Pitfalls)

  • 절연 설계: 산업용 릴레이 작동 시 발생하는 노이즈를 방지하기 위해 로직 GND와 파워 GND 분리가 필수입니다.
  • SPI 무결성: W5500은 고속 SPI를 지원하지만, PCB 패턴 길이에 따라 신호 왜곡이 생길 수 있으니 적절한 클럭 설정과 터미네이션이 필요합니다.
  • 프로토콜 확장: Modbus TCP(Port 502)를 구현하여 상위 SCADA 시스템이나 HMI와 연동해 보세요.

FAQ

Q: 왜 STM32 내장 MAC + LwIP 대신 W5500을 사용하나요?

W5500은 TCP/IP 스택을 하드웨어로 처리하므로 MCU의 RAM과 CPU 부하를 줄일 수 있습니다. PLC와 같이 실시간 제어가 중요한 시스템에서는 네트워크 스택이 제어 루프에 영향을 주지 않도록 분리하는 것이 중요합니다.

Q: W5500은 STM32F407과 어떻게 연결되나요?

SPI 인터페이스(SCK, MISO, MOSI, CS)로 연결되며, 추가로 RESET 및 INT 핀을 사용할 수 있습니다. W5500은 MAC과 PHY를 내부에 통합하고 있어 별도의 외부 PHY 설정이 필요하지 않습니다.

Q: 이 프로젝트에서 W5500의 구체적인 역할은 무엇인가요?

산업용 Ethernet 통신 인터페이스를 제공합니다. SCADA 시스템이나 Modbus TCP 마스터와의 통신을 담당하며, 안정적인 유선 네트워크 연결을 보장합니다.

Q: 초보자도 구현할 수 있나요?

STM32 펌웨어 개발 경험, SPI 통신 이해, 산업 통신 프로토콜(Modbus 등)에 대한 기본 지식이 필요합니다. 하드웨어 조립 및 디버깅 경험도 요구됩니다.

Q: ESP32 Wi-Fi만 사용하는 것과 비교하면 어떤 차이가 있나요?

Wi-Fi는 설치 편의성과 무선 확장성 측면에서 장점이 있지만, 지연 시간 변동과 RF 환경 영향을 받습니다. 산업 환경에서는 안정성과 예측 가능성 측면에서 유선 Ethernet(W5500)이 일반적으로 더 적합합니다.

 


Summary

This project presents a custom PLC controller built around the STM32F407VGT6 with Ethernet connectivity via the W5500 hardware TCP/IP offload chip. The system integrates 12 digital inputs, 16 relay outputs (2A), RS485 communication, and optional Wi-Fi using ESP32. The W5500 serves as the dedicated Ethernet interface, enabling deterministic wired networking without consuming STM32 RAM for TCP/IP stack processing.

What the Project Does

The repository contains the hardware design files for a compact PLC board intended for industrial-style automation tasks. The system architecture includes:

  • MCU: STM32F407VGT6 (Cortex-M4)
  • Digital Inputs: 12 channels
  • Relay Outputs: 16 channels (2A rated)
  • Ethernet: W5500
  • RS485: Industrial serial communication
  • Wi-Fi: ESP32-WROOM-32U module

The PLC is designed to:

  • Monitor field inputs (sensors, switches)
  • Control relay outputs (actuators, motors, contactors)
  • Communicate over Ethernet (likely Modbus TCP or custom protocol)
  • Provide RS485-based industrial protocol support (e.g., Modbus RTU)
  • Optionally support Wi-Fi connectivity

From the repository structure (eagle-pcb/, hardware images, and README), the project currently provides PCB and schematic design files. Firmware implementation is not included.

This means the system defines a hardware-capable Ethernet PLC platform, but does not yet include network stack implementation.

 

Key Point: The Role of WIZnet W5500

In industrial settings, wired Ethernet is generally preferred over Wi-Fi. It offers superior immunity to EMI (Electromagnetic Interference) and provides predictable, low-latency communication.

The W5500 communicates with the STM32 via SPI and offers the following advantages:

  • MCU Resource Preservation: Since the hardware handles the TCP/IP stack, the STM32's RAM usage is significantly reduced.
  • Independent Socket Management: It supports 8 independent hardware sockets, allowing for simultaneous tasks like acting as a Modbus TCP server while streaming data logs.
  • Stability: It is immune to the memory leaks or crashes that can occasionally occur in complex software-based network stacks.

Firmware Implementation Guide (Conceptual)

Currently, this repository focuses on hardware design (Eagle PCB). To drive the W5500, you need to implement the SPI communication logic using the WIZnet ioLibrary.

// Example: Initializing the W5500 network
#include "wizchip_conf.h"

void wizchip_init_network(void) {
    uint8_t txSize[8] = {2,2,2,2,2,2,2,2}; // Socket buffer configuration
    uint8_t rxSize[8] = {2,2,2,2,2,2,2,2};
    
    wizchip_init(txSize, rxSize);

    wiz_NetInfo netInfo = {
        .mac = {0x00, 0x08, 0xdc, 0x01, 0x02, 0x03},
        .ip  = {192, 168, 1, 100},
        .sn  = {255, 255, 255, 0},
        .gw  = {192, 168, 1, 1}
    };
    wizchip_setnetinfo(&netInfo);
}

Practical Tips for Implementation

  • Isolation Design: To prevent noise caused by industrial relay operation, it is essential to separate Logic GND from Power GND.
  • SPI Integrity: While the W5500 supports high-speed SPI, signal distortion can occur depending on PCB trace lengths. Ensure proper clock settings and consider signal termination if needed.
  • Protocol Expansion: Implement Modbus TCP (Port 502) to enable seamless integration with upper-level SCADA systems or HMI devices.v

FAQ

Q: Why use W5500 instead of STM32’s internal MAC with LwIP?

W5500 removes the need for a software TCP/IP stack and reduces RAM/CPU usage. In a PLC where deterministic I/O timing is important, hardware TCP/IP offload prevents networking from interfering with real-time control loops.

Q: How does W5500 connect to STM32F407?

It connects via SPI (SCK, MISO, MOSI, CS) plus reset and interrupt pins. No external PHY configuration is required because the W5500 integrates the MAC and PHY.

Q: What role does W5500 play in this PLC project?

It provides the wired Ethernet interface for industrial communication, likely for Modbus TCP or supervisory SCADA integration. It enables stable wired networking independent of Wi-Fi.

Q: Can beginners build this?

Hardware-level assembly and STM32 firmware development experience are required. Familiarity with SPI, embedded C, and industrial communication protocols (Modbus) is recommended.

Q: How does this compare to using Wi-Fi (ESP32 only)?

Wi-Fi offers convenience and remote deployment flexibility but introduces latency variation and RF dependency. Wired Ethernet via W5500 provides stable timing and is generally preferred in industrial PLC environments.

 

Documents
Comments Write