07-27-2022 08:28 AM
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)
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.
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
07-27-2022 09:35 AM - edited 07-27-2022 09:40 AM
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:
(Now I'll focus on the toplevel VI. Seem highly convoluted too.....
07-27-2022 09:57 AM
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)
07-27-2022 10:33 AM - edited 07-27-2022 10:36 AM
Making some very wild guesses, see if this can give you some ideas.
Most likely, this not exactly what you want, but it should give you some ideas. 😄 Modify as needed.
07-30-2022 05:39 AM - edited 07-30-2022 05:41 AM
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
07-30-2022 07:05 AM
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?
07-30-2022 11:30 AM
07-30-2022 11:41 AM - edited 07-30-2022 12:04 PM
@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 whicheach 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):
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?
08-01-2022 04:51 AM - edited 08-01-2022 04:59 AM
@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 .
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
08-01-2022 04:58 AM
@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?