LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

modbus register readings, double type Shared Variable>32000

Hello
 
I am new to labview and modbus and have been trying to communicate with a control card using the VIs in the standard modbus library in labview 8. This might be a very simple question, it relates to the output of the "read holding register" or "function code 0x03" . All the results I have been getting are in 5 digit decimal form, I have read in another post that this may be the "double type Shared Variable" and that it can be converted or typecasted to "ieee 754 type" i.e. as actual measurement values. I was wondering if it is possible for 5 digit "double type shared variable" that are greater than the 32000, i.e such as 50119 or 50294, to be converted to "ieee 754 type". Or even if there are standard methods that can perform this type of conversion in general.
 
Thanks in advance
0 Kudos
Message 1 of 7
(6,191 Views)
Hi,
This KB has a VI attached to it which does IEEE 754 to Single conversion. Is this what you are after?
Regards,
0 Kudos
Message 2 of 7
(6,132 Views)
Hello
 
Thanks for the reply, the problem is fixed now, it was just basically converting and combining two 16 bit half precision numbers to a float type or "readable form".  Thanks for the link anyway.
 
Could I ask on similar note if you have any experience with writing to two (paired) 16 bit precision registers that share the same address. I have tried using function code 6 (write single register) and function code 16 (write multiple registers). The write single which seems to be trying to write to only one 16 bit register and not the other, the write Multiple which came back as an illegal data address error (6002 or 2) in which I used the starting address and a quantity of 2.
 
I have tried modifying the standard "MB serial Modbus data unit t.vi" from the library and changing the number of bytes to be written to a register address (2bytes to 4bytes) and it still comes back with the same results. Just wondering if you have any expertise on this.
 
Thanks a lot
Regards
0 Kudos
Message 3 of 7
(6,127 Views)
32 bit values aren't going to 2 registers at the same address, they are actually 2 different addresses back to back.  You woul need the write multiple registers.
 
Take your single 32 bit value ,type cast and split the the words into 2 16 bit values.  Build them into an array.  Use function code 16 and give the starting address for the first register, and tell it you want to write to 2 registers.  Pass in the 2 element array.  In this thread,  I posted some example code where I was doing similar things, only in my case I was dealing with I32 values.
0 Kudos
Message 4 of 7
(6,122 Views)
Dear Ravens Fan
 
Thanks for the advice. I am actually a colleague of G.noble and we have been working on different parts of the same problem (hence the respective posts initially). Its just at the moment we are stuck on this writing to a single address that contains the two 16 bit registers, you may have seen this in the manual that G.noble uploaded. We are still waiting on confirmation from them and in the mean time we are trying to see if there is anyway to get around it. I have read your reply to G, that mentions the 'normal' modbus set up is that any register will have its own address rather than a shared address, correct me if i am wrong.
 
I will try using your recommendation, though i think (I might be wrong), that it is not a case of splitting up a 32 bit number and interleaving the resultant 16 bit numbers into an array. I value your expertise and I will go ahead with trying the programme, please advice.
 
Thank You Very much
Regards
 


Message Edited by K_enny on 03-30-2008 01:17 PM
0 Kudos
Message 5 of 7
(6,095 Views)

Maybe this will help.

http://forums.mrplc.com/index.php?showtopic=30

http://www.simplymodbus.ca/FAQ.htm#Types

What are data types?

The example for FC03 shows that register 40108 contains AE41
which converts to the 16 bits 1010 1110 0100 0001
Great! But what does it mean? Well, it could mean a few things.

Register 40108 could be defined as any of these 16-bit data types:
     A 16-bit unsigned integer (a whole number between 0 and 65535)
                    register 40108 contains AE41 = 44,609 (hex to decimal conversion)

     A 16-bit signed integer (a whole number between -32768 and 32767)
                                                        AE41 = -20,927
              (hex to decimal conversion that wraps, if its over 32767 then subtract 65536)

     A two character ASCII string (2 typed letters)
                                                        AE41 = ® A

     A discrete on/off value (this works the same as 16-bit integers with a value of 0 or 1.
                                              The hex data would be 0000 or 0001)

Register 40108 could also be combined with 40109 to form any of these 32-bit data types:
     A 32-bit unsigned integer (a number between 0 and 4,294,967,295)
                             40108,40109 = AE41 5652 =  2,923,517,522

     A 32-bit signed integer (a number between -2,147,483,648 and 2,147,483,647)
                                                       AE41 5652 = -1,371,449,774

      A 32-bit double precision IEEE floating point number.
      This is a mathematical formula that allows any real number (a number with decimal
       points) to represented by 32 bits with an accuracy of about seven digits.
                                                       AE41 5652 = -4.395978 E-11

      Here is a spreadsheet IEEE float calculator for inputs of 4 bytes or 2 words.
      To download a copy, right click and select Save Target As...

     A four character ASCII string (4 typed letters)
                                                         AE41 5652 = ® A V R

More registers can be combined to form longer ASCII strings.  Each register being used to store two ASCII characters (two bytes).

Message 6 of 7
(6,073 Views)

Dear UncleBump

Thanks for the advice and information. We got back some extra details from the manufacturer today and we are just testing it. I think the problem we were having, was that the format for writing (function code 3) and reading (function code 6) data are completely different in our application, in which we thought were the same. This included differences in the starting address for reading and writing to the same register and also the data types for writing is different from the form it comes back in, through "read single register".

Thank you very much anyway

Regards



Message Edited by K_enny on 03-31-2008 01:27 PM
0 Kudos
Message 7 of 7
(6,057 Views)