Address configuration for s7 1200 as OPC device

Hello,
I am trying to set up Ignition to communicate with an S7 1200 by Modbus and having trouble with the booleans. The Holding registers work the way I expect but I can't figure out how to set the Modbus Address for the coils. If I set them both to 1 I would expect them to conflict but they don't. The Coils are being set somewhere in the PLC but I can't figure out where.

I expect the Coil values from the Quick Client to be in the Coils array of the TIA table, but they don't show up there

But if I change the values of the Coils in the Quick Client they change somewhere

I am trying to use modbus with both holding registers and coils but it seems like only the holding registers work, does anyone know if its possible to have both holding registers and coil registers in the same modbus block?

Lets start at the start of your post. I would title the post "Address configuration of S7-1200 as Modbus device" it will get more responses from people quickly scanning the topics.
Next, I would suggest to never use the "Address Configuration" section of the modbus driver, and instead use the Modbus Addressing | Ignition User Manual system. This system is much easier to use and to troubleshoot.
Make your tags in the tag browser on ignition, use these examples as the OPC Path:
Holding Register - ns=1;s=[Test Stand - S7 1200 Mdbs]1.HRF2
Coil - ns=1;s=[Test Stand - S7 1200 Mdbs]1.C1
Then lets see what the tags show as in the tag browser.

1 Like

Hi David,
Thanks for the response. I have tried using modbus addressing in the OPC Item Path. It works for the Real numbers, so HRF2 returns 179.77, as I expect.
The problem is that the Booleans in TIA are not affected by commands like
ns=1;s=[Test Stand - S7 1200 Mdbs]1.C1
It just doesn't do anything. In Ignition it appears the bit is being toggled somewhere, and I can see it toggling in the Quick Client but nothing in tia changes in the Booleans section. If I manually change the booleans in TIA, again nothing happens in Ignition. I can read bits in Ignition from TIA if I use commands like HRF1.0 will read in Ignition if I manually toggle bits in TIA but if I try to write the bit in Ignition it says the bit is Read Only.


The reason I tried the "Address Configuration" Feature was because addressing in the tag isn't working.

Are you sure TIA supports Modbus coil addresses? Instead of mapping booleans into holding registers?

Hi pturmel,
I am not sure that TIA supports coils except that in the documentation it says it can. Here is a screenshot.


One difference is that the Ignition documents say that TIA uses X instead of C for bits like MX0.1 (Or IX0.1, or similar) should work to toggle the bit I am after, but it doesn't.
I am looking for an example of someone that has used booleans and reals(or whatever) with TIA portal. The examples in the documentation don't work.

Here, you're mixing up the Siemens driver with the Modbus driver. If you want to use the Siemens driver, you'll use that format, but when using Modbus, you have to stick with the Modbus format. You can't mix the two different formats.

1 Like

Hi Michael,
Thanks for the response. I don't know what that means. I thought it was the Siemens Modbus driver? What command should I use in Ignition to control the bit at offset 1.0 in TIA?

Siemens native format is not Modbus. When using the native format, you would not have a Modbus Server block in your code.

If you do want to use Modbus, then only the Siemens addresses that are deliberately exposed through the MB Server instructions will actually be usable. Siemens addresses that start with "I" are fundamentally read-only externally, no matter what else you do. (And it wouldn't be called "Siemens Modbus". It's just "Modbus".)

1 Like

pturmel, Thanks for the reply. I think I am exposing the addresses in DB5 called Modbus.

I set up the MB_SERVER block like this

It seems like '[Test Stand - S7 1200 Mdbs]1.C1' should work, or just '[Test Stand - S7 1200 Mdbs]C1' and it from Ignition it looks like they do but I can't see any changes in TIA, I don't know where the C values are changing, I expect them to change bewteen offsets 0 and 1.7 in the Modbus DB from the way the MB_SERVER block is set up, but they don't.
With the way I have the MB_SERVER block set up and the Modbus DB what command should I use to control bit at offset 1.0?

Have you tried HR1.0, HR1.1, etc...?

The word "coil" doesn't appear a single time in the documentation for these Modbus function blocks from what I can see.

1 Like

Hi Kevin, Thanks for the reply. I have tried that, I can read the value at offset 1.0 with HR1.0 but when I try to write to it I get an error

If you change the bit in the PLC does it reflect on the Ignition side?

Is there an error in the Ignition logs when you try to write to that bit? Writing to a bit within a register requires that the Modbus slave/server supports function code 0x16 Mask Write Register.

Kevin,
Yes, if the bit changes in the PLC it is shown correctly in Ignition, but can't write from Ignition to PLC.
Yes, there is an error


Maybe the 1200 doesn't support the function, as you noted. It seems like there should be a way to control bits... I can imagine a script to write bits of a word or something, but that sounds more complicated than it should be.

This is pretty much what you need to do. Create a new word that represents the bits you want set or not set, then write the whole register.

Or... stop using the Modbus driver and start using the Siemens S7 driver or a direct OPC UA connection? I hope you're only doing this with Modbus as an exercise.

Or... stop using the Modbus driver and start using the Siemens S7 driver or a direct OPC UA connection? I hope you're only doing this with Modbus as an exercise.

When activating OPC in TIA portal the IDE crashes, the fix apparently is to get a 1500, in a few months. Using modbus was supposed to be a quick way to get around the OPC problem. Writing to a word still seems faster than waiting for a 1500, but more than seems necessary. Must be a Siemens thing.

Thanks for your help!

Kevin,

Maybe you can answer a question? If using the Siemens device driver, what would be the syntax for something like [Test Stand - S7 1200 Mdbs]C1, or is that it? I still don't understand the difference between modbus and siemens driver for the syntax.
Also, do you know of a way to set up using bits in the addressing feature?

The Siemens address syntax is described here: Siemens | Ignition User Manual

In this case the bit addresses might be something like DB5,X0.0, DB5,X0.1.

1 Like

I have tried that syntax and get an error
image

I'm not having much luck with this PLC, usually this is easy.

Is your tag configured as Read Only?

Did you call it "OpcItemPath" or is there something else goofy going on here? How are you trying to write to it?

Modbus and the native Siemens driver are 2 completely different protocols. It's like trying to talk Spanish to someone who only talks English. You have to use the correct syntax for the correct driver/protocol.