Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted
I am using a Modbus driver to obtain measurement data. My measurement device

contains a single precision floating point in a so called pair of holding

registers. When I read the data with Labview I get two 16 bit fields in a

data array. I am new to Labview and I am struggling to reconstruct a proper

single precision value (32 bit) from the two 16 bit data fields. Any hints,

Martien

01-16-2003 01:36 PM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

contains a single precision floating point in a so called pair of holding

registers. When I read the data with Labview I get two 16 bit fields in a

data array. I am new to Labview and I am struggling to reconstruct a proper

single precision value (32 bit) from the two 16 bit data fields. Any hints,

Martien

Highlighted
Options
There are two functions you should look at in the Advanced >> Data Manipulation palette: Join Numbers and Type Cast.

Join Numbers takes two 16 bits numbers and joins them into one 32 bit number (or two 8 bit into one 16 bit). When you join them, make sure you know which is your high word (or Most Significant Word) and which is your low word (or Least Significant Word). You could also create your 32 bit number by multiplying the high word by 2^16 and adding it to the low word.

If your number is in the IEEE 32 bit floating point format, you then need to Type Cast that number as a single precision number. On your diagram, create a numeric constant, right-click on it and change the Representation to SGL. Wire that constant to the Type input of the Type Cast function an

d wire your new 32 bit number to the X input.

01-16-2003 02:43 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Join Numbers takes two 16 bits numbers and joins them into one 32 bit number (or two 8 bit into one 16 bit). When you join them, make sure you know which is your high word (or Most Significant Word) and which is your low word (or Least Significant Word). You could also create your 32 bit number by multiplying the high word by 2^16 and adding it to the low word.

If your number is in the IEEE 32 bit floating point format, you then need to Type Cast that number as a single precision number. On your diagram, create a numeric constant, right-click on it and change the Representation to SGL. Wire that constant to the Type input of the Type Cast function an

d wire your new 32 bit number to the X input.

Highlighted
Options
It sounds like your measurement device is using the IEEE 754 standard for a single precision number. The numbers are obviously split into two fields but actually represent one 32 bit number. If you look at the binary representation of that 32 bit number, the first bit is the sign of the number (0 positive, 1 negative), the next 8 bits represent the exponent of the number, and the last 23 bits represent the mantissa of the number. I hope this helps.

Regards,

Steve

01-16-2003 02:53 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Regards,

Steve

Highlighted
Options
The Type Cast function (in the Advanced >> Data Manipulation palette) takes care of this for you, so you don't have to parse the 32 bit number into fields and do the math to get the floating point number. You just put in the 32 bit number, wire the Type input to a LabView numeric constant represented as Single, and you get out the floating point number.

01-16-2003 03:12 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Highlighted
Options
You're right. I just tried that and it worked like a charm. Oh well, I guess a little extra info doesn't hurt.

Regards,

Steve.

01-16-2003 03:32 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Regards,

Steve.

Highlighted
Options
Thanks Al and Steve,

I tested the procedure given by Al and it works perfectly. Thanks very much

for your help, and the extra info of Steve certain did not hurt. On the

contrary, I appreciate it in order to understand better what is actually

happening when reassembling the floating points.

Kindest regards,

Martien

"Steve W." wrote in message

news:50650000000500000031C50000-1042324653000@exchange.ni.com...

> You're right. I just tried that and it worked like a charm. Oh well, I

> guess a little extra info doesn't hurt.

>

> Regards,

>

> Steve.

01-17-2003 09:36 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

I tested the procedure given by Al and it works perfectly. Thanks very much

for your help, and the extra info of Steve certain did not hurt. On the

contrary, I appreciate it in order to understand better what is actually

happening when reassembling the floating points.

Kindest regards,

Martien

"Steve W."

news:50650000000500000031C50000-1042324653000@exchange.ni.com...

> You're right. I just tried that and it worked like a charm. Oh well, I

> guess a little extra info doesn't hurt.

>

> Regards,

>

> Steve.

Highlighted
Options
I agree with Steve here. I have run into similar situations with different IEEE standards, and multiple times it came down to this problem.

01-17-2003 10:15 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

J.R. Allen