# Modbus driver doesn't seem to properly optimize write multiple registers

**URL:** <https://forum.inductiveautomation.com/t/modbus-driver-doesnt-seem-to-properly-optimize-write-multiple-registers/14853>\
**Category:** Ignition\
**Created:** [July 21, 2017, 11:21am UTC](https://forum.inductiveautomation.com/t/modbus-driver-doesnt-seem-to-properly-optimize-write-multiple-registers/14853 "2017-07-21T11:21:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cgz](https://avatars.discourse-cdn.com/v4/letter/c/8dc957/32.png) [@cgz](https://forum.inductiveautomation.com/u/cgz)\
**Post date:** [July 21, 2017, 11:21am UTC](https://forum.inductiveautomation.com/t/modbus-driver-doesnt-seem-to-properly-optimize-write-multiple-registers/14853/1 "2017-07-21T11:21:22Z")

</div>

Hi!

I’m facing a problem with Modbus. I’m trying to write 120 holding registers in one request, but for some reason, Ignition seems to split them into 60 two-register requests. The functionality of the device I’m trying to access, requires a 120-register bulk write.

How do I make the bulk write work?

If absolutely necessary, I could modify the Modbus driver, assuming the SDK has got the current driver, and modifying it would actually help.

Details:

- I’m using the “system.opc.writeValues()” script function
  - The registers input to the writeValues() function are in an ascending numeric order.

- The device’s been configured as follows:
  - Allow Write Multiple Registers Request: ENABLED
  - Max Holding Registers Per Request: 125
  - Span Gaps: ENABLED
  - Force Multiple Register Writes: tried both
  - One-based Addressing: DISABLED

- Modbus Driver v2 3.7.5 (b2015071516)
- OPC-UA 2.7.5 (b2015071516)
- Ignition Gateway 7.7.5 (b2015071516)

Thanks!

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 21, 2017, 1:11pm UTC](https://forum.inductiveautomation.com/t/modbus-driver-doesnt-seem-to-properly-optimize-write-multiple-registers/14853/2 "2017-07-21T13:11:42Z")

</div>

Do the registers span a contiguous address range?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 21, 2017, 3:01pm UTC](https://forum.inductiveautomation.com/t/modbus-driver-doesnt-seem-to-properly-optimize-write-multiple-registers/14853/3 "2017-07-21T15:01:01Z")

</div>

It looks like we fixed a bug back in version 7.8.3 that, from the description in the tracker, sounds like what you’re experiencing.

Can you upgrade to 7.8.x or 7.9.x?

---

<div class="post-metadata">

**Author:** ![cgz](https://avatars.discourse-cdn.com/v4/letter/c/8dc957/32.png) [@cgz](https://forum.inductiveautomation.com/u/cgz)\
**Post date:** [July 21, 2017, 10:02pm UTC](https://forum.inductiveautomation.com/t/modbus-driver-doesnt-seem-to-properly-optimize-write-multiple-registers/14853/4 "2017-07-21T22:02:28Z")

</div>

Yes, they’re contiguous.

---

<div class="post-metadata">

**Author:** ![cgz](https://avatars.discourse-cdn.com/v4/letter/c/8dc957/32.png) [@cgz](https://forum.inductiveautomation.com/u/cgz)\
**Post date:** [July 21, 2017, 10:04pm UTC](https://forum.inductiveautomation.com/t/modbus-driver-doesnt-seem-to-properly-optimize-write-multiple-registers/14853/5 "2017-07-21T22:04:40Z")

</div>

I need to check with my customer if they’re able to upgrade without too much hassle. What other options might I have? Perhaps just upgrading the Modbus driver (assuming the driver’s the problem)?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 21, 2017, 10:17pm UTC](https://forum.inductiveautomation.com/t/modbus-driver-doesnt-seem-to-properly-optimize-write-multiple-registers/14853/6 "2017-07-21T22:17:01Z")

</div>

There’s not much else that can be done besides upgrading. A module from the 7.8.x series won’t install on a 7.7.x gateway.

If this block write is not a common theme maybe you can just open a socket and write the necessary Modbus command + payload manually.

---

<div class="post-metadata">

**Author:** ![cgz](https://avatars.discourse-cdn.com/v4/letter/c/8dc957/32.png) [@cgz](https://forum.inductiveautomation.com/u/cgz)\
**Post date:** [July 21, 2017, 11:37pm UTC](https://forum.inductiveautomation.com/t/modbus-driver-doesnt-seem-to-properly-optimize-write-multiple-registers/14853/7 "2017-07-21T23:37:18Z")

</div>

I was able to test the current gateway version (7.9.3), and the bulk write now works correctly, thanks!

I hope the production environment will be reasonably upgradeable as well 🔨
