Panasonic MEWTOCOL
The MEWTOCOL module targets Panasonic FP-series PLC communication over MEWTOCOL-COM ASCII. It supports %NN# station frames, BCC checks, DT/LD/FL data registers, X/Y/R/L contact words, point acquisition, write-back by point name, and virtual PLC simulation.
Start with a Virtual PLC
var memory = new MewtocolSlaveMemory();
memory.DataRegisterWords[100] = 253;
memory.InternalRelayWords[10] = 0x0001;
await using var app = ZeusHost.Create(builder =>
{
builder.AddAcquisition(TimeSpan.FromMilliseconds(100));
builder.AddVirtualChannel("mewtocol", new MewtocolSlaveResponder(stationNumber: 1, memory));
builder.AddPanasonicMewtocol("plc", "mewtocol", new MewtocolOptions
{
StationNumber = 1
}, points: map => map
.DtWord("temperature", address: 100, scale: 0.1).Writable("temperature")
.RBit("running", wordAddress: 10, bitOffset: 0).Writable("running"));
});
await app.StartAsync();
var temperature = app.Points.Get<double>("temperature");
await app.Points.WriteAsync("temperature", 18.6);
| Code | Meaning |
|---|---|
MewtocolSlaveMemory | Virtual PLC image for DT/LD/FL registers and X/Y/R/L contact words |
MewtocolSlaveResponder(1, memory) | Simulates station 01 |
StationNumber = 1 | Two-digit station number in the MEWTOCOL frame |
.DtWord(..., 0.1) | DT100 raw word is scaled by 0.1; write-back reverses the scale |
Run sample: samples/Zeus.Samples.Console.Mewtocol.
Connect to a Real PLC
MEWTOCOL-COM is commonly used over serial or RS-485. Serial settings come from the PLC project:
await using var app = ZeusHost.Create(builder =>
{
builder.AddSerialPort("mewtocol", "COM3", 9600);
builder.AddPanasonicMewtocol("plc", "mewtocol", new MewtocolOptions
{
StationNumber = 1
});
});
If the site uses an Ethernet-to-serial gateway or TCP tunnel, use a TCP channel:
builder.AddTcpClient("mewtocol", "192.168.250.1", 9094);
builder.AddPanasonicMewtocol("plc", "mewtocol", new MewtocolOptions { StationNumber = 1 });
Read/Write API
var plc = app.Devices.Get<MewtocolDevice>("plc");
var dt = await plc.ReadDataRegistersAsync(100, 2);
await plc.WriteDataRegistersAsync(110, [10, 20, 30]);
var relays = await plc.ReadInternalRelayWordsAsync(10, 1);
await plc.WriteInternalRelayWordsAsync(10, [0x0001]);
Raw MEWTOCOL commands are also available:
string data = await plc.ExecuteAsync("RD", "D0010000101");
Memory Areas
| Area | Commands | Point helpers |
|---|---|---|
| DT data registers | RD / WD | .DtWord(...) / .DtBit(...) |
| LD link data registers | RD / WD | .LdWord(...) |
| FL file registers | RD / WD | .FlWord(...) |
| X external input words | RC | .XWord(...) / .XBit(...) |
| Y external output words | RC / WC | .YWord(...) / .YBit(...) |
| R internal relay words | RC / WC | .RWord(...) / .RBit(...) |
| L link relay words | RC / WC | .LWord(...) / .LBit(...) |
Bit points are written by reading the owning word, changing only the target bit, then writing the word back. X inputs are driven by the PLC, so JSON and the point map reject writable X points.
Points
builder.AddPanasonicMewtocol("plc", "mewtocol", new MewtocolOptions
{
StationNumber = 1,
WordOrder = MewtocolWordOrder.HighWordFirst
}, points: map => map
.DtWord("temperature", 100, 0.1).Writable("temperature")
.Int16("pressure", MewtocolDataArea.DataRegister, 120)
.Real("flow", MewtocolDataArea.DataRegister, 130)
.RBit("running", 10, 0).Writable("running"));
MEWTOCOL raw words are 16-bit. UInt32, Int32, and Real occupy two consecutive words; MewtocolOptions.WordOrder controls word order and defaults to high word first.
JSON Configuration
{
"channels": [
{
"name": "mewtocol",
"type": "serial",
"options": {
"portName": "COM3",
"baudRate": 9600
}
}
],
"devices": [
{
"name": "plc",
"channel": "mewtocol",
"type": "panasonic-mewtocol",
"options": {
"unitId": 1
},
"points": [
{
"name": "temperature",
"options": {
"area": "dt",
"address": 100,
"dataType": "word",
"scale": 0.1,
"writable": true
}
},
{
"name": "running",
"options": {
"area": "r",
"address": 10,
"bit": 0,
"dataType": "bit",
"writable": true
}
}
]
}
]
}
Virtual MEWTOCOL PLC:
{
"name": "mewtocol",
"type": "virtual",
"options": {
"responder": "mewtocol",
"unitId": 1
}
}
A ready-to-copy serial sample is at samples/Zeus.Samples.Console.Config/zeus-mewtocol.json.
Common Issues
| Symptom | Likely cause | Fix |
|---|---|---|
| Timeout | Station number, serial parameters, or TCP tunnel port is wrong | Test with MewtocolSlaveResponder, then check PLC settings |
| BCC failure | Baud/parity mismatch or the peer is not MEWTOCOL-COM ASCII | Verify serial settings and protocol mode |
| Error code returned | Memory area, address, or count unsupported | Inspect the MEWTOCOL error code and PLC manual |
| 32-bit word order is wrong | PLC project uses opposite word order | Change MewtocolOptions.WordOrder |
| Write-back did not run | Point is not writable, or the point is an X input | Mark the point writable; X inputs cannot be written |
Next: Points and Acquisition.