From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I write to Modbus I/O Server addresses without creating bound variables?

Solved!
Go to solution

Hi all,

 

I'm wondering if it's possible to use the Modbus I/O Server without explicitly creating bound variables?

 

  • If I write a value to the bound variable at "ni.var.psp://My Computer/Slave/300001", the master can see the value.
  • The variable properties paeg says that the variable is bound to "My Computer\Slave.lvlib\ModbusSlave1\300001"
  • I deleted the bound variable and tried a few different ways to write directly to the I/O Server, but all of them gave me Error 0x8BBB0005. I tried the following:
    • ni.var.psp://My Computer/Slave/300001
    • ni.var.psp://My Computer/Slave/ModbusSlave1/300001
    • ni.var.psp://My Computer/Slave.lvlib/ModbusSlave1/300001
    • ni.var.psp://My Computer/Slave.lvlib/ModbusSlave1/300001

I also tried replacing "My Computer" with "localhost" above. No luck.

 

Is there anything I've missed? I'm asking because CPU usage is very high, and I thought I might be able to reduce that a bit by removing the 300 bound variables in the system.

Certified LabVIEW Developer
0 Kudos
Message 1 of 6
(3,498 Views)

 You can use the modbus library to be a modbus master or slave. This does not use bound variable. You can add a comunication loop to your code. This gives you more control of the update rate and timeouts. You can down load the library http://www.ni.com/example/29756/en/

 

0 Kudos
Message 2 of 6
(3,471 Views)

Hi Dave,

 

Thanks for the recommendation. However, I'm hoping for an I/O Server based solution. At the moment, I don't actually know if I'll even benefit from getting rid of bound variables yet, so I don't want to rewrite my code yet.

 

If the bound variables are indeed the culprit for my high CPU usage, and if bound variables are the only way to use I/O Server, then I'll look at the low-level Modbus VIs.

Certified LabVIEW Developer
0 Kudos
Message 3 of 6
(3,459 Views)

I just noticed a typo in my original post. The paths I tried are:

 

  • ni.var.psp://My Computer/Slave/300001
  • ni.var.psp://My Computer/Slave/ModbusSlave1/300001
  • ni.var.psp://My Computer/Slave.lvlib/300001
  • ni.var.psp://My Computer/Slave.lvlib/ModbusSlave1/300001
Certified LabVIEW Developer
0 Kudos
Message 4 of 6
(3,457 Views)
Solution
Accepted by topic author JKSH

You can use DataSocket with a path like psp:\\localhost\Slave\ModbusSlave1.400001 for read and write access.

 

Check out the example VI "Monitor OPC Items with DataSocket.vi" in the LabVIEW examples.




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
Message 5 of 6
(3,446 Views)

Thanks Michael! That worked perfectly.

Certified LabVIEW Developer
0 Kudos
Message 6 of 6
(3,440 Views)