LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Contenating .BIN files (similar to R16 format) to Graph

Hi,
I am fairly new to Labview and not knowing advance features yet.
I have 15 binary files , each of which is having information of 64 Sensors( 1 Block - 64 Sensors - 128 Bytes).
(adding the file as .txt file as .bin file is not supported , test001 , test002)


Within each binary file multiple blocks are stored, my purpose is to create graph of each sensor individually.
For Eg:
Sensor 1
Offset of Value 1 of Sensor 1 is in Block 1 from 1 Byte

Offset of Value 2 of Sensor 1 is in Block 2 from 129 Byte of same file

Sensor 2 
Offset of Value 1 of Sensor 2 is in Block 1 from 3 Byte

Offset of Value 2 of Sensor 2 is in Block 2 from 132 Byte of same file

To solve above problem I have created following algorithm.
Please note , my algorithm works but , I get memory full error (sometimes ) and some data of sensors is missing , may be becasue there might any limitation to what a spreadsheet file can store, but I am not sure.


Step -1  ( Reading binary files in a loop and creating a single spreadsheet file)
sub_vi_2_Working_new_single_spreadsheet.vi (Attached)

divgup1986_0-1658924113278.png


Step-2 ( Reading sensor values which are stored at different offset)
Snippet and VI file both are attached.I have put comments for ease understanding,as I might be making things complex.

snippet.png


Support Requested

My question , is how can i improve the algorithm.
1) I am in doubt , whether I am doing things in a correct way.
2) Because there are 64 values , there will be 64 different algortihms (which is shown in Algorithms node), My purpose is to create a GUI , so that user can select/change the formula and see the corresponding graph.

3) As the .bin files are large 400 mB , I  sometimes get memory full error, which may also be due to problem in subvi , where I am opening the same file Data.bin to store concatenated output of .bin files , but I am not too sure about it.

Hopefull for response from NI community.

Thanks

0 Kudos
Message 1 of 18
(2,072 Views)

Your code is unbelievably inefficient and convoluted.

 

So you are reading a U16 binary file, the appending it to a formatted file, the reading the final file as DBL (4x more bytes!!!). So much hot air!!!

 

All you need is e.g. something as follows for your subVI:

 

altenbach_0-1658932798661.png

 

 

(Now I'll focus on the toplevel VI. Seem highly convoluted too.....

0 Kudos
Message 2 of 18
(2,037 Views)

Some questions:

 

Are all bin files of the same size? If not, you cannot put them into a 2D array, because all shorter rows will get padded with zeroes.

 

You probably want to read the file right in the main loop and process each row according to the size.

 

What do you want at the end? (e.g. a 2D array with 64 rows, one for each sensor)

 

0 Kudos
Message 3 of 18
(2,029 Views)

Making some very wild guesses, see if this can give you some ideas.

 

  • It reads all bin files in the given folder.
  • For each bin file, the flat U16 binary data gets reshaped into an array of 64 columns (And a sufficient number of rows to contain all data!) and appended to the previous data using a concatenating tunnel.
  • At the end, we have a 2D array with 64 columns, each representing one sensor. Each row is the concatenated sensor data from all files.
  • We can pick with a control which column to graph.

Most likely, this not exactly what you want, but it should give you some ideas. 😄 Modify as needed.

 

 

altenbach_1-1658936133531.png

 

0 Kudos
Message 4 of 18
(2,015 Views)

Hi,
Step-1 Completed ( and partially some of Step-2 also)
I don't know why have you written , modify as needed. 😄

 

The vi provided by you works perfectly fine and thanks for correcting me.
I first thought of its algorithm in C, then according planned to maked the VI, but I guess experience is the key to keep the vi as small as possible for the same task. 



Can you please guide further and tell me what would be the best for following steps :

Step.2 Binding Algorithms to Sensor Values

In current application each sensor value in All data array, is having different scaling factor or equation, in some I have to right shift / left shift and for some , I have to apply signed / unsigned fixed point conversion or in some quadratic equations have to be applied.
Many of the above calculations are repetitive, for 12 parameters after Left shift step is same but only scaling factor is different, can there be a way in in which .

1) Like we are selecting , Offset, for the graph in real time , similar to that , can there be anyway in which

each different sensor value (0-63)  is linked with its corresponding algorithm (0-63).

 What I have thought - once algorithms are finalized at my end, I will make sub-vi's for algorithm (which are repetetive) and other algorithms can be put in a case structure,once the Offset value will is selected , I can index a particular array and forward the values to this algorithm with , Case-Structure and then the result can be seen as graph. ( dont't know if its correct way to do it)




Step.3 Multiple Plots

I am also looking for a way to check mark which values are to be displayed in the graph. For this , I have thought of creating a binary array of 64 values and use it somehow to bundle the output, but I am unable to think of a way clearly.


Hopefull for your guidance.
Thanks

0 Kudos
Message 5 of 18
(1,980 Views)

Step 2:

 

So the scale factor to apply is specific to each sensor? How many individual scaling algorithms are we talking here, and how do you determine which to apply?

 

Do you actually need the raw values for anything? Or can you store the scaled values back into the same array?

 

Step 3:

 

Would using the functionality of the plot legend be a viable solution?

 

JimB_0-1659182659779.png

 

0 Kudos
Message 6 of 18
(1,974 Views)

In particular, show the "plot visibility" checkbox. No code needed. 😄

 

altenbach_0-1659198609291.png

 

0 Kudos
Message 7 of 18
(1,964 Views)

@divgup1986 wrote:

Step.2 Binding Algorithms to Sensor Values

In current application each sensor value in All data array, is having different scaling factor or equation, in some I have to right shift / left shift and for some , I have to apply signed / unsigned fixed point conversion or in some quadratic equations have to be applied.
Many of the above calculations are repetitive, for 12 parameters after Left shift step is same but only scaling factor is different, can there be a way in in which .

1) Like we are selecting , Offset, for the graph in real time , similar to that , can there be anyway in which

each different sensor value (0-63)  is linked with its corresponding algorithm (0-63).

 What I have thought - once algorithms are finalized at my end, I will make sub-vi's for algorithm (which are repetetive) and other algorithms can be put in a case structure,once the Offset value will is selected , I can index a particular array and forward the values to this algorithm with , Case-Structure and then the result can be seen as graph. ( dont't know if its correct way to do it)

We really need to have more information on the "algorithms"

 

If it is just an offset, scale, quadratic, you could just apply a second order polynomial to all columns, where some of the terms might be zero (e.g. if you only want an offset for a particular sensor, the linear and quadratic terms could be zero).

 

Here is one possibility (It could be made more scalable, of course):

 

altenbach_1-1659200636090.png

 

An x-shift is more tricky. You can implement a "delay" by integer multiples of dt, but shifting into the future is of course not possible 😄

 

Can you be a bit more specific about the exact transforms you need?

0 Kudos
Message 8 of 18
(1,962 Views)

@altenbach wrote:

We really need to have more information on the "algorithms"

There are total 4-5 types of algorithms / parameter types.

For Eg: in 16 bit signed two 16bit values are taken from two adjacent offsets.
In higher (16-8 bits) are right shifted and then the lower 16 bits are added,after adding the result is scaled .

 

value types.jpg

Like three shown above there are two more type of algorithms, which are simple, like 16 bit unsigned values and 12 bit discrete values.In total there are 6 algorithms , but the scaing factor , shift factor etc. varies.

 

Thanks

0 Kudos
Message 9 of 18
(1,921 Views)

@JimB. wrote:

Step 2:

 

So the scale factor to apply is specific to each sensor? How many individual scaling algorithms are we talking here, and how do you determine which to apply?

 

Do you actually need the raw values for anything? Or can you store the scaled values back into the same array?

 

Step 3:

 

Would using the functionality of the plot legend be a viable solution?

 

 


  1.  The scaling factor etc, once decided is going to be fixed, for the particular parameter.
  2. Therer are total 6 types of scaling / conversion algorithms.
  3. I haven't thought about it, but raw values are not being used for anything else, other than getting final results.

    Step 3.
  4. I will check the plot legend function, the main purpose is to select out of which out of given 64 parameters are to be plotted.

    Thanks
0 Kudos
Message 10 of 18
(1,919 Views)