Wiznet makers

mason

Published April 16, 2026 © GNU General Public License, version 3 or later (GPL3+)

149 UCC

21 WCC

32 VAR

0 Contests

0 Followers

0 Following

Original Link

ROR_Controller

ROR_Controller

COMPONENTS Hardware components

WIZnet - W5500

x 1


PROJECT DESCRIPTION

프로젝트가 하는 일

ROR_Controller는 Roll-Off Roof 방식의 천문 관측소 지붕을 네트워크로 제어하기 위한 PLC 기반 컨트롤러입니다. 사용자는 ASCOM 호환 천문 소프트웨어나 PowerShell TCP 명령을 통해 지붕을 열고 닫을 수 있으며, 컨트롤러는 센서 상태와 마운트 주차 상태를 확인한 뒤 모터 출력을 제어합니다.

전체 동작 흐름은 비교적 명확합니다. Windows PC의 ASCOM Dome Driver가 P1AM-100 컨트롤러의 IP 주소와 TCP 포트 5000으로 접속합니다. P1AM-ETH 모듈의 W5500이 유선 이더넷 연결을 처리하고, Arduino 기반 펌웨어가 open_roof, close_roof, stop_roof 같은 문자열 명령을 읽습니다. 이후 PLC 로직은 리미트 센서, 감속 위치 센서, 수동 스위치, 마운트 상태를 확인하고 모터 정방향·역방향·고속·저속 출력을 제어합니다.

이 프로젝트는 PLC가 단순한 산업용 제어 장비를 넘어, 네트워크 통신, 안전 인터록, 모터 제어, 천문 자동화 소프트웨어 연동까지 통합할 수 있음을 보여주는 좋은 활용 사례입니다.

이미지 출처 : AI 생성

주요 구성 요소

AutomationDirect P1AM-100은 이 프로젝트의 메인 PLC CPU입니다. Arduino 스타일 코드로 작성된 펌웨어를 실행하면서 P1AM 모듈 초기화, 센서 입력 판독, 모터 출력 제어, watchdog 처리, 네트워크 명령 파싱을 담당합니다. 지붕 제어에서는 단순한 통신 장치가 아니라, 안전 조건을 확인한 뒤 실제 출력 신호를 결정하는 중심 제어기입니다.

ProductivityOpen Arduino-compatible CPU: C++, microB-USB port,  (programmable logic controller) (PN# P1AM-100) | AutomationDirect

이미지 출처 : https://www.automationdirect.com

P1AM-ETH Ethernet Module은 P1AM-100에 유선 이더넷 기능을 추가하는 확장 장비입니다. 이 모듈은 내부에 WIZnet W5500 Ethernet Controller를 포함하고 있으며, P1AM-100과 SPI로 통신합니다. 펌웨어에서는 Arduino Ethernet 라이브러리를 통해 W5500을 제어하고, TCP 서버를 구성해 ASCOM Driver와 PowerShell 스크립트의 명령을 수신합니다.

Ethernet Shield: for ProductivityOpen P1AM-100 CPU (PN# P1AM-ETH) |  AutomationDirect

이미지 출처 : https://www.automationdirect.com

P1-15CDD1 I/O Module은 현장 입출력을 담당합니다. 이 프로젝트에서는 열림 감속 센서, 열림 리미트 센서, 닫힘 감속 센서, 닫힘 리미트 센서, 망원경 주차 센서, 수동 열림 스위치, 수동 닫힘 스위치를 입력으로 사용합니다. 출력은 모터 정방향, 역방향, 고속, 저속, 마운트 전원, 카메라 전원, 히터 전원으로 나뉩니다.

Discrete Combo Module: 8-pt in, 7-pt out (PN# P1-15CDD1) | AutomationDirect

이미지 출처 : https://www.automationdirect.com

InduSKY 근접 센서는 지붕의 위치를 판단하는 입력 장치입니다. 지붕이 완전히 열렸는지, 완전히 닫혔는지, 감속 구간에 들어왔는지를 판단하는 데 사용됩니다.

InduSKY 2pcs 8mm Inductive Proximity Sensor Detecting Distance Approach  Sensor Cylinder Proximity Switch NPN NO DC 6-36V 300mA 3-Wire (Diameter  18mm) : Buy Online at Best Price in KSA - Souq is

이미지 출처 : https://www.amazon.sa/-/en/InduSKY-Inductive-Proximity-Detecting-Distance/dp/B0872Y3C7D

AutomationDirect GS2-10P5 AC Drive는 모터 구동을 담당하는 인버터입니다. PLC 출력은 드라이브에 방향과 속도 신호를 전달하고, 실제 지붕 구동은 AC 드라이브와 모터가 수행합니다.

AC Micro Drive: 1/2hp with 1-phase input, (VFD) (PN# GS2-10P5) |  AutomationDirect

이미지 출처 : https://www.automationdirect.com

AutomationDirect Y360 AC Motor는 지붕을 움직이는 구동원입니다. 프로젝트 구성상 3상 AC 모터를 사용하며, 드라이브와 감속기를 통해 Roll-Off Roof 구조물을 이동시킵니다.

이미지 출처 : https://www.automationdirect.com

WG-175-040-D Gearbox, Aleko Gear, Gear Rack은 모터 회전을 지붕의 직선 이동으로 바꾸는 기계 구동부입니다. 감속기는 모터의 속도와 토크를 조정하고, 기어와 랙은 지붕 구조물을 실제로 밀고 당기는 역할을 합니다.

Worm Gearbox: general purpose, 40:1 ratio (PN# WG-175-040-D) |  AutomationDirect

이미지 출처 : https://www.automationdirect.com

ASCOM Dome Driver는 천문 자동화 소프트웨어와 PLC 컨트롤러 사이의 소프트웨어 어댑터입니다. 드라이버는 TCP 포트 5000을 통해 P1AM-100에 접속하고, 지붕 열기·닫기·정지 명령을 전송합니다. 또한 컨트롤러에서 받은 상태 정보를 읽어 ASCOM 환경에 맞는 지붕 상태로 변환합니다.

이미지 출처 : AI 생성

WIZnet이 들어가는 위치

이 프로젝트에서 WIZnet 제품은 W5500입니다. W5500은 별도 브레이크아웃 보드로 직접 배선된 것이 아니라, P1AM-ETH 모듈 내부의 이더넷 컨트롤러로 사용됩니다. P1AM-100은 SPI로 P1AM-ETH와 통신하고, 펌웨어에서는 Arduino Ethernet 라이브러리를 통해 TCP 서버를 구성합니다.

W5500의 역할은 지붕 제어 명령을 위한 유선 TCP/IP 경로를 제공하는 것입니다. 관측소 지붕 제어는 대역폭보다 연결 안정성, 물리 연결 상태 확인, 명령 지연의 예측 가능성이 중요합니다. W5500은 하드웨어 TCP/IP 스택과 내장 Ethernet PHY를 제공하므로, P1AM-100은 복잡한 네트워크 스택 처리보다 센서 판독과 모터 제어 로직에 집중할 수 있습니다.

구현 노트

원본 파일: Controller Source/ROR Controller.ino

 
byte mac[] = { 0x60, 0x52, 0xD0, 0x06, 0x8F, 0x21 };

EthernetServer tcpServer = EthernetServer(5000);
EthernetClient clients[2];

Ethernet.init(5);

if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
}

tcpServer.begin();
 

이 코드는 P1AM-ETH의 W5500을 초기화하고 TCP 포트 5000에서 서버를 시작합니다. Ethernet.init(5)는 P1AM-ETH의 CS 핀 설정과 연결됩니다. Ethernet.begin(mac)은 DHCP로 IP 설정을 시도하며, 이후 루프에서는 유선 연결 상태가 정상일 때 클라이언트 접속과 명령 수신을 처리합니다.

원본 파일: Controller Source/ROR Controller.ino

 
if (sCommand == "open_roof") {
    bOpenRoof = true;
    bCloseRoof = false;
    return true;
} else if (sCommand == "close_roof") {
    bOpenRoof = false;
    bCloseRoof = true;
    return true;
} else if (sCommand == "stop_roof") {
    bOpenRoof = false;
    bCloseRoof = false;
    return true;
}
 

이 부분은 TCP 명령을 PLC 제어 플래그로 바꾸는 경계입니다. 네트워크에서 들어온 문자열이 곧바로 모터를 구동하지 않고, bOpenRoof, bCloseRoof 같은 내부 상태로 변환됩니다. 이후 SetMotorDrive() 로직이 마운트 연결·주차 상태, 리미트 센서, 감속 센서, 방향 전환 대기 시간을 확인한 뒤 실제 출력 채널을 제어합니다.

원본 파일: ASCOM Driver/ASCOM.Dome.RORController/Driver.cs

 
tcpClientROR.Connect(sIPAddress, nTCPPort);

byte[] byteOpenRoof =
    System.Text.Encoding.UTF8.GetBytes("open_roof");
tcpStream.Write(byteOpenRoof, 0, byteOpenRoof.Length);

byte[] byteCloseRoof =
    System.Text.Encoding.UTF8.GetBytes("close_roof");
tcpStream.Write(byteCloseRoof, 0, byteCloseRoof.Length);
 

ASCOM Driver는 Roll-Off Roof를 ASCOM의 Dome Shutter로 다룹니다. 천문 자동화 소프트웨어가 지붕 열기나 닫기 동작을 호출하면, 드라이버는 같은 TCP 명령 문자열을 P1AM-100 컨트롤러로 보냅니다. 드라이버는 수신한 JSON 상태에서 지붕 열림, 닫힘, 이동 중, 센서 상태, 마운트 상태를 읽어 내부 상태로 갱신합니다.

실전 팁 / 주의점

  • P1AM-ETH는 W5500 기반 SPI 모듈이므로 Ethernet.init(5)의 CS 핀 설정을 먼저 확인하시는 것이 좋습니다.
  • ASCOM Driver와 펌웨어가 같은 TCP 포트 5000을 기준으로 동작하므로, 방화벽과 IP 주소 설정을 함께 점검하셔야 합니다.
  • DHCP는 설정이 간단하지만, 실제 설치 환경에서는 DHCP 예약 또는 고정 IP 운용이 더 안정적입니다.
  • 지붕 제어에서는 네트워크보다 센서 검증이 더 중요할 수 있습니다. 열림·닫힘 리미트 센서와 감속 센서가 잘못 동작하면 기계적 충돌 위험이 있습니다.
  • 코드에는 마운트가 연결되어 있지 않거나 주차 상태가 확인되지 않으면 지붕 이동 명령을 중지하는 로직이 있습니다. 원격 관측소에서는 이 인터록을 우회하지 않는 것이 안전합니다.
  • W5500은 8개 독립 소켓을 지원하지만, 이 프로젝트의 펌웨어는 클라이언트 배열을 2개로 제한합니다. ASCOM Driver, 테스트 스크립트, 디버그 클라이언트를 동시에 붙일 경우 연결 수를 관리하셔야 합니다.

FAQ

Q: 왜 이 프로젝트에서 W5500을 사용하나요?
A: 이 프로젝트는 원격 관측소 지붕을 제어하므로 무선 편의성보다 안정적인 유선 연결이 더 중요합니다. W5500은 하드웨어 TCP/IP 스택, 10/100 Ethernet PHY, 8개 독립 소켓, 내부 버퍼를 제공해 P1AM-100이 네트워크 처리보다 PLC 제어 로직에 집중할 수 있게 해 줍니다.

Q: W5500은 P1AM-100에 어떻게 연결되나요?
A: W5500은 P1AM-ETH 모듈 안에 포함되어 있으며, P1AM-100과 SPI로 통신합니다. Arduino 환경에서는 Arduino Ethernet 라이브러리로 제어하고, 펌웨어에서는 Ethernet.init(5)로 CS 핀을 지정합니다.

Q: W5500은 이 프로젝트에서 정확히 어떤 역할을 하나요?
A: W5500은 ASCOM Driver 또는 PowerShell 스크립트가 보내는 TCP 명령을 P1AM-100 펌웨어로 전달하는 네트워크 계층입니다. 펌웨어는 W5500을 통해 들어온 open_roof, close_roof, stop_roof 명령을 내부 플래그로 바꾸고, 센서 조건을 확인한 뒤 모터 출력을 제어합니다.

Q: 초보자도 따라할 수 있나요?
A: 단순 Arduino 이더넷 예제보다는 난이도가 높습니다. P1AM 모듈 구성, TCP 소켓, ASCOM Driver, AC 모터 드라이브, 리미트 센서, 전기 안전을 함께 이해해야 합니다. 코드 구조는 비교적 명확하지만, 실제 지붕을 움직이는 프로젝트이므로 기계적 인터록과 현장 안전 설계가 필요합니다.

Q: Wi-Fi 대신 W5500 유선 이더넷을 쓰는 이유는 무엇인가요?
A: 관측소는 장시간 무인 운용되는 경우가 많고, 지붕 제어는 명령 손실이나 지연 변동에 민감합니다. W5500 기반 유선 이더넷은 물리 연결 상태를 명확히 확인할 수 있고 TCP 서버 구조가 단순해 ASCOM Driver와 PLC 사이의 제어 경로를 예측하기 쉽습니다.

 

What the Project Does

ROR_Controller is a PLC-based controller for operating a Roll-Off Roof astronomical observatory over a network. The user can open and close the roof through ASCOM-compatible astronomy software or PowerShell TCP commands, while the controller checks sensor status and mount parking status before controlling the motor outputs.

The overall operating flow is straightforward. The ASCOM Dome Driver on a Windows PC connects to the IP address of the P1AM-100 controller through TCP port 5000. The W5500 inside the P1AM-ETH module handles the wired Ethernet connection, and the Arduino-based firmware reads string commands such as open_roof, close_roof, and stop_roof. The PLC logic then checks the limit sensors, deceleration position sensors, manual switches, and mount status before controlling the motor outputs for forward, reverse, high-speed, and low-speed operation.

This project is a good example of how a PLC can go beyond basic industrial control and integrate network communication, safety interlocks, motor control, and astronomy automation software in one system.

Image source : AI Generated

Main Components

AutomationDirect P1AM-100 is the main PLC CPU used in this project. It runs firmware written in Arduino-style code and handles P1AM module initialization, sensor input reading, motor output control, watchdog processing, and network command parsing. In this roof control system, it is not just a communication device. It is the central controller that checks safety conditions and decides the actual output signals.

ProductivityOpen Arduino-compatible CPU: C++, microB-USB port, programmable logic controller (PN# P1AM-100) | AutomationDirect

ProductivityOpen Arduino-compatible CPU: C++, microB-USB port,  (programmable logic controller) (PN# P1AM-100) | AutomationDirect

Image source: https://www.automationdirect.com

P1AM-ETH Ethernet Module is an expansion device that adds wired Ethernet functionality to the P1AM-100. This module includes a WIZnet W5500 Ethernet Controller internally and communicates with the P1AM-100 through SPI. In the firmware, the W5500 is controlled through the Arduino Ethernet library, and a TCP server is configured to receive commands from the ASCOM Driver and PowerShell scripts.

Ethernet Shield: for ProductivityOpen P1AM-100 CPU (PN# P1AM-ETH) | AutomationDirect

Ethernet Shield: for ProductivityOpen P1AM-100 CPU (PN# P1AM-ETH) |  AutomationDirect

Image source: https://www.automationdirect.com

P1-15CDD1 I/O Module handles field input and output. In this project, the inputs are used for the open deceleration sensor, open limit sensor, close deceleration sensor, close limit sensor, telescope parking sensor, manual open switch, and manual close switch. The outputs are assigned to motor forward, motor reverse, high speed, low speed, mount power, camera power, and heater power.

Discrete Combo Module: 8-pt in, 7-pt out (PN# P1-15CDD1) | AutomationDirect

Discrete Combo Module: 8-pt in, 7-pt out (PN# P1-15CDD1) | AutomationDirect

Image source: https://www.automationdirect.com

InduSKY proximity sensors are input devices used to determine the roof position. They are used to detect whether the roof is fully open, fully closed, or entering a deceleration zone.

InduSKY 2pcs 8mm Inductive Proximity Sensor Detecting Distance Approach Sensor Cylinder Proximity Switch NPN NO DC 6-36V 300mA 3-Wire (Diameter 18mm): Buy Online at Best Price in KSA - Souq is

InduSKY 2pcs 8mm Inductive Proximity Sensor Detecting Distance Approach  Sensor Cylinder Proximity Switch NPN NO DC 6-36V 300mA 3-Wire (Diameter  18mm) : Buy Online at Best Price in KSA - Souq is

Image source: https://www.amazon.sa/-/en/InduSKY-Inductive-Proximity-Detecting-Distance/dp/B0872Y3C7D

AutomationDirect GS2-10P5 AC Drive is the inverter responsible for motor drive control. The PLC outputs send direction and speed signals to the drive, while the AC drive and motor perform the actual roof movement.

AC Micro Drive: 1/2hp with 1-phase input, VFD (PN# GS2-10P5) | AutomationDirect

AC Micro Drive: 1/2hp with 1-phase input, (VFD) (PN# GS2-10P5) |  AutomationDirect

Image source: https://www.automationdirect.com

AutomationDirect Y360 AC Motor is the power source that moves the roof. In this project configuration, a three-phase AC motor is used, and the Roll-Off Roof structure is moved through the drive and gearbox.

Image source: https://www.automationdirect.com

WG-175-040-D Gearbox, Aleko Gear, and Gear Rack are the mechanical drive components that convert motor rotation into the roof’s linear movement. The gearbox adjusts motor speed and torque, while the gear and rack physically push and pull the roof structure.

Worm Gearbox: general purpose, 40:1 ratio (PN# WG-175-040-D) | AutomationDirect

Worm Gearbox: general purpose, 40:1 ratio (PN# WG-175-040-D) |  AutomationDirect

Image source: https://www.automationdirect.com

ASCOM Dome Driver is the software adapter between astronomy automation software and the PLC controller. The driver connects to the P1AM-100 through TCP port 5000 and sends roof open, close, and stop commands. It also reads status information from the controller and converts it into roof status values suitable for the ASCOM environment.

Image source : AI Generated

 

Where WIZnet Fits

The WIZnet product used in this project is the W5500. The W5500 is not wired as a separate breakout board. Instead, it is used as the Ethernet controller inside the P1AM-ETH module. The P1AM-100 communicates with the P1AM-ETH over SPI, and the firmware uses the Arduino Ethernet library to configure the TCP server.

The role of the W5500 is to provide a wired TCP/IP path for roof control commands. In observatory roof control, connection stability, physical link status, and predictable command latency are more important than bandwidth. Because the W5500 provides a hardware TCP/IP stack and an integrated Ethernet PHY, the P1AM-100 can focus on sensor reading and motor control logic rather than complex network stack handling.

Implementation Notes

Original file: Controller Source/ROR Controller.ino

 
byte mac[] = { 0x60, 0x52, 0xD0, 0x06, 0x8F, 0x21 };

EthernetServer tcpServer = EthernetServer(5000);
EthernetClient clients[2];

Ethernet.init(5);

if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
}

tcpServer.begin();
 

This code initializes the W5500 inside the P1AM-ETH and starts a server on TCP port 5000. Ethernet.init(5) is tied to the CS pin setting of the P1AM-ETH. Ethernet.begin(mac) attempts to configure the IP address through DHCP, and the main loop later handles client connections and command reception when the wired link is active.

Original file: Controller Source/ROR Controller.ino

 
if (sCommand == "open_roof") {
    bOpenRoof = true;
    bCloseRoof = false;
    return true;
} else if (sCommand == "close_roof") {
    bOpenRoof = false;
    bCloseRoof = true;
    return true;
} else if (sCommand == "stop_roof") {
    bOpenRoof = false;
    bCloseRoof = false;
    return true;
}
 

This section is the boundary where TCP commands are converted into PLC control flags. The string received from the network does not drive the motor directly. Instead, it is converted into internal states such as bOpenRoof and bCloseRoof. The SetMotorDrive() logic then checks mount connection and parking status, limit sensors, deceleration sensors, and direction-change delay timing before controlling the actual output channels.

Original file: ASCOM Driver/ASCOM.Dome.RORController/Driver.cs

 
tcpClientROR.Connect(sIPAddress, nTCPPort);

byte[] byteOpenRoof =
    System.Text.Encoding.UTF8.GetBytes("open_roof");
tcpStream.Write(byteOpenRoof, 0, byteOpenRoof.Length);

byte[] byteCloseRoof =
    System.Text.Encoding.UTF8.GetBytes("close_roof");
tcpStream.Write(byteCloseRoof, 0, byteCloseRoof.Length);
 

The ASCOM Driver treats the Roll-Off Roof as an ASCOM Dome Shutter. When astronomy automation software calls an open or close operation, the driver sends the same TCP command string to the P1AM-100 controller. The driver also reads the received JSON status and updates its internal state for roof open, closed, moving, sensor status, and mount status.

Practical Tips / Pitfalls

  • Since the P1AM-ETH is a W5500-based SPI module, it is recommended to check the CS pin setting in Ethernet.init(5) first.
  • The ASCOM Driver and firmware both operate around TCP port 5000, so firewall rules and IP address settings should be checked together.
  • DHCP is easy to configure, but DHCP reservation or a static IP is more stable for real installations.
  • In roof control, sensor validation can be more important than network communication. If the open and close limit sensors or deceleration sensors behave incorrectly, there is a risk of mechanical collision.
  • The code includes logic that stops roof movement if the mount is not connected or if parking status is not confirmed. In a remote observatory, this interlock should not be bypassed.
  • The W5500 supports 8 independent sockets, but this project’s firmware limits the client array to 2 clients. Connection count should be managed when the ASCOM Driver, test scripts, and debug clients are connected at the same time.

FAQ

Q: Why does this project use the W5500?
A: This project controls the roof of a remote observatory, so stable wired connectivity is more important than wireless convenience. The W5500 provides a hardware TCP/IP stack, 10/100 Ethernet PHY, 8 independent sockets, and internal buffers, allowing the P1AM-100 to focus on PLC control logic rather than network processing.

Q: How is the W5500 connected to the P1AM-100?
A: The W5500 is included inside the P1AM-ETH module and communicates with the P1AM-100 through SPI. In the Arduino environment, it is controlled through the Arduino Ethernet library, and the firmware specifies the CS pin using Ethernet.init(5).

Q: What exactly does the W5500 do in this project?
A: The W5500 acts as the network layer that delivers TCP commands from the ASCOM Driver or PowerShell scripts to the P1AM-100 firmware. The firmware converts commands received through the W5500, such as open_roof, close_roof, and stop_roof, into internal flags, checks sensor conditions, and then controls the motor outputs.

Q: Can beginners follow this project?
A: This project is more advanced than a simple Arduino Ethernet example. It requires understanding of P1AM module configuration, TCP sockets, ASCOM Driver behavior, AC motor drives, limit sensors, and electrical safety. The code structure is relatively clear, but because it moves a real roof, mechanical interlocks and field safety design are required.

Q: Why use W5500 wired Ethernet instead of Wi-Fi?
A: Observatories are often operated unattended for long periods, and roof control is sensitive to command loss and latency variation. W5500-based wired Ethernet makes the physical link status easier to verify and provides a simple TCP server structure, making the control path between the ASCOM Driver and PLC more predictable.

Documents
  • Github Code

Comments Write