LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Send Multiple Modbus Commands using NI-VISA write at the same time.

Solved!
Go to solution

Hi, I'm trying to send 2 commands at once and graph their responses on different plots. The method of communication is Modbus serial. I tried the same plot, but couldn't figure it out. But, I am having a an issue with sending and receiving the responses from the sensor at the same time. However, my second VISA Write-Read combinaiton fails to complete. Any help would be greatly appreciated.

0 Kudos
Message 1 of 19
(1,937 Views)

Don't try to reinvent the wheel, there is a free and full featured Modbus library available for LabVEW 

 

I have used this library in a few applications and found it straight forward and well supported in the forum I linked to.

========================
=== Engineer Ambiguously ===
========================
Message 2 of 19
(1,894 Views)

I have installed the Package previously, but I am a confused is it supposed to replace all the VISA Writes and Reads in my Block diagram?

0 Kudos
Message 3 of 19
(1,873 Views)

Yes.  Because the needed VISA Writes and Reads are in the VI's of the library, along with all the other code to structure the command messages and interpret the responses from the device.

Message 4 of 19
(1,869 Views)

Yes it replaces VISA, I believe actually it uses VISA inside but that's kind of the point of the library. As it abstracts out all the "hairy details' of Modbus an boils it down to reading and writing registers and coils. You will still have to know exactly what register(s) to read and how to convert the returned data. 

========================
=== Engineer Ambiguously ===
========================
Message 5 of 19
(1,866 Views)

Trying to execute requests in parallel over serial could potentially cause additional problems if the read operations happen in the opposite order of your write actions. As an example, there's nothing stopping your Gas PPM request to happen before your Temperature request but then have the Temperature read happen before the Gas PPM read.

 

The Modbus library that was linked has a mutex around the critical VISA read/write section to avoid that problem.

Matt J | National Instruments | CLA
Message 6 of 19
(1,841 Views)

So, should I even be configuring my serial port using VISA Configure cause I'm not sure what it is supposed to connect to anymore? Also, do I need both Master and Slave Versions of the Read/Write VIs? Can I just use Modbus Read Multiple holding registers to read the value stored there or does the basic structure of command and response apply whether it is VISA or Modbus?

0 Kudos
Message 7 of 19
(1,826 Views)

I will try to give you a couple tips here... but later, after work< I might be able to answer more detailed questions.

 

First, study the manual of your device thoroughly as you will need to know what register(s) to read and how to scale the returned values.

 

  1. Use New Serial Master  to open the com port not VISA serial setup
  2. Yes, as I said before all the hairy details of Modbus communications are hidden beneath the Modbus library abstraction layer. So requesting a register value is as simple as using the Read Holding Registers vi.
  3. If you need to read multiple holding registers read them all in sequence at the same time.

 

 

 

 

 

 

========================
=== Engineer Ambiguously ===
========================
Message 8 of 19
(1,817 Views)

Hi RTSLVU,

 

Thank you for your help. I've just realized that I have been working away at an issue from base camp when people have already built a helicoter that could take me halfway up the mountain lol. I'm looking at example codes online (which can be a risky proposition as I've learned from the past), but if my understanding is correct my current code would be from the perspective of the client (master)

0 Kudos
Message 9 of 19
(1,787 Views)

@vanceblake wrote:

Hi RTSLVU,

 

Thank you for your help. I've just realized that I have been working away at an issue from base camp when people have already built a helicoter that could take me halfway up the mountain lol. I'm looking at example codes online (which can be a risky proposition as I've learned from the past), but if my understanding is correct my current code would be from the perspective of the client (master)


But to further that analogy, you learn a lot more by getting yourself halfway up the mountain than if you took the helicopter!

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 19
(1,779 Views)