Modbus Slave in LabVIEW Overwrites Multiple Coils

Updated Sep 5, 2024

Reported In

Software

  • LabVIEW Datalogging and Supervisory Control Module

Issue Details

I'm trying to write multiple coils using Modbus on LabVIEW but I'm experiencing an unexpected behavior, my code is overwriting the subsequent coils, for instance: 
 

My Modbus Master sends a command to change 10 coils and provides 10 values for those. Our code will write those 10 values, but the next 6 coils will be set to false, no matter what they had in them before, overwriting the data when they're not apparently supposed to do that. The only way to avoid this is if the number of coils to be written is a multiple of 8.

Solution

This is a known bug regarding the Modbus API on LabVIEW for versions 2019 to the most recent one. The VI writes the entire payload instead of set coils based on the count in "Quantity of Outputs" so any number of coils set not multiple of 8 will write off the end overwriting remaining bits with 0s.
 

There are currently 2 workarounds for this situation:
 

  1. Write coil data from lowest address to highest address, and separate coils that aren't related by at least 8 addresses, so they don't interfere with each other.
  2. Replace the file located in the next path C:\Program Files (x86)\National Instruments\LabVIEW 202x\vi.lib\Modbus\subvis\Data and Functions\Standard Data Model\Modbus Functions\F15.vi with the VI attached to this KB.

Attachments