How to Bit write with Modbus v2?

I use the Modbus v2 driver, and in the manual there is no explication how to write to a single bit in a holding register in the PLC (Modicon compact A984-130).

Sorry, the user manual section is still talking about Modbus-v1.

To address a bit you create a SQLTag and in the OPC Item Path append a “.” and then the bit number you want to the normal address, for example:

[my_modbus_device]HR1.3

Would address Holding Register 1, bit 3 on the device you have configured named “my_modbus_device”. You can also copy/paste/modify tags you’ve already dragged in from browsing (which are only available if you created an address map). You can then read and write to that SQLTag like normal.

Reading should work on any device, but writing requires that the device supports the MaskWriteRegister Modbus function code.

@Kevin,

Reading a bit, that works fine, but write to a bit in the plc will not work.
I have the following error message :
[color=#FF0000]
Error writing “1” to tag V41201-V41260/V41215_10 StatusCode[Severity=Bad, Subcode=NotSpecified, 0x80
[/color]

Any idea ?

If you look in your logs on the Ignition gateway, under Configure > Console > Logs tab, you will probably see an error message that says “Received response with ExceptionCode: IllegalFunction”.

If this is the case then your device does not support the MaskWriteRegister function code and you will not be able to write to individual bits atomically.

A work-around is to create some global scripting functions that read the value and perform some bit twiddling before writing the value back down, but this is not 100% safe because there’s no guarantee the value won’t change in the mean-time and you end up writing down a value that clobbers the change.

This is the error that I found in the system console:

[color=#FF0000]
0:21:47 SQLTags.TagProviders.Provider[default] [[default]V41201-V41260/V41215_10] Error writing to OPC address [[Ignition OPC-UA Server][PLC22]22.HR1215.10]. Result code: StatusCode[Severity=Bad, Subcode=NotSpecified, 0x80000000]
0:21:47 ModbusDriver2.PLC22.MaskWriteRegisterRequest Error reading response at field “Register Values”. Buffer=[15 EB 00 00 00 03 16 96 01 ].
[/color]

I’m guessing you’re using a version prior to beta5, which did not give as helpful of error messages, but what you’re seeing is indeed the device responding with an IllegalFunction ExceptionCode, meaning MaskWriteRegister requests are not supported.

Thanks Kevin,

I use Ignition version 7.2.7 (b170). The Modbus v2 is version 2.2.0 (b0).
The PLC is a Modicon 984-130, the communication go’s over Ethernet via a Modbus to Ethernet bridge (174 CEV 300 10). I thought that with this combination it must be possible to write to individual bits in a holding register. But it’s not so.
For write to a bit I will use the specific script for it. Somewhere on this forum I read about it.

You should definitely upgrade your Modbus v2 driver to the latest version. It’s available on the development downloads page: inductiveautomation.com/down … evelopment

I did the update for ignition and Modbus v2. Now I can not configure a device because there is no driver module from modbus to find. I see Siemens, Allen Bradley, … etc but no Modbus.
Please help.

Tank you.

Uh-oh. There shouldn’t be any problems using Modbus v2 beta 5 on a 7.2.7 gateway. Can you find your wrapper.log file(s) and email them to support@inductiveautomation.com? On a default install they can be found in C:\Program Files\Inductive Automation\Ignition.

One thing you might try in the mean-time:

  1. Shut down Ignition
  2. Open the modules folder. On a default install, this is C:\Program Files\Inductive Automation\Ignition\contexts\main\modules
  3. Delete any Modbus modules you find there.
  4. Place the new Modbus-v2 .modl file you downloaded here.
  5. Start Ignition.

There were some compatibility issues between the earlier and later betas that may be causing the problem.