01-05-2009 01:25 PM
Hi,
I am communicating to a controller from my labview program using modbus RTU and the controller has modbus 16 bit registers.
To send in float values like "1.23" , I have to write two registers to store the 32-bit hexadecimal value for this float value.
I use the modbus driver provided by labview for this purpose and I use labview 8.2.1
I have the following doubts regarding this.
Solved! Go to Solution.
01-05-2009 02:11 PM
I suspect a confusion between decimal 16 and hexadecimal 10 😉
Two successive register writes are not equivalent to one double write : during the period between the two writes your controler will be loaded with a false parameter. This may not necessarily be a source of problems. It depends on your application. Writing the MSB first should reduce the problem.
The Hi-Lo order is dependent on the controler maker. Some use Big Endian, other Little Endian. But this choice should affect single register values (U16) as well.
If this is not documented, you should read the registers, and see if the result makes sense. If not, reverse the byte order and verify that the problem is solved. Good luck 😄
By the way, I suppose you know how to use the typecast function to convert a single (32 bits float) into 2 U16 ?
01-05-2009 02:24 PM
Thank you CC,
How am I so dumb not to recognise that 16 in decimal is 10 in hexa..
haha.. happens.. phew!!
Ya, I have converted a floating point into U32.
Now to split it, and give decimal values to the vi, should I give the decimal equivalent of the MSB and LSB to the vi..
For example
12.3 in U32 is 4144CCCD
so to give two values to two registers, should I give 16708 and 52429 to the registers as MSB and LSB as they are equivalents of the values shown below
|| ||
4144 CCCD
Please clarify this alone..
Thanks a ton for your help.
🙂
VJ
01-05-2009 03:14 PM - edited 01-05-2009 03:16 PM
Not sure about the way you do your conversion. Have a look at the diagram below and tell me if this is what you were doing 🙂
The most interesting thing here is that casting the single precision float to an U16 array (top type cast operation) gives directly the data to be transfered to your ModBus VI. 😉
01-05-2009 03:38 PM
Thank you so much..
I was using the method that I have attached to this post.
Which is nothing but one of the methods in your VI.
Yours seems to be a short method than mine as it directly converts it to an array.
I will use yours
Thanks a lot
VJ
01-05-2009 03:39 PM
This image is more clearer than I posted above..
Thank you
01-05-2009 04:55 PM
vijay shankar a écrit:This image is more clearer than I posted above..
Thank you
The prefered format to post clean diagrams is png.
And never forget the Kudos button 😄 😄 😄
07-10-2010 10:49 AM
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" ???
07-10-2010 11:29 AM - edited 07-10-2010 11:30 AM
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.
07-10-2010 07:18 PM
ohh sorry. Very new to this forum and i was desperate. Anywayzz will remember that. Tq 🙂