10-05-2012 04:48 AM
I want to read binary file in a specific format. There is a number at the starting of the file. That tells us where the data is starting. Suppose it says 3975, then it mean data starts at 3975. Then once I read that location I want to read data at 10bytes at a time and then convert it to numeric and display it on graph. I am attaching the file format and the current vi which I am using. please help.
Solved! Go to Solution.
10-05-2012 07:22 AM
To read in 10 bytes, you need to read it as U8 data type and set the count to 10. You would then need to convert the byte array as needed.
10-05-2012 07:23 AM - edited 10-05-2012 07:24 AM
Hi rohan,
I want to read data at 10bytes at a time and then convert it to numeric
Well, you want to read 10 bytes. But you have programmed to read 4 DBL values with each read operation (which are 32 bytes instead). Why have you done that?
Then your PDF says "Convert char to 'unsigned long int' ". You don't do that in your VI. Instead you read DBLs and then you convert those DBLs to ASCII values (which is nonsense!)...
Please read your own specs and program only that, what is told by the specs!
10-05-2012 07:29 AM
Unfortunately I am not very well versed with Labview else I would have done that. Just started to learn. I appreciate your efforts to look in to my problem and reply but your reply was a bit confusing for me. 😞
10-05-2012 07:37 AM
Read the help for the Binary Read VI. You will see that there is a data type input in the top. Wire a U8 constant there. You should also see a Count input. Right click here, create constant, change constant to 10. The output will turn into an array of U8. The array should contain 10 elements after reading.
10-05-2012 07:38 AM
Also if you refer to the jpg image I have sent, It shows there is data from 20 channels. I want to display coupling channel 1 and flaw channel 1 on one graph, coupling channel 2 and flaw channel 2 on second graph and so on up to 10..
10-05-2012 07:44 AM
the file I am reading is created and written by a windows CVI program
10-05-2012 07:54 AM
That spec doesn't make much sense. It says to read 10 bytes and convert that array of bytes into a U32. A U32 is 4 bytes. So 6 bytes are being thrown away. And then why would you waste even more disk space with nothingness?
Do you happen to have some of the source code of how this file is made?
10-05-2012 10:32 AM
here is the c code
10-05-2012 10:47 AM - edited 10-05-2012 10:48 AM
Ah, the first 10 characters are a string!
After opening the file, use the Read From Text File with count set to 10. Then use the Decimal String to Number to convert this string into your "record size".
NOTE: The text indicator was just for debug purposes. You don't really need it.