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.
| Item | Value |
|---|---|
opc_type | FATEK |
| Implementation class | plantpulse.driver.protocol.fatek.FatekDriver |
| Library | (none — custom implementation. FATEK FBs manual) |
| read | Good (cmd 44 / 46) |
| write | Good (cmd 45 / 47) |
| Default port | 500 |
| Security | None |
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
| cmd | Action |
|---|---|
40 | Read system status |
41 | Get PLC run/stop/error/break status (for hello) |
42 | Run/Stop PLC |
44 | Read data from registers (consecutive words) |
45 | Write data to registers (consecutive words) |
46 | Read individual data (single bit / mixed) |
47 | Write 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)
| Key | Meaning | Default |
|---|---|---|
station | PLC station ID (0–255) | 1 |
connect-timeout | ms | 3000 |
read-timeout | ms | 3000 |
Tag Address Format
| Notation | Meaning | bit/word |
|---|---|---|
R0 / R100 | General register | word |
D100 | Data register | word |
WX10 / WY0 / WM10 | Input/Output/Internal word | word |
M100 | Internal relay | bit |
X0 / Y0 / S0 | Input / Output / Step | bit |
T0 / C0 | Timer / Counter present value | word (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_type | Word count | Notes |
|---|---|---|
W / WORD / UI / UW | 1 | signed/unsigned 16 |
B / BYTE | 1 | (16-bit response as-is) |
DW / DWORD / Int32 | 2 | signed 32 |
UDW / UInt32 | 2 | unsigned 32 |
REAL / FLOAT / Float | 2 | IEEE 32-bit |
LREAL / DOUBLE / Double | 4 | IEEE 64-bit |
LW / LWORD / Int64 | 4 | signed 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/
| Class | Test count |
|---|---|
FatekDriverTest | 48 |
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