Skip to main content

Omron Host Link

The Host Link module targets Omron PLC ASCII Host Link communication. It supports @UU station frames, FCS checks, CIO/LR/HR/AR/DM word access, point acquisition, write-back by point name, and virtual PLC simulation.

Start with a Virtual PLC​

var memory = new HostLinkSlaveMemory();
memory.DataMemoryWords[100] = 253;
memory.CioWords[10] = 0x0001;

await using var app = ZeusHost.Create(builder =>
{
builder.AddAcquisition(TimeSpan.FromMilliseconds(100));
builder.AddVirtualChannel("host-link", new HostLinkSlaveResponder(unitNumber: 0, memory));
builder.AddOmronHostLink("plc", "host-link", new HostLinkOptions
{
UnitNumber = 0
}, points: map => map
.DmWord("temperature", address: 100, scale: 0.1).Writable("temperature")
.CioBit("running", address: 10, bitOffset: 0).Writable("running"));
});

await app.StartAsync();
var temperature = app.Points.Get<double>("temperature");
await app.Points.WriteAsync("temperature", 18.6);

Run sample: samples/Zeus.Samples.Console.HostLink.

Connect to a Real PLC​

Serial settings depend on the PLC project:

await using var app = ZeusHost.Create(builder =>
{
builder.AddSerialPort("host-link", "COM3", 9600);
builder.AddOmronHostLink("plc", "host-link", new HostLinkOptions
{
UnitNumber = 0
});
});

If the site uses an Ethernet-to-serial gateway or TCP tunnel, use a TCP channel:

builder.AddTcpClient("host-link", "192.168.250.1", 9600);
builder.AddOmronHostLink("plc", "host-link", new HostLinkOptions { UnitNumber = 0 });

Read/Write API​

var plc = app.Devices.Get<HostLinkDevice>("plc");

var dm = await plc.ReadDataMemoryWordsAsync(100, 2);
await plc.WriteDataMemoryWordsAsync(110, [10, 20, 30]);

var cio = await plc.ReadCioWordsAsync(10, 1);
await plc.WriteCioWordsAsync(10, [0x0001]);

Raw Host Link commands are also available:

string data = await plc.ExecuteAsync("RD", "01000002");

Memory Areas​

AreaRead commandWrite commandPoint helpers
CIO / IRRRWR.CioWord(...) / .CioBit(...)
LRRLWL.LinkWord(...) / .LinkBit(...)
HRRHWH.HoldingWord(...) / .HoldingBit(...)
ARRJWJ.AuxiliaryWord(...) / .AuxiliaryBit(...)
DMRDWD.DmWord(...) / .DmBit(...)

Bit points are written by reading the owning word, changing only the target bit, then writing the word back.

Points​

builder.AddOmronHostLink("plc", "host-link", new HostLinkOptions
{
UnitNumber = 0,
WordOrder = HostLinkWordOrder.HighWordFirst
}, points: map => map
.DmWord("temperature", 100, 0.1).Writable("temperature")
.Int16("pressure", HostLinkArea.DataMemory, 120)
.Real("flow", HostLinkArea.DataMemory, 130)
.CioBit("running", 10, 0).Writable("running"));

Host Link raw words are 16-bit. UInt32, Int32, and Real occupy two consecutive words; HostLinkOptions.WordOrder controls word order.

JSON Configuration​

{
"channels": [
{
"name": "host-link",
"type": "serial",
"options": {
"portName": "COM3",
"baudRate": 9600
}
}
],
"devices": [
{
"name": "plc",
"channel": "host-link",
"type": "omron-host-link",
"options": {
"unitId": 0
},
"points": [
{
"name": "temperature",
"options": {
"area": "dm",
"address": 100,
"dataType": "word",
"scale": 0.1,
"writable": true
}
},
{
"name": "running",
"options": {
"area": "cio",
"address": 10,
"bit": 0,
"dataType": "bit",
"writable": true
}
}
]
}
]
}

Virtual Host Link PLC:

{
"name": "host-link",
"type": "virtual",
"options": {
"responder": "host-link",
"unitId": 0
}
}

Common Issues​

SymptomLikely causeFix
TimeoutUnit number, serial parameters, or TCP tunnel port is wrongTest with HostLinkSlaveResponder, then check PLC settings
FCS failureBaud/parity mismatch or the peer is not Host Link ASCIIVerify serial settings and protocol mode
End code returnedMemory area, address, or count unsupportedInspect HostLinkException.EndCode and PLC manual
32-bit word order is wrongPLC project uses opposite word orderChange HostLinkOptions.WordOrder

Next: Points and Acquisition.