AR22 LCU: W5500 Ethernet TCP Dose Logging on a Dual-Range STM32F446 Radiation Detector
AR22 LCU v1.1 adds W5500 TCP logging to an STM32F446 gamma detector, streaming live dose-rate JSON without disturbing the core firmware.
0
Components
Hardware components
WIZnet - W5500
SPI1 @12.5 MHz, CS=PA4, RST=PC4. Static IP 192.168.1.22:15022. Single-socket TCP server streams dose-rate JSON using WIZnet ioLibrary.
Project description
๐ Overview
kzeta23 publishes AR22 LCU v1.1 as a Korean-documented STM32F446 firmware repository for a dual-range gamma radiation detector. The public GitHub profile does not publish a name, country, or organization, so this post keeps those fields conservative and focuses on the firmware evidence.
AR22 LCU v1.1 adds a WIZnet W5500 Ethernet TCP logging path to a validated radiation detector firmware. The detector counts pulses from two Geiger-Mueller tube channels, calculates dose rate with adaptive filtering, drives a 256x64 SSD1322 OLED and alarm output, and then streams the current dose rate as one JSON line over TCP port 15022.
Generated technical illustration: AR22 LCU as a dose-rate instrument with W5500 TCP logging.
The repository is more than a small networking demo. It documents a real embedded instrument firmware pattern: preserve the measurement and alarm core, then add a self-contained W5500 layer behind ETH_LOG_ENABLE. With that macro set to 1, a TCP client can connect to 192.168.1.22:15022 and receive output such as {"val":1.23,"unit":"uSv/h"}. With the macro set to 0, the Ethernet code is removed from the build.
System Configuration
The main controller is an STM32F446VET6 running as a Cortex-M4 application at 100 MHz. The firmware uses hardware timers for pulse counting, SPI and DMA for the OLED display, I2C for EEPROM settings, GPIO/EXTI for the front-panel switches, TIM5 PWM for the buzzer, and SPI1 for the W5500 Ethernet controller.
The current code and CubeMX project show this GM channel mapping:
- LOW dose channel: LND 7128 class GM tube,
GM_COUNT_LO, PA0, TIM8_ETR. - HIGH dose channel: LND 71631 class GM tube,
GM_COUNT_HI, PE7, TIM1_ETR.
That detail matters because an older overview table in the repository still describes the channel mapping in the opposite direction. The firmware itself is clearer: HAL_TIM_PeriodElapsedCallback() reads the LOW count from TIM8 and the HIGH count from TIM1, and comments in the ISR state that the GM channels were swapped to match the current wiring and labels.
The display is an SSD1322 256x64 OLED on SPI4 with DMA. A 24C01 I2C EEPROM stores the alarm threshold and the LOW/HIGH conversion factors. The firmware also includes a power-on self-test for display, LEDs, buzzer, and EEPROM, plus watchdog handling that is intentionally started only after long blocking startup work.
Measurement Chain and Firmware Timing
The radiation measurement path is built around a one-second sampling rhythm. TIM4 provides the timing source. Every second, the firmware snapshots the two hardware counters, resets them, and marks the one-second processing tick.
Generated technical diagram: the LOW and HIGH GM counts flow through timer snapshots, adaptive EMA, range logic, display, alarm, and W5500 TCP output.
process_dose_ema() then runs the signal-processing step. For each range it computes an exponential moving average of the raw count rate. The smoothing factor is adaptive: it rises when the recent reference diverges from the filtered value, which improves response to sudden dose changes, and it falls during stable readings, which reduces Poisson count noise on the display.
The LOW channel also applies dead-time correction before converting count rate to dose rate. The repository's sensor note explains why this asymmetry is intentional: the low-dose tube is much more sensitive, so dead-time loss is significant near the upper end of the LOW range, while the high-dose tube is deliberately lower sensitivity and stays within a more forgiving count-rate region at the documented system range.
Range switching is centered around 1000 uSv/h with +/-200 uSv/h hysteresis. LOW covers the low-background to about 1 mSv/h region, while HIGH carries the higher-dose region up to the 100 mSv/h system specification. The display code changes numeric formatting and units across the range, and the HIGH display shows OVERLOAD above the configured high-end threshold.
System Architecture and Data Flow
The W5500 layer does not own the measurement loop. It receives the same current dose variable that already feeds the OLED and alarm logic.
Generated technical diagram: GM pulses are counted by STM32F446 timers, processed into dose rate, displayed locally, and sent through a W5500 TCP socket.
During startup, the firmware initializes the display and self-test first, then loads EEPROM data, then initializes the W5500 before the independent watchdog starts. That ordering is not accidental. The repository notes explain that CubeMX regeneration may reinsert an early MX_IWDG_Init() call, and starting the watchdog before POST, EEPROM loading, and W5500 link wait can cause a boot loop. The project documents this as a maintenance checklist, not just a code comment.
The main loop has two relevant cadences:
- Every 1 second: alarm processing, range checking, dose EMA processing, USB diagnostic logging, and every second tick pair, W5500 JSON sending.
- Every 0.2 seconds: watchdog refresh, W5500 socket polling, and OLED display refresh.
This split keeps the W5500 socket state machine out of the timer ISR. The ISR snapshots counters and sets flags; the main loop does the network work.
W5500 TCP Logging Layer
The Ethernet integration is contained under MyLib/W5500/. It is useful because it separates application policy from chip-port details:
w5500_port_ar22.cmaps W5500 CS to PA4, reset to PC4, and SPI transfer calls toHAL_SPI_TransmitReceive,HAL_SPI_Transmit, andHAL_SPI_Receiveon SPI1.w5500_eth.cresets the chip, registers ioLibrary callbacks, checksVERSIONR == 0x04, allocates 2 KB RX/TX buffers for all eight sockets, writes static MAC/IP/subnet/gateway values, reads them back, and polls PHY link state.net_app.cowns the application socket: W5500 socket 0, TCP mode, port 15022.
Generated technical diagram: net_app_poll() opens and maintains the TCP socket, while net_app_send_dose() sends a JSON line when a client is connected.
The core socket state machine is short and recognizable to anyone who has used WIZnet ioLibrary:
case SOCK_CLOSED:
socket(NET_SOCK, Sn_MR_TCP, NET_PORT, 0);
break;
case SOCK_INIT:
listen(NET_SOCK);
break;
case SOCK_ESTABLISHED:
/* drain RX, ready to send JSON */
break;
case SOCK_CLOSE_WAIT:
disconnect(NET_SOCK);
break;
When the socket is established, net_app_send_dose(float dose_uSv) formats the current value as newline-delimited JSON and calls send(). Below 100 uSv/h it reports uSv/h; at or above that threshold it converts the value to mSv/h. If no client is connected, the function returns immediately.
โ๏ธ Role of the WIZnet Chip
The W5500 is the wired telemetry interface for the detector. It handles the TCP/IP stack in hardware, while the STM32F446 application continues to focus on pulse counting, filtering, display, alarm, EEPROM, and watchdog behavior.
That is the right fit for this project. Radiation monitoring is not a place where the main firmware should be burdened with wireless reconnect behavior, software TCP state management, or a large network stack. Here, the firmware opens one TCP socket through the WIZnet ioLibrary API and lets the W5500 handle framing, checksums, and TCP state internally.
The implementation is also easy to remove or port. ETH_LOG_ENABLE gates the entire Ethernet feature at compile time, and net_app.c uses standard ioLibrary socket calls rather than application-specific W5500 register pokes. A future move to another WIZnet chip would mainly affect the port and chip setup layer, not the dose-processing core.
Where It Fits - Value and Limits
AR22 LCU is valuable as a W5500 example because it is attached to a meaningful instrument firmware, not just a loopback server. The project shows how wired Ethernet can be grafted onto an existing embedded device as a low-risk telemetry channel: a lab PC, data logger, or bridge script can connect with telnet, netcat, or Python sockets and record live dose-rate readings.
The limits are also important. The public repository does not include schematic or PCB files, so the hardware layout cannot be audited from the repo alone. The network configuration is static IP only. There is no DHCP, no TLS, no authentication, and no multi-client design. Any host on the same LAN segment that can connect to port 15022 can receive the stream. This is appropriate for a controlled lab network, but it should not be exposed directly to an untrusted network.
The project also has a documentation mismatch worth noting for future maintainers: some overview text still describes the original LOW/HIGH timer mapping, while the current ISR and .ioc show the swapped mapping used by the firmware. For actual integration work, trust the code, .ioc, and pin labels.
Related WIZnet Maker Projects
A Low-Cost IoT Gamma-Ray Spectrometer with the Easy-F407V-ETH (W5500) Board is the closest radiation-domain comparison. It uses an STM32F407 and W5500-enabled board to stream gamma-ray spectrum data from a scintillation detector. AR22 LCU is different: it is a GM-tube dose-rate detector, not an energy spectrometer, and it adds W5500 as a firmware-isolated logging channel to an existing instrument.
Scintillation Monitor with Ethernet Interface is another radiation-monitoring example with Ethernet, KiCad hardware, and enclosure files. That project is stronger on physical design materials, while AR22 LCU is stronger on firmware depth: adaptive dual-range processing, EEPROM settings, watchdog startup notes, and a working W5500 TCP server.
Interrupt-Driven W5500 UDP Server on STM32F4 with FreeRTOS and ioLibrary is a useful implementation companion. It shows the ioLibrary style on STM32F4 in a FreeRTOS UDP reference. AR22 LCU uses the same WIZnet socket API family, but chooses TCP, no RTOS, and a production-like detector firmware context.
โ FAQ
Q. What does AR22 LCU use the W5500 for? It uses W5500 as a wired TCP telemetry interface. A client connects to 192.168.1.22:15022 and receives a dose-rate JSON line every two seconds when the socket is established.
Q. Is the W5500 path part of the radiation measurement algorithm? No. The measurement algorithm runs on STM32 timers and firmware variables. The W5500 path reads the current dose value and sends it to a TCP client.
Q. Which timer input is LOW and which is HIGH in the current code? The current firmware maps LOW to PA0/TIM8 and HIGH to PE7/TIM1. Some overview text is stale, but the ISR, .ioc, and pin labels confirm the current mapping.
Q. Can Ethernet be removed from the firmware build? Yes. ETH_LOG_ENABLE controls the W5500 feature at compile time. Setting it to 0 removes the Ethernet includes and calls from the build.
Q. Is this ready for an untrusted network? No. It uses a fixed IP TCP server without TLS or authentication. Treat it as a controlled-LAN telemetry channel unless extra security is added outside this firmware.
ํ๊ตญ์ด (Korean)
๐ ๊ฐ์
kzeta23๋ AR22 LCU v1.1์ STM32F446 ๊ธฐ๋ฐ ์ด์ค ๋ ์ธ์ง ๊ฐ๋ง์ ๊ฒ์ถ๊ธฐ ํ์จ์ด๋ก ๊ณต๊ฐํ์ต๋๋ค. GitHub ๊ณต๊ฐ ํ๋กํ์๋ ์ด๋ฆ, ๊ตญ๊ฐ, ์กฐ์ง ์ ๋ณด๊ฐ ์์ผ๋ฏ๋ก ์ด ๊ธ์์๋ ํ์ธ๋ ๋ ํฌ์ ์ฝ๋ ๊ทผ๊ฑฐ๋ง ๋ณด์์ ์ผ๋ก ๋ค๋ฃน๋๋ค. ๋ ํฌ์ ๋ฌธ์์ ์ฃผ์์ ๋๋ถ๋ถ ํ๊ตญ์ด๋ก ์์ฑ๋์ด ์์ต๋๋ค.
AR22 LCU v1.1์ ํต์ฌ์ ๊ฒ์ฆ๋ ๋ฐฉ์ฌ์ ๊ฒ์ถ๊ธฐ ํ์จ์ด์ WIZnet W5500 Ethernet TCP ๋ก๊น ๊ฒฝ๋ก๋ฅผ ์ถ๊ฐํ ์ ์ ๋๋ค. ํ์จ์ด๋ ๋ ๊ฐ์ ๊ฐ์ด๊ฑฐ-๋ฎฌ๋ฌ ๊ด ์ฑ๋์์ ํ์ค๋ฅผ ๊ณ์ํ๊ณ , ์ ์ํ ํํฐ๋ก ์ ๋๋ฅ ์ ๊ณ์ฐํ๋ฉฐ, SSD1322 OLED์ ์๋ ์ถ๋ ฅ์ ๊ตฌ๋ํฉ๋๋ค. ์ฌ๊ธฐ์ TCP ํฌํธ 15022๋ฅผ ํตํด ํ์ฌ ์ ๋๋ฅ ์ JSON ํ ์ค๋ก ์ ์กํ๋ W5500 ๊ฒฝ๋ก๊ฐ ๋ถ์ต๋๋ค.


๊ฐ์ด๊ฑฐ-๋ฎ๋ฌ ๊ณ์๊ด(GeigerโMรผller tube)์ด๋ผ๊ณ ํ๋ ๊ด(tube)์ ํตํด ๋ฐฉ์ฌ์ ์ ์ ํ๋ํ๋๋ฅผ ์ ์ ์์ผ๋ฉฐ, ์ธก์ ๋จ์๋ CPS(Count Per Second)์ด๋ค.
์์ฑ ๊ธฐ์ ์ผ๋ฌ์คํธ: AR22 LCU๋ฅผ ์ ๋๋ฅ ๊ณ์ธก๊ธฐ์ W5500 TCP ๋ก๊น
๊ตฌ์กฐ๋ก ํํํ์ต๋๋ค.
์ด ๋ ํฌ๋ ๋จ์ TCP ์์ ๊ฐ ์๋๋๋ค. ๊ธฐ์กด ๊ณ์ธก๊ณผ ์๋ ์ฝ์ด๋ฅผ ๋ณด์กดํ๊ณ , ETH_LOG_ENABLE ๋งคํฌ๋ก ๋ค์ W5500 ๊ณ์ธต์ ๋ถ๋ฆฌํด์ ๋ถ์ด๋ ๊ตฌ์กฐ์
๋๋ค. ๋งคํฌ๋ก๊ฐ 1์ด๋ฉด 192.168.1.22:15022๋ก ์ ์ํ TCP ํด๋ผ์ด์ธํธ๊ฐ {"val":1.23,"unit":"uSv/h"} ๊ฐ์ JSON ๋ฐ์ดํฐ๋ฅผ ๋ฐ์ ์ ์๊ณ , 0์ด๋ฉด Ethernet ๊ด๋ จ ์ฝ๋๊ฐ ๋น๋์์ ๋น ์ง๋๋ค.
์์คํ ๊ตฌ์ฑ
์ฃผ MCU๋ STM32F446VET6์ด๋ฉฐ Cortex-M4 ์ ํ๋ฆฌ์ผ์ด์ ์ผ๋ก 100 MHz์์ ๋์ํฉ๋๋ค. ํ์ค ๊ณ์์๋ ํ๋์จ์ด ํ์ด๋จธ๋ฅผ ์ฐ๊ณ , OLED๋ SPI์ DMA, ์ค์ ์ ์ฅ์ I2C EEPROM, ์ค์์น๋ GPIO/EXTI, ๋ถ์ ๋ TIM5 PWM, W5500์ SPI1์ ์ฌ์ฉํฉ๋๋ค.
์ต์ ์ฝ๋์ CubeMX ํ๋ก์ ํธ ๊ธฐ์ค์ GM ์ฑ๋ ๋งคํ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
- LOW ์ ๋ ์ฑ๋: LND 7128 ๊ณ์ด GM ๊ด,
GM_COUNT_LO, PA0, TIM8_ETR. - HIGH ์ ๋ ์ฑ๋: LND 71631 ๊ณ์ด GM ๊ด,
GM_COUNT_HI, PE7, TIM1_ETR.
์ด ๋ถ๋ถ์ ์ค์ํฉ๋๋ค. ๋ ํฌ์ ์ค๋๋ overview ํ์๋ LOW/HIGH ํ์ด๋จธ ๋งคํ์ด ๋ฐ๋๋ก ์ ํ ์์ง๋ง, ์ค์ ํ์จ์ด์ HAL_TIM_PeriodElapsedCallback()์ LOW ์นด์ดํธ๋ฅผ TIM8์์ ์ฝ๊ณ HIGH ์นด์ดํธ๋ฅผ TIM1์์ ์ฝ์ต๋๋ค. ISR ์ฃผ์์๋ ํ์ฌ ๋ฐฐ์ ๊ณผ ๋ผ๋ฒจ์ ๋ง์ถฐ ์ฑ๋์ด swap๋์๋ค๊ณ ์ ํ ์์ต๋๋ค.
๋์คํ๋ ์ด๋ SPI4+DMA ๊ธฐ๋ฐ SSD1322 256x64 OLED์ ๋๋ค. 24C01 I2C EEPROM์๋ ์๋ ์๊ณ๊ฐ๊ณผ LOW/HIGH ๋ณํ๊ณ์๊ฐ ์ ์ฅ๋ฉ๋๋ค. ๋ถํ ์์๋ ๋์คํ๋ ์ด, LED, ๋ถ์ , EEPROM์ ํ์ธํ๋ power-on self-test๊ฐ ์คํ๋๋ฉฐ, watchdog์ ๊ธด ๋ถํ ์์ ์ด ๋๋ ๋ค ์์๋๋๋ก ๊ตฌ์ฑ๋์ด ์์ต๋๋ค.
์ธก์ ์ฒด์ธ๊ณผ ํ์จ์ด ํ์ด๋ฐ
๋ฐฉ์ฌ์ ์ธก์ ๊ฒฝ๋ก๋ 1์ด ์ํ๋ง ๋ฆฌ๋ฌ์ ์ค์ฌ์ผ๋ก ๊ตฌ์ฑ๋ฉ๋๋ค. TIM4๊ฐ ์๊ฐ ๊ธฐ์ค์ ๋ง๋ค๊ณ , 1์ด๋ง๋ค ๋ ํ๋์จ์ด ์นด์ดํฐ ๊ฐ์ ์ฝ์ ๋ค ์นด์ดํฐ๋ฅผ ๋ฆฌ์ ํฉ๋๋ค.
์์ฑ ๊ธฐ์ ๋ค์ด์ด๊ทธ๋จ: LOW/HIGH GM ์นด์ดํธ๊ฐ ํ์ด๋จธ ์ค๋
์ท, ์ ์ํ EMA, ๋ ์ธ์ง ๋ก์ง, ํ์, ์๋, W5500 TCP ์ถ๋ ฅ์ผ๋ก ํ๋ฆ
๋๋ค.
์ดํ process_dose_ema()๊ฐ ์ ํธ ์ฒ๋ฆฌ๋ฅผ ์ํํฉ๋๋ค. ๊ฐ ๋ ์ธ์ง์์ raw count rate์ ์ง์์ด๋ํ๊ท ์ ๊ณ์ฐํ๊ณ , ์ต๊ทผ reference์ filtered ๊ฐ์ ์ฐจ์ด๊ฐ ํฌ๋ฉด alpha๋ฅผ ๋์ฌ ๋น ๋ฅด๊ฒ ๋ฐ์ํ๊ณ , ์์ ์ํ์์๋ alpha๋ฅผ ๋ฎ์ถฐ ๊ณ์ ๋
ธ์ด์ฆ๋ฅผ ์ค์
๋๋ค.
LOW ์ฑ๋์๋ dead-time correction๋ ์ ์ฉ๋ฉ๋๋ค. ๋ ํฌ์ ์ผ์ ๋ฌธ์๋ ์ด ๋น๋์นญ ์ฒ๋ฆฌ๊ฐ ์๋๋ ์ค๊ณ๋ผ๊ณ ์ค๋ช ํฉ๋๋ค. LOW ๊ด์ ๊ณ ๊ฐ๋๋ผ ์๋จ์์ dead-time ์์ค์ด ์๋ฏธ ์๊ฒ ์ปค์ง๊ณ , HIGH ๊ด์ ์ผ๋ถ๋ฌ ๋ฎ์ ๊ฐ๋์ ์งง์ dead time์ ๊ฐ์ง ์์๋ผ ๋ฌธ์ํ๋ ์์คํ ๋ฒ์์์๋ ๋ณด์ ํ์์ฑ์ด ๋ฎ์ต๋๋ค.
๋ ์ธ์ง ์ ํ์ 1000 uSv/h๋ฅผ ์ค์ฌ์ผ๋ก +/-200 uSv/h ํ์คํ
๋ฆฌ์์ค๋ฅผ ๋ก๋๋ค. LOW๋ ์ ์ ๋๋ถํฐ ์ฝ 1 mSv/h ๊ทผ์ฒ๊น์ง, HIGH๋ ๋ ๋์ ์ ๋ ์์ญ์ ๋ด๋นํฉ๋๋ค. ํ์ ์ฝ๋๋ ๊ฐ ๋ฒ์์ ๋ฐ๋ผ ๋จ์์ ํฌ๋งท์ ๋ฐ๊พธ๊ณ , HIGH ํ์์์๋ ์๋จ ์กฐ๊ฑด์์ OVERLOAD๋ฅผ ํ์ํฉ๋๋ค.
์์คํ ์ํคํ ์ฒ์ ๋ฐ์ดํฐ ํ๋ฆ
W5500 ๊ณ์ธต์ ์ธก์ ๋ฃจํ๋ฅผ ์์ ํ์ง ์์ต๋๋ค. OLED์ ์๋์ ์ฐ์ด๋ ํ์ฌ ์ ๋ ๋ณ์๋ฅผ ์ฝ์ด TCP๋ก ๋ด๋ณด๋ด๋ ๊ตฌ์กฐ์ ๋๋ค.
์์ฑ ๊ธฐ์ ๋ค์ด์ด๊ทธ๋จ: GM ํ์ค๋ STM32F446 ํ์ด๋จธ์์ ๊ณ์๋๊ณ , ์ ๋๋ฅ ๋ก ์ฒ๋ฆฌ๋ ๋ค ๋ก์ปฌ ํ์์ ์๋, W5500 TCP ์์ผ์ผ๋ก ์ ๋ฌ๋ฉ๋๋ค.
๋ถํ
์์๋ ์ ์คํฉ๋๋ค. ํ์จ์ด๋ ๋จผ์ ๋์คํ๋ ์ด์ self-test๋ฅผ ์ด๊ธฐํํ๊ณ , EEPROM ๋ฐ์ดํฐ๋ฅผ ๋ก๋ํ ๋ค, W5500์ ์ด๊ธฐํํ๊ณ ๋์ watchdog์ ์์ํฉ๋๋ค. ๋ ํฌ ๋ฌธ์์๋ CubeMX ์ฌ์์ฑ ์ MX_IWDG_Init()๊ฐ ๋๋ฌด ์ด๋ฅธ ์์น์ ๋ค์ ์ฝ์
๋ ์ ์๊ณ , ๊ทธ๋ ๊ฒ ๋๋ฉด POST๋ EEPROM ๋ก๋ฉ, W5500 ๋งํฌ ๋๊ธฐ ์ค watchdog reset์ผ๋ก boot loop๊ฐ ๋ฐ์ํ ์ ์๋ค๊ณ ์ ๋ฆฌ๋์ด ์์ต๋๋ค.
๋ฉ์ธ ๋ฃจํ์๋ ๋ ๊ฐ์ง ์ฃผ๊ธฐ๊ฐ ์์ต๋๋ค.
- 1์ด๋ง๋ค: ์๋ ์ฒ๋ฆฌ, ๋ ์ธ์ง ํ์ธ, dose EMA ์ฒ๋ฆฌ, USB ์ง๋จ ๋ก๊ทธ, ๊ทธ๋ฆฌ๊ณ 2์ด๋ง๋ค W5500 JSON ์ ์ก.
- 0.2์ด๋ง๋ค: watchdog refresh, W5500 socket polling, OLED ๊ฐฑ์ .
์ด ๊ตฌ์กฐ ๋๋ถ์ W5500 socket state machine์ timer ISR ์์ ๋ค์ด๊ฐ์ง ์์ต๋๋ค. ISR์ ์นด์ดํฐ ์ค๋ ์ท๊ณผ ํ๋๊ทธ ์ค์ ๋ง ํ๊ณ , ๋คํธ์ํฌ ์์ ์ ๋ฉ์ธ ๋ฃจํ๊ฐ ์ฒ๋ฆฌํฉ๋๋ค.
W5500 TCP ๋ก๊น ๊ณ์ธต
Ethernet ํตํฉ์ MyLib/W5500/ ์๋์ ๋ถ๋ฆฌ๋์ด ์์ต๋๋ค. ์ ํ๋ฆฌ์ผ์ด์
์ ์ฑ
๊ณผ ์นฉ ํฌํธ ์ธ๋ถ ๊ตฌํ์ ๋๋ ์ ์ด ์ข์ต๋๋ค.
w5500_port_ar22.c: W5500 CS=PA4, reset=PC4, SPI ์ ์ก์ STM32 HAL SPI1 ํธ์ถ๋ก ๋งคํํฉ๋๋ค.w5500_eth.c: ์นฉ ๋ฆฌ์ , ioLibrary callback ๋ฑ๋ก,VERSIONR == 0x04ํ์ธ, 8๊ฐ socket RX/TX ๋ฒํผ 2 KB ํ ๋น, static network ์ค์ , readback ๊ฒ์ฆ, PHY link polling์ ๋งก์ต๋๋ค.net_app.c: ์ ํ๋ฆฌ์ผ์ด์ socket์ ๋ด๋นํฉ๋๋ค. W5500 socket 0, TCP mode, port 15022์ ๋๋ค.
์์ฑ ๊ธฐ์ ๋ค์ด์ด๊ทธ๋จ: net_app_poll()์ด TCP socket์ ์ด๊ณ ์ ์งํ๋ฉฐ, net_app_send_dose()๊ฐ ํด๋ผ์ด์ธํธ ์ฐ๊ฒฐ ์ JSON ํ ์ค์ ์ ์กํฉ๋๋ค.
ํต์ฌ socket state machine์ WIZnet ioLibrary๋ฅผ ์จ๋ณธ ๋ ์์๊ฒ ์ต์ํ ํํ์ ๋๋ค.
case SOCK_CLOSED:
socket(NET_SOCK, Sn_MR_TCP, NET_PORT, 0);
break;
case SOCK_INIT:
listen(NET_SOCK);
break;
case SOCK_ESTABLISHED:
/* drain RX, ready to send JSON */
break;
case SOCK_CLOSE_WAIT:
disconnect(NET_SOCK);
break;
socket์ด ์ฐ๊ฒฐ๋๋ฉด net_app_send_dose(float dose_uSv)๊ฐ ํ์ฌ ๊ฐ์ newline-delimited JSON์ผ๋ก ํฌ๋งทํ๊ณ send()๋ฅผ ํธ์ถํฉ๋๋ค. 100 uSv/h ๋ฏธ๋ง์์๋ uSv/h, ๊ทธ ์ด์์์๋ mSv/h๋ก ๋ณํํฉ๋๋ค. ํด๋ผ์ด์ธํธ๊ฐ ์ฐ๊ฒฐ๋์ด ์์ง ์์ผ๋ฉด ํจ์๋ ๋ฐ๋ก ๋ฐํ๋ฉ๋๋ค.
โ๏ธ WIZnet ์นฉ์ ์ญํ
W5500์ ๊ฒ์ถ๊ธฐ์ ์ ์ telemetry ์ธํฐํ์ด์ค์ ๋๋ค. TCP/IP stack์ ํ๋์จ์ด์์ ์ฒ๋ฆฌํ๊ณ , STM32F446 ์ ํ๋ฆฌ์ผ์ด์ ์ ํ์ค ๊ณ์, ํํฐ๋ง, ํ์, ์๋, EEPROM, watchdog ๋์์ ์ง์คํฉ๋๋ค.
๋ฐฉ์ฌ์ ๋ชจ๋ํฐ๋ง ํ์จ์ด์์๋ ์ด ์ ํ์ด ์์ฐ์ค๋ฝ์ต๋๋ค. ๋ฉ์ธ ํ์จ์ด๊ฐ wireless reconnect, software TCP state, ํฐ network stack์ ์ง์ ๋ค๊ณ ์์ ํ์๊ฐ ์์ต๋๋ค. ์ด ํ๋ก์ ํธ๋ WIZnet ioLibrary API๋ก socket ํ๋๋ฅผ ์ด๊ณ , W5500์ด framing, checksum, TCP state๋ฅผ ๋งก๊ฒ ํฉ๋๋ค.
๊ตฌํ์ ์ ๊ฑฐํ๊ฑฐ๋ ์ด์ํ๊ธฐ๋ ์ฝ์ต๋๋ค. ETH_LOG_ENABLE์ด Ethernet ๊ธฐ๋ฅ ์ ์ฒด๋ฅผ compile time์์ ์ ์ดํ๊ณ , net_app.c๋ ์ ํ๋ฆฌ์ผ์ด์
๋ณ register ์ง์ ์กฐ์์ด ์๋๋ผ ํ์ค ioLibrary socket ํธ์ถ์ ์ฌ์ฉํฉ๋๋ค. ๋ค๋ฅธ WIZnet ์นฉ์ผ๋ก ์ฎ๊ธด๋ค๋ฉด dose-processing core๋ณด๋ค port/chip setup layer๋ฅผ ์ฃผ๋ก ๋ฐ๊พธ๋ฉด ๋ฉ๋๋ค.
์ ์ฉ ๊ฐ์น์ ํ๊ณ
AR22 LCU๋ W5500 ์์ ๋ก ๊ฐ์น๊ฐ ์์ต๋๋ค. ๋จ์ echo server๊ฐ ์๋๋ผ ์ค์ ๊ณ์ธก๊ธฐ ํ์จ์ด์ ๋ถ์ telemetry ์ฑ๋์ด๊ธฐ ๋๋ฌธ์ ๋๋ค. ์คํ์ค PC, ๋ฐ์ดํฐ ๋ก๊ฑฐ, bridge script๊ฐ telnet, netcat, Python socket์ผ๋ก ์ ์ํด์ ์ค์๊ฐ ์ ๋๋ฅ ์ ๊ธฐ๋กํ ์ ์์ต๋๋ค.
ํ๊ณ๋ ๋ถ๋ช ํฉ๋๋ค. ๊ณต๊ฐ ๋ ํฌ์๋ ํ๋ก๋, PCB, ์ธํด๋ก์ CAD, ์ค์ ํ๋์จ์ด ์ฌ์ง์ด ์์ต๋๋ค. ๋คํธ์ํฌ ์ค์ ์ static IP ์ ์ฉ์ด๊ณ , DHCP, TLS, ์ธ์ฆ, ๋ค์ค ํด๋ผ์ด์ธํธ ๊ตฌ์กฐ๋ ์์ต๋๋ค. ๊ฐ์ LAN์์ ํฌํธ 15022์ ์ ๊ทผ ๊ฐ๋ฅํ ์ฅ์น๋ ๋ฐ์ดํฐ๋ฅผ ๋ฐ์ ์ ์์ต๋๋ค. ํต์ ๋ ์คํ์ค LAN์๋ ์ ํฉํ์ง๋ง, ์ ๋ขฐํ ์ ์๋ ๋คํธ์ํฌ์ ์ง์ ๋ ธ์ถํ๋ฉด ์ ๋ฉ๋๋ค.
๋ ํ๋์ ์ ์ง๋ณด์ ํฌ์ธํธ๋ ๋ฌธ์ ๋ถ์ผ์น์
๋๋ค. ์ผ๋ถ overview ๋ฌธ์๋ ์๋ LOW/HIGH ํ์ด๋จธ ๋งคํ์ ์ค๋ช
ํ์ง๋ง, ํ์ฌ ISR๊ณผ .ioc๋ swap๋ ๋งคํ์ ์ฌ์ฉํฉ๋๋ค. ์ค์ ํตํฉ์ด๋ ๋๋ฒ๊น
์์๋ ์ฝ๋, .ioc, pin label์ ๊ธฐ์ค์ผ๋ก ๋ณด๋ ๊ฒ์ด ๋ง์ต๋๋ค.
๊ด๋ จ WIZnet Maker ํ๋ก์ ํธ
W5500 ๊ธฐ๋ฐ ์ ๋น์ฉ IoT ๊ฐ๋ง์ ๋ถ๊ด๊ธฐ๋ ๊ฐ์ฅ ๊ฐ๊น์ด ๋ฐฉ์ฌ์ ๋ถ์ผ ๋น๊ต ๋์์ ๋๋ค. STM32F407๊ณผ W5500 ๋ณด๋๋ฅผ ์ฌ์ฉํด scintillation detector์ gamma spectrum ๋ฐ์ดํฐ๋ฅผ PC๋ก ์ ์กํฉ๋๋ค. AR22 LCU๋ ์๋์ง spectrum์ด ์๋๋ผ GM tube dose rate๋ฅผ ๋ค๋ฃจ๊ณ , ๊ธฐ์กด ๊ณ์ธก๊ธฐ ํ์จ์ด์ W5500 logging channel์ ๋ถ๋ฆฌํด์ ๋ถ์ธ ์ ์ด ๋ค๋ฆ ๋๋ค.
Scintillation Monitor with Ethernet Interface๋ Ethernet์ ํฌํจํ ๋ ๋ค๋ฅธ ๋ฐฉ์ฌ์ ๋ชจ๋ํฐ๋ง ์์์ด๋ฉฐ KiCad hardware์ enclosure ์๋ฃ๊ฐ ์์ต๋๋ค. ๊ทธ ํ๋ก์ ํธ๊ฐ ๋ฌผ๋ฆฌ ์ค๊ณ ์๋ฃ์ ๊ฐํ๋ค๋ฉด, AR22 LCU๋ adaptive dual-range ์ฒ๋ฆฌ, EEPROM ์ค์ , watchdog startup ์ฃผ์, W5500 TCP server ๊ฐ์ ํ์จ์ด ๊น์ด์ ๊ฐ์ ์ด ์์ต๋๋ค.
STM32F4 FreeRTOS W5500 UDP ioLibrary ๋ ํผ๋ฐ์ค๋ ๊ตฌํ ๊ด์ ์์ ๊ฐ์ด ๋ณด๋ฉด ์ข์ต๋๋ค. ํด๋น ๊ธ์ STM32F4์ FreeRTOS์์ ioLibrary UDP server๋ฅผ ์ ๋ฆฌํ ๋ ํผ๋ฐ์ค์ด๊ณ , AR22 LCU๋ ๊ฐ์ WIZnet socket API ๊ณ์ด์ ์ฐ์ง๋ง TCP, no RTOS, ์ค์ ๊ฒ์ถ๊ธฐ ํ์จ์ด๋ผ๋ ๋งฅ๋ฝ์ด ๋ค๋ฆ ๋๋ค.
โ FAQ
AR22 LCU๋ W5500์ ์ด๋์ ์ฌ์ฉํ๋์? W5500์ ์ ์ TCP telemetry ์ธํฐํ์ด์ค์
๋๋ค. ํด๋ผ์ด์ธํธ๊ฐ 192.168.1.22:15022๋ก ์ ์ํ๋ฉด socket์ด ์ฐ๊ฒฐ๋ ๋์ 2์ด๋ง๋ค dose-rate JSON ํ ์ค์ ๋ฐ์ต๋๋ค.
W5500 ๊ฒฝ๋ก๊ฐ ๋ฐฉ์ฌ์ ์ธก์ ์๊ณ ๋ฆฌ์ฆ์ ์ผ๋ถ์ธ๊ฐ์? ์๋๋๋ค. ์ธก์ ์๊ณ ๋ฆฌ์ฆ์ STM32 ํ๋์จ์ด ํ์ด๋จธ์ ํ์จ์ด ๋ณ์์์ ๋์ํฉ๋๋ค. W5500 ๊ฒฝ๋ก๋ ํ์ฌ dose ๊ฐ์ ์ฝ์ด TCP ํด๋ผ์ด์ธํธ๋ก ๋ณด๋ด๋ ์ถ๋ ฅ ์ฑ๋์ ๋๋ค.
ํ์ฌ ์ฝ๋์์ LOW์ HIGH ํ์ด๋จธ ์
๋ ฅ์ ์ด๋ป๊ฒ ๋งคํ๋์ด ์๋์? ํ์ฌ ํ์จ์ด๋ LOW๋ฅผ PA0/TIM8, HIGH๋ฅผ PE7/TIM1์ ๋งคํํฉ๋๋ค. ์ผ๋ถ overview ๋ฌธ์๋ ์ค๋๋ ๋งคํ์ ๋ด๊ณ ์์ง๋ง, ISR, .ioc, pin label์ ํ์ฌ ๋งคํ์ ํ์ธํด ์ค๋๋ค.
Ethernet ๊ธฐ๋ฅ์ ๋น๋์์ ์ ๊ฑฐํ ์ ์๋์? ๋ค. ETH_LOG_ENABLE์ด W5500 ๊ธฐ๋ฅ์ compile time์์ ์ ์ดํฉ๋๋ค. 0์ผ๋ก ์ค์ ํ๋ฉด Ethernet include์ ํธ์ถ์ด ๋น๋์์ ๋น ์ง๋๋ค.
์ด ํ์จ์ด๋ฅผ ์ ๋ขฐํ ์ ์๋ ๋คํธ์ํฌ์ ๋ฐ๋ก ์ฐ๊ฒฐํด๋ ๋๋์? ์ ๋ฉ๋๋ค. fixed IP TCP server์ด๋ฉฐ TLS๋ ์ธ์ฆ์ด ์์ต๋๋ค. ๋ณ๋ ๋ณด์ ๊ณ์ธต์ด ์๋ค๋ฉด ํต์ ๋ LAN telemetry ์ฑ๋๋ก ๋ณด๋ ๊ฒ์ด ๋ง์ต๋๋ค.
Documents
-
AR22_v1_1 Source Code
STM32F446 AR22 LCU firmware with dual-range GM counting, SSD1322 OLED, EEPROM settings, and W5500 TCP dose logging.
-
AR22 LCU System Overview
Korean system overview covering measurement chain, display, alarm, EEPROM, and build flow.
-
AR22 GM Sensor Notes
Sensor and firmware consistency notes for LND 7128 and LND 71631 dual-range operation.
-
WIZnet W5500 Documentation
W5500 chip documentation and product information.
-
WIZnet ioLibrary Driver
Reference WIZnet socket API used by the bundled MyLib/W5500/ioLibrary code.