LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read and write 32 bit number not equal

Hello and thank you for any help you might be able to give me.
 
I'm reading a 32 bit value from a register or memory location which I then wish to save in decimal or binary format to manipulate later. If I compare the 32 bit value that I write to a file with the value read from the file later the two values (which ought to be the same) differ by about 50 something. I've looked through the discussion forums and see there is a bug linked to U32/binary values but don't understand the solutions given. 
0 Kudos
Message 1 of 10
(2,968 Views)
Make sure you are writing and reading using the same format, sometimes there is a byte or work swap which can cause some wierd and un expected effects.  A few more details would help, where is the register? how are you reading/ writing to it?  Can you provide the code to look at?
 
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 10
(2,947 Views)
What kind of 32bit representation are you using. From your description I'm guessing SGL? What do you mean by "decimal format"? ASCII formatted text?
 
If you write your values to a binary file, you won't have a problem. Anything involving formatting will mutilate you data to some extent.
 
Could you provide more detail on what you are actually donig. Show us a VI containing some typical default data.
0 Kudos
Message 3 of 10
(2,931 Views)

 


@falkpl wrote:
Make sure you are writing and reading using the same format, sometimes there is a byte or work swap which can cause some wierd and un expected effects. 

I doublt it is a byte order problem, the data would be off by more than 50 in most cases. 😉

0 Kudos
Message 4 of 10
(2,928 Views)
I know that the word swap would be off way more than 50 but It was a swing in the dark without more information on the way in which the data is written.  Formatting is more likely but I thought that it was a I32 (but now I see that it only says 32 bit number, not necessarily an integer)
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 5 of 10
(2,911 Views)

Sorry I haven't replied to sooner. Thank you for the responses so far.

The details of where the data values come from are of no real help here; they are, however, integers (decimal representations of 32 bit numbers) - I was going to attach a VI to prove my point but it'll be just as quick to write a phrase or two. If afterwards you still don't understand what I'm talking about I'll send a VI.

Save a U32 or I32 number of ten or more digits to a spread sheet file using the common write function and then read the number with the corresponding function. You'll see for yourself there's a problem. The way around that I've discovered is to change the numeric representation to floating point/double precision, though I don't see why this should be necessary because the ten digit numbers I'm talking about are well within the I32/U32 data range.

Thanks again

0 Kudos
Message 6 of 10
(2,906 Views)


@raff wrote:
Save a U32 or I32 number of ten or more digits to a spread sheet file using the common write function and then read the number with the corresponding function.

An U32 number cannot have more than 10 digits, it will overflow.
Same with more than half of all possible 10 digit decimal numbers (Highest U32 is 4294967295, half that for I32).

What are your typical input numbers?

What format specifier do you use when you write to spreadsheet file? Have you looked at your spreadsheet file in notepad?

0 Kudos
Message 7 of 10
(2,895 Views)

Sorry, I was trying to be clear but wasn't. If you take the number 4294967295 (the highest number possible in the U32 bit data range) and replace the first digit by, say, a 1, which  is clearly a smaller number that shouldn't overflow, 
and then write and reread the value you should see that the initial and read values differ. I'll send a VI in the next post.
0 Kudos
Message 8 of 10
(2,881 Views)

Ok, now I'm logged in under my own name. Here's an example VI.

0 Kudos
Message 9 of 10
(2,879 Views)
The "Write to Spreadsheet File" uses single precision floats. So your I32 number gets converted to a single precision float, loosing some digits of precision. Either you'll have to make a copy of the write to spreadsheet VI which will handle I32 numbers or create a spreadsheet string and write it to file using write characters to file.

0 Kudos
Message 10 of 10
(2,875 Views)