Canoko Posted May 8, 2018 Report Share Posted May 8, 2018 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 Quote Link to comment
Porter Posted May 8, 2018 Report Share Posted May 8, 2018 You mean something like this? Quote Link to comment
MarkCG Posted May 8, 2018 Report Share Posted May 8, 2018 (edited) 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 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 May 8, 2018 by MarkCG Quote Link to comment
Canoko Posted May 9, 2018 Author Report Share Posted May 9, 2018 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 Quote Link to comment
ensegre Posted May 9, 2018 Report Share Posted May 9, 2018 (edited) 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: Edited May 9, 2018 by ensegre Quote Link to comment
Canoko Posted May 10, 2018 Author Report Share Posted May 10, 2018 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. I tried to use "Write Single Register.vi" in reference to your advice. Is this correct ? Sincerely, Canko Quote Link to comment
Porter Posted May 11, 2018 Report Share Posted May 11, 2018 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. Quote Link to comment
Canoko Posted May 13, 2018 Author Report Share Posted May 13, 2018 You are right. I made a mistake. Is this "the Modbus Comm Tester" that you suggested, right ? Quote Link to comment
Porter Posted May 14, 2018 Report Share Posted May 14, 2018 Yes, that is the modbus comm tester. Quote Link to comment
Canoko Posted May 14, 2018 Author Report Share Posted May 14, 2018 I'll try to test by it. Mr.Poter, Mr.MarkCG and Mr.ensegre, thank you very much ! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.