Skip to main content

FATEK FBs Driver

Overview

ASCII communication for FATEK FACON FBs series PLCs. Custom implementation based on the public specification in the FBs Series Communication Protocol Manual. No dependency on external libraries or GitHub code.

ItemValue
opc_typeFATEK
Implementation classplantpulse.driver.protocol.fatek.FatekDriver
Library(none — custom implementation. FATEK FBs manual)
readGood (cmd 44 / 46)
writeGood (cmd 45 / 47)
Default port500
SecurityNone

Classes / Structure

FatekDriver (BaseProtocolDriver)
├── Socket / InputStream / OutputStream
├── station — 0~255 (디폴트 1)
├── synchronized read/write
├── Addr (device, index, bit)
├── parseAddress(raw) — R/D/M/X/Y/T/C/WX/WY/WM
├── formatBitItem / formatWordItem
└── sendAndReceive(cmd, body) — STX/ETX/LRC 검증

Immediately after connect(), cmd 41 (status) is called as a hello, but the connection is maintained even if it fails (the PLC may not support it).


Wire Format Summary

Request : STX <station 2hex> <cmd 2hex> <data ASCII> <LRC 2hex> ETX
Response: STX <station 2hex> <cmd 2hex> <error-1char> <data> <LRC 2hex> ETX
STX = 0x02, ETX = 0x03
LRC : STX 다음부터 LRC 직전까지 XOR (ASCII char 단위) → 2자리 hex 대문자

Main Commands

cmdAction
40Read system status
41Get PLC run/stop/error/break status (for hello)
42Run/Stop PLC
44Read data from registers (consecutive words)
45Write data to registers (consecutive words)
46Read individual data (single bit / mixed)
47Write individual data

In sendAndReceive(), if the response error code is not '0', then IOException (e.g. '2' illegal value, '4' illegal command, '5' checksum, '6' illegal address, 'A' PLC password locked).


OPC Registration Options (options)

KeyMeaningDefault
stationPLC station ID (0–255)1
connect-timeoutms3000
read-timeoutms3000

Tag Address Format

NotationMeaningbit/word
R0 / R100General registerword
D100Data registerword
WX10 / WY0 / WM10Input/Output/Internal wordword
M100Internal relaybit
X0 / Y0 / S0Input / Output / Stepbit
T0 / C0Timer / Counter present valueword (RT/RC notation of cmd 44)

formatWordItem() :

  • R/D → <dev>+5자 index (6 characters total)
  • WX/WY/WM → <dev>+4자 (6 characters total)
  • T → RT + 4 characters, C → RC + 4 characters

Data Encoding / Decoding

wordCountFor(dt, fmt) determines 1/2/4 words. decodeWords() performs the conversion — FATEK FB multi-word values use little-endian word order (low word first).

format / data_typeWord countNotes
W / WORD / UI / UW1signed/unsigned 16
B / BYTE1(16-bit response as-is)
DW / DWORD / Int322signed 32
UDW / UInt322unsigned 32
REAL / FLOAT / Float2IEEE 32-bit
LREAL / DOUBLE / Double4IEEE 64-bit
LW / LWORD / Int644signed 64

Supported / Not Supported

  • ✅ cmd 44 / 45 (consecutive read/write of N words)
  • ✅ cmd 46 / 47 (single-bit read/write)
  • ✅ STX/ETX/LRC frame validation + station/cmd echo validation
  • ✅ 32 / 64-bit multi-word, Float, Double
  • ❌ Simultaneous read/write of multiple bits (mixed items of cmd 46/47)
  • ❌ Run/Stop PLC (cmd 42)
  • ❌ Separate Timer/Counter contact bits (currently word only)

Test Coverage

test/java/plantpulse/driver/protocol/fatek/

ClassTest count
FatekDriverTest48

48 tests total — LRC, buildRequest, address parser, word encode/decode, error codes.


References

  • FATEK FBs Series Communication Protocol Manual (vendor public)
  • Code: src/plantpulse/driver/protocol/fatek/FatekDriver.java