Siemens S7 1200 Modbus TCP to WebRelay

b.c.ninja

Member
Join Date
Oct 2016
Location
Dunedin
Posts
2
Hi Guys, bare with me on this one, so looking for someone to show me how to configure the Modbus Client within Siemens TIA portal for the following parameters.
Pretty much I am looking at communicating to a nice wee cheap Ethernet Relay via Modbus TCP and I'm flying blind, I've already had a wee play and done some research but everything is based around rather complex read/writes, I essentially just want to write to the WebRelay from the S7 PLC to tell it to turn the output on or off via Modbus TCP. The WebRelay has a built in Modbus Server so that side is covered.
Now I know it sounds like I want someone to do the job for me, well you're right, I'm half way there already but thought it would be easier to jump on here, have someone that knows what they're doing quickly show what needs put where and whammo I'll be away and will be able to reverse engineer and have all the planets align.

So here goes this is the info direct from the WebRelay manual, I have the IP address etc so that part isn't needed, so any help with pics would be grand.

3.4.3 Write Single Coil (Modbus Function Code 05 (0x05))
Request:
Modbus/TCP
Transaction identifier (2 Bytes): 0x0001
Protocol identifier (2 Bytes): 0x0000
Length (2 Bytes): 0x0006
Unit identifier (1 Byte): 0xff

Modbus
Function code (1 Byte): 0x05 (write coil)
Output address (2 Bytes): 0x0000
Output value (1 Byte): 0xff - turn relay on, 0x00 - turn relay off
Padding (1 Byte): 0x00
char write_coil_mb_request[] = {0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0xff, 0x05, 0x00, 0x00, 0xff,
0x00};

Response:

Modbus/TCP
Transaction identifier (2 Bytes): 0x0001
Protocol identifier (2 Bytes): 0x0000
Length(2 Bytes): 0x0006
Unit identifier (1 Byte): 0xff

Modbus
Function code (1 Byte): 0x05 (write coil)
Output address (2 Bytes): 0x0000
Output value (1 Byte): 0xff - relay on, 0x00 - relay off
Padding (1 Byte): 0x00

Modbus Error:
Function code (1 Byte): 0x85
Exception code (1 Byte): 0x01 or 0x02
Exception codes:
0x01 - Function code not supported
0x02 - Incorrect starting address / quantity of outputs combination
Character String Example:
char write_coil_mb_response[] = {0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0xff, 0x05, 0x00, 0x00,
0xff, 0x00 };

Cheers in advance.
 
Cheers for the reply, so currently I have nutted my way through most of it, the only bit I'm stuck on is

MB_DATA_ADDR

and

MB_DATA_PTR

along with the supplied info from the WebRelay

Output address (2 Bytes): 0x0000
Output value (1 Byte): 0xff - turn relay on, 0x00 - turn relay off
Padding (1 Byte): 0x00

Pretty much we currently have a PLC output controlling a relay that switches a 230V lighting control contactor, we are getting rid of the copper circuit and going with the ethernet relay so want to reference the current PLC output to switch the Ethernet Relay via Modbus.

So the MB_DATA_ADDR, is this the address of the SERVER therefore "Output address (2 Bytes): 0x0000" or is this an address in PLC Memory that I write to within the code to set the required bits to be outputted to the WebRelay,note that I'm using Modbus function 05.

Pretty much I understand that I have to write 0xff to turn on the WebRelay and 0x00 to turn it off, and have to write that to the WebRelay's memory location of 0x000, I just need to know how to achieve this with the Modbus_Client block,

Also the "Padding" is this done automatically within the Client block or do I need to biff that in as well somewhere, again any help would be awesome
 
MB_data_address = modbus memory area (0x0000)

MB_data_ptr = M or db-address range which has values to write (or readed data)

MB_block only needs

trigger bit for query
IP-address or slave numb
data area to read/write to/from slave
data area (data_ptr) where data is located on master side.


traditional relay is easier to setup and after all you still need copper wire (cat6) to ethernet relay
 

Similar Topics

I have 3 control panels made by an OEM, they are all identical and have a Siemens S7-1200 PLC with a Siemens CB-1241 Modbus card talking to 2...
Replies
8
Views
4,504
Hi All, I have a closed loop stepper motor (Nanotec make), https://en.nanotec.com/products/2512-pd4-e601l42-e-65-4. This uses MODBUS TCP for...
Replies
4
Views
3,821
Hello; i'm having some troubles with a com test i'm handling. i have another end for it, but for now i would like to have : M241 in io_scanning...
Replies
4
Views
3,477
Replies
3
Views
2,356
Hi all, I've hit a bit of a brick wall and need some help. I'm currently trying to get a Siemens S7-1200 PLC to talk to an Eaton DE1 Drive I'm...
Replies
8
Views
3,666
Back
Top Bottom