Jump to content
News about the LabVIEW Wiki! Read more... ×
Canoko

Tell me how to use Modus Master Library

Recommended Posts

Hi, Nice to meet you.

I'd like to use "Write Single Register.vi" by RTU mode.

But I don't know how to input Value(U16).

http://modbus.org/docs/PI_MBUS_300.pdf

For example, like a query in above link page28, Figure 7.

In this case, How can I input value ?

Sincerely,

Canko

Share this post


Link to post
Share on other sites

What is the datatype you want to write? If the manual for the device say that a particular register is interpreted as a 16- bit signed integer (I16 ) you will need to use the type-cast function on the I16 data in your LabVIEW program and wire that that to the write single register VI.

For single precision floating point values, which are 32 bits, the modbus device will typically have you write to two consecutive registers in memory, typically called the high word and low word. It's done this way because every modbus register is 16 bits.  So what you do is this

 

 

typecast single float.png

 

and wire the array of U16s to the "write multiple registers" VI. Usually if the high word precedes the low word in memory this will work. If not the you have shuffle the high and low word. Modbus is fairly old, dating back to the 70's and doesn't have built in support for flaoting point.

 

Edited by MarkCG

Share this post


Link to post
Share on other sites

Mr.Poter and Mr.MarkCG, thank you for reply.

For example, I'd like to write a query message like this uploaded image.

In this case, Can I use the "write multiple registers.vi" ?

First, I make an 1Darray. It is Slave Address, Function, ...Error Check.

Technically, It is 0000 0110, 0000 0011, ...CRC.

Then, I input to value of "write multiple registers.vi" it ?

Can I understand your advices ?

Sincerely,

Canko

WS000000.JPG

Share this post


Link to post
Share on other sites

Possibly you're missing that Porter's library (pretty as much as any other modbus library) is made in order to save you from the technicality of how to build the proper header and CRC. To reproduce the table you copied, which is call function 3, read holding registers, for a device at address 6 (hence serial modbus it is) you do like this:

r.png

Edited by ensegre

Share this post


Link to post
Share on other sites

Mr.ensegre, thanks your help.

I made a mistake in upload image last time. I'm so sorry.

I'd like to write a query message like this uploaded image about Function 06.

WS000001.JPG

I tried to use "Write Single Register.vi" in reference to your advice.

WS000002.JPG

Is this correct ?

 

Sincerely, Canko

Share this post


Link to post
Share on other sites

From the picture, it looks like slave ID is wrong. 11 decimal = 0x0B in hex

If you want to communicate with slave ID 0x11, you should change that slave ID constant to 17

By the way, if you want to test communication with an instrument, I suggest that you try the Modbus Comm Tester. You can open it from the "Tools->Plasmionique" menu.



 

Share this post


Link to post
Share on other sites

You are right. I made a mistake.

Is this "the Modbus Comm Tester" that you suggested, right ?

WS000000.JPG

 

Share this post


Link to post
Share on other sites

I'll try to test by it.

Mr.Poter, Mr.MarkCG and Mr.ensegre, thank you very much !

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site, you agree to our Terms of Use.