07-12-2006 05:10 PM
07-12-2006 05:36 PM - edited 07-12-2006 05:36 PM
Jeff
You can use the type cast function to do this
David
Message Edited by David Crawford on 07-12-2006 11:37 PM
07-12-2006 10:53 PM - edited 07-12-2006 10:53 PM
Hi Jeff,
It's possible you may be able to cast directly to an array:
tbd
Message Edited by tbd on 07-12-2006 10:55 PM
07-13-2006 03:33 PM - edited 07-13-2006 03:33 PM
Forgive me but I'm confused about this function. I don't understand what either of these examples is doing.
If I had an array of let's say 8 bytes (unsigned 8 bit integer). Those 8 bytes represent 2 floating point values. So I need to grab 4 bytes at a time, convert each to a floating point value (IEE754).
Is this what either of these functions is doing?
I'm trying to read the help about the typecast but it's really confusing.
Jeff
Message Edited by jeff_scharpf on 07-13-2006 03:33 PM
07-14-2006 03:16 AM - edited 07-14-2006 03:16 AM
Message Edited by David Crawford on 07-14-2006 09:16 AM
07-14-2006 03:28 AM
07-15-2006 12:16 AM
Hi Jeff,
It's pretty common to read a waveform from an instrument, like a scope or a spectrum analyzer, as a binary string. Perhaps you're using "driver" software that returns an array of bytes. Either way - whether you start with a pink "string", or blue "array of bytes") don't be afraid to try casting directly to an array of floats. (If starting with a string, you may have to crop some formatting info first.) Anyway, the less code the better.
LabVIEW stores arrays of SGLs as contiguous 4-byte sequences. It sounds like the floats returned by your device (IEEE754 => 23bits fractional component) are formatted exactly the same as an array of LabVIEW's SGLs. If so, it should be possible to "cast" the raw data directly to an array of SGLs!
tbd
07-17-2006 05:20 PM
Thanks again for the replies.
I'm close but something still isn't quite right. The reason I know that the data is good is because Labview can read it, store it, and the software that comes with the data acquisition has no problem reading that saved file and stripping the header.
The problem I have is no matter how I typecast I always get different data. I'm either not taking the header off correctly or something, but I don't know.
I can see a specific number of bytes. They are all there. Yes they are 4 byte words in IEEE754 format. There is also a 77 byte header in the file. What I don't know is if the data is contigous. (For example, I know what the decimal value of the very last data point is). But when I look at the raw last 4 bytes, and convert this using an IEE754 conversion program, I come up with different values.
I realize this is not for this discussion. I now understand that if I have an array of 4 byte floating point numbers I can convert the raw bytes into numbers.
Thanks for your help.!
Jeff
07-18-2006 02:21 AM
07-18-2006 07:09 AM
Thanks Gerd,
I've posted this on another forum because I was trying to get the data acq driver to work. The company is called Stanford Research. The instrument (and driver) is the SRS785.
Here's what I posted, along with the data: