Jump to content

Tell me how to use Modus Master Library


Recommended Posts

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
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

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
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

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.



 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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