LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to select Modbus Registers?

Solved!
Go to solution

I’m a newbie to Modbus and I need to develop a cRIO controller to act as a Modbus Slave via TCP.  I’ve successfully completed the NI tutorial titled How to turn a RT Target into a Modbus Slave using IO Servers.  However, I don’t understand which registers to use.  I have a number of I32 and u16 represented values that need to be sent via Modbus.  From what I gather, I will need to use the 300001-399999 range of Analog Input Registers.  (Data will always be read from the cRIO controller and never written to it.)  On step 6 of the tutorial there is a long list of registers and it’s not clear which ones to use.

I thought to use the SD300001 range for the I32 values and the 300001 range for the U16 values.  However, they seem to affect each other when I view the results using NI Distributed System Manager.  For example, changing the value for SD300002 will also affect the value for SD300001; as if they are doubled registers.

 What is the relationship between SD30001 and 300001?  Should I only use the 300001-399999 range and double them for the I32 number?

To rephrase the question, how should I present I32 and U16 represented values for the end-user to read via Modbus?

I’m currently using Win-7 and LV 2009 with SP1, NI-RIO v3.4.0 and Modus I/O Server v.1.6.1.

Thanks,

Dave
0 Kudos
Message 1 of 7
(4,546 Views)

Hi Dave,

 

One important thing to keep in mind is that every modbus register contains 16 bits of data.  If you are trying to represent a 32-bit number, it will take up 2 registers.  Therefore an I32 on SD300001 will actually take up registers SD300001 and SD300002.  To avoid the problems, simply use every other register if you are using 32 bit data. 

 

Hope this helps. 

0 Kudos
Message 2 of 7
(4,523 Views)
Solution
Accepted by topic author dj143

The following KB goes into more detail.  It references Lookout specifically, but it is the same concept with any Modbus server...

 

http://digital.ni.com/public.nsf/allkb/4EF459F549FCC7028625660A000A7629?OpenDocument  

Message 3 of 7
(4,521 Views)

Hi David,

I was able to get this working.  It was actually quite simple with the only hurdle of remembering to double the registers.  This was reminiscent of programming PLC’s.   Be the way, we haven’t programmed a PLC since around 2005.  At that point we converted to cFP and a couple years ago we started using cRIO.

I recommend that the NI tutorial (How to turn a RT Target into a Modbus Slave using IO Servers) be updated for LV 2009.

I appreciate your response and help.

Dave

0 Kudos
Message 4 of 7
(4,502 Views)
I'm glad I could help.  It's a pretty common mistake to forget that, because with most other things in computers (especially in LabVIEW) you don't have to worry about that kind of stuff.
0 Kudos
Message 5 of 7
(4,467 Views)

can somehelp me out. im new to labview. Im doing a small project on communication between two computers via labview on modbus protocol. So we have to select the com port in the field dats written "visa resource name" but somehow there are no options in mb serial init.vi. it only has "refresh". wat could be the reason that i dont see the drop down menu to choose the com port in "visa resource name" ???

0 Kudos
Message 6 of 7
(4,164 Views)

Don't post the same question in multiple highjacked threads.  If the answer given for your other post does not help, then move the discussion into a single brand new thread.

 

The same question in multiple threads (especially ones that aren't related to your problem) just annoys people.  Especially when they answer your question to one thread that has already been answered in one of the other threads.  Also, if you wind up with on going discussions in multiple threads, it just duplicates everyone's work, and the information you are given and questions asked are just scattered among multiple places.

0 Kudos
Message 7 of 7
(4,147 Views)