Adress Twincat nModbus

139 views
Skip to first unread message

Benoît Lefebvre

unread,
Jul 19, 2016, 9:29:47 AM7/19/16
to NModbus
Hello everyone,

I have a small address translation worries.
I have a Beckhoff BC9000 controller card with a KL2114 (4 Digital Output), I have a Twincat System Manager solution and a PLC code. So far all is well.
I want to activate the DO via a C # program.
Currently I use the dll Twincat.Ads.dll with it I can "write" and activate my DO.
I would do the same but in ModBus.

Here is some code
MyObjectTwinCat = new TcAdsClient();
MyObjectTwinCat.Connect (Server, Port);
...
AdsStream ds = new AdsStream (1);
BinaryWriter bw = new BinaryWriter (ds);
ds.Position = 0;
MyObjectTwinCat.Write (0xF031, 0x20, ds);

What I do not find is the corresponding addresses and offsets in ModBus, in this case: 0xF031 and 0x20 and the Write method ...
MyObjectModBus.Write ... (address + offset, True);
Write with ... = WriteSingleRegister or WriteMultipleCoils or WriteMultipleRegisters or WriteSingleCoil?

I hope I was clear in my explanations.

In advance thank you very much for your help

Benoît

MiguelS

unread,
Jul 20, 2016, 10:01:22 AM7/20/16
to NModbus

ModbusTCP Process Image

The ModbusTCP process image makes a fundamental distinction between digital and byte-oriented or word-oriented signals (Bus Terminals). Additionally, a distinction is made between inputs and outputs. The mapping table shows which Bus Terminals belong to which mapping.

Digital inputs Digital outputs
Offset 0 ... 4095
Modbus function
Reading 2
Writing: -
Offset 0 ... 4095
Modbus function
Reading 1
Writing 5, 15

 

Analog/digital inputs Analog/digital outputs
Offset 0x000 ... 0x0FF
Modbus function
Reading 3, 23
Writing: -
Offset 0x800 ... 0x8FF
Modbus function
Reading 3, 4, 23
Writing 6, 16, 23

This will be clarified by examples.

Example 1

BK9000
4 x KL1xx4
2 x KL2xx2
1 x KL9010

Inputs

Outputs

Modbus function Modbus address/offset Bus Terminal Modbus function Modbus address/offset Bus Terminal
3 read 0x0000 4 x KL1xx4 3 read 0x0800 2 x KL2xx2
4 read 0x0000 1 read 0x0000
2 read 0x0000 - 0x000F 5 write 0x0000-0x0003
      15 write 0x0000-0x0003
      6 write 0x800
      16 write 0x800
      23 write 0x800
Example 2

BK9000
4 x KL1xx4
2 x KL2xx2
1 x KL1501
1 x KL3xx2
1 x KL4xx2
1 x KL9010

Inputs

Outputs

Modbus function Modbus address/offset Bus Terminal Modbus function Modbus address/offset Bus Terminal
3, 4 read 0x0000..0002 KL1501 3 read 0x0800..0802 KL1501
    6, 16 write 0x0800..0802
3, 4 read 0x0003..0x0006 KL3xx2 3 read 0x0803..0x0806 KL3xx2
    6, 16 write 0x0803..0x0806
3, 4 read 0x0007..0x000A KL4xx2 3 read 0x0807..0x080A KL4xx2
    6, 16 write 0x0807..0x080A
 
3 read 0x000B 4 x KL1xx4 3 read 0x080B 2 x KL2xx2
4 read 0x080B
4 read 0x000B 1 read 0x0000-0x0003
2 read 0x0000 - 0x000F 5 write 0x0000-0x0003
15 write 0x0000-0x0003
6 write 0x80B
16 write 0x80B
23 write 0x80B

Benoît Lefebvre

unread,
Jul 25, 2016, 7:30:43 AM7/25/16
to NModbus
Hello , thank you for your reply and sorry for the delay , I was on leave.
You talk to me much of the Modbus protocol , but I try to use the <Nmodbus> project and I do not know what function used: "Write with ... = WriteSingleRegister or  WriteMultipleCoils or WriteMultipleRegisters or WriteSingleCoil ? " and at what offset .
I would activate an output on a KL2xx2 (or 4)
Again thank you to you and sorry for my english
Benoît
Reply all
Reply to author
Forward
0 new messages