01-20-2006 08:02 AM
01-21-2006 05:06 AM
Basically you want to search for two times 0x7F in the datastream. If you find it you check if the next byte is also 0x7F and if so this and the preceeding byte are actually the sync and the first 0x7F was part of a previous data word. Now with the sync found and since your data seems to be in Big Endian which is what LabVIEW prefers, you can simply Typecast the rest of the string into an array of int16 or uInt16 depending on the singedness of the data. If your incoming stream after the sync contains more than 2 bytes you will end up with an array of 16bit integers in which every second value should be a sync word. The words in between are your real measurement values.
@HFZ wrote:A flowmeter provides data as 16-bit signed integer in binary format with 2 byte sync. precedingI got i small problem by understanding the synchronasation.I read the data provided by the flowmeter, and then write it to a binaryfile.dat. i need to convert the data to decimal format. is it better to convert the data before or after writing it to the binary file. Coz i need to read the data out again for calculations and save it again in a new file.I understand that the synchronization help one to see where to begin reading the usable data. is it right?Need any suggestionsThank you !Zamzam
01-23-2006 04:08 AM
That was a paradise off an answer!
Thank you very much Rolf Kalbermatter
Zamzam
01-23-2006 09:14 AM
HI Ray
I have developed the program after your answer,
i search the input string for 7F7F and, then i take the next byte and compare it with 7F, if its true then i got a wrong Sync. so there i take the input string again and saerches for the three bytes to remove them and take the last byte coz that must be a useable data. typecast it to to 16 bit signed integer and initialize it into an array adds a timestamp to the data value and plot it out in a wavechart.
As you can see in the jpg.image i've made a probe to compare the dataflow, and they seems to be in binary format like assumed. But i f you look at the panel in the Front Panel, you see som hex data. So i got that problem that i cant compare with the strings "7F7F" ect.
I'm not shure that my program is right made. so If you can give a look , that would be helpfully!
Zamzam
01-23-2006 09:18 AM
One more thing that i'm thinking about is: the order of reading the 4 bytes. If u look at the datasheet in the first message (with the sync. example)
Do i have to revert the bytes, before converting the data for plotting them to a waveform graph.
Zamzam
01-23-2006 10:15 AM
Exactly NOT! As I mentioned in the earlier post since the data seems to be in Big Endian format already this is perfectly right for the LabVIEW Typecast fucntion, since LabVIEW also assumes Big Endian data when unflattening data streams. So no need to swap Bytes.
@HFZ wrote:One more thing that i'm thinking about is: the order of reading the 4 bytes. If u look at the datasheet in the first message (with the sync. example)
Do i have to revert the bytes, before converting the data for plotting them to a waveform graph.
Zamzam
01-26-2006 02:35 AM
01-26-2006 02:40 AM
sorry my bad about the data file,
There will be a date and timestamp and then a datavalue, in the file. Two coloumns.
example :
26-01-2006.09:38:52:498 -256
26-01-2006.09:38:52:503 -154
26-01-2006.09:38:52:508 32
26-01-2006.09:38:52:513 214
01-26-2006 07:07 AM
If you get several valid data in one line this is not SPURIOUS data in the stream. The loop is setup such that it reads whatever is on the serial port and then converts it to an ARRAY of values. If your device is set to generate lots of data it is very likely that this routine receives several values in each iteration. So your values array is in fact an array of several values and you convert it into a spreadsheet string and append it to the line. This will give you a timestamp, a tab and 0,1, or more tab separated values per line.
@HFZ wrote:
sorry my bad about the data file,
There will be a date and timestamp and then a datavalue, in the file. Two coloumns.
example :
26-01-2006.09:38:52:498 -256
26-01-2006.09:38:52:503 -154
26-01-2006.09:38:52:508 32
26-01-2006.09:38:52:513 214