LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

processing raw data in different ways depending on some condition

Hi,

 

I am receiving a raw data stream through a UDP port. The values contained in the raw data are all stored in 32 bits but are of different formats i.e I have 16 bit signed integer, 32 bit signed integer, 8 bit unsigned integer and 32 bit single precision floating point number. I have a spreadsheet which tells me the measured parameter, the data type and the address of the parameter within the stream (ie parameter 1 is address 1 and is the 1st 32 bits, parameter 2 is address 2 and is the following 32 bits, and so on...) I need to use the "data type" column from the spreadhseet as a condition to a case structure which will then display the 32 bits of data in the correct format. Ideally I want my output to be an array of numbers under each Parameter (or address) so I can save to a TDMS file. I have an idea of how to do this part but I am struggling to link the 'data type' condition and case stucture successfuly. Any ideas or pointer would be greatly appreciated. I have attached my VI so far...

0 Kudos
Message 1 of 21
(2,720 Views)

You just don't have a 'Default' case for your case structure. That's why you are getting the error. Just create a new case, right click on the border of the case structure and choose 'Make this the Default case'.

 

Also, is there a need to read the spreadsheet on each iteration of the loop? You can place the spreadsheet outside the loop, get the 2D array and read the specific data value at a particular iteration.

 

Let me know if I have not understood things right.

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 2 of 21
(2,713 Views)

Everytime the loop completes, another data stream is sucked in through the UDP portal which needs to be divided up into 32bit packets and read according to its data type. So I would have thought I need to read from the spreadhsheet every execution of the loop? I should say that parameters may be added to or removed from the spreadsheet so the order of the data types may change. At the moment the input to the case structure is an array of data types. Is this maybe causing a problem as a single data type is not being fed into the selector terminal? Do I need anothe loop inside the outer while loop to look through the data types in the spreadsheet and assign each 32 bit bundle with a data type?

0 Kudos
Message 3 of 21
(2,710 Views)

@TGL wrote:

At the moment the input to the case structure is an array of data types. Is this maybe causing a problem as a single data type is not being fed into the selector terminal?



You are indexing out a 2D array, thus you need to wire both indices to get a scalar element suitable to be wired to the case structure. If you leave one index unwired, you get an entire row or column respectively.

 

How often does the file change? If it is always the same, it would be sufficient to read it once before the loop.

0 Kudos
Message 4 of 21
(2,705 Views)

 

 

 

0 Kudos
Message 5 of 21
(2,692 Views)

The element sent to the selector terminal should change every 32 bits of data. Assume every time the loop executes there are 1000 bits of binary data received. The binary data contains measured parameter values which are each stored in 32 bits of data, each parameter will be stored in a different binary format (float, integer...). This format is listed in a spreadsheet which i need to read to know how to process the 32 bits of binary data. The next time the loop executes the binary data changes, but the format of the 32 bit bundles does not. How do I change the string sent to the selector terminal of the case structure every 32 bits of data passed?

 

Please let me know if this is clear enough...

0 Kudos
Message 6 of 21
(2,684 Views)

explanation.png

0 Kudos
Message 7 of 21
(2,683 Views)

@TGL wrote:

Please let me know if this is clear enough...


No, it is not clear. Please attach a VI containing a typical string as diagram constant. How many different types are there? Are they always in the same order? You have much more than 32 bits of data, so why would the selector change ever 32 bits/

0 Kudos
Message 8 of 21
(2,667 Views)

Hi,

 

I think I understand your problem,

 

So you have a stream of essentially continuous data, which you need to split up into different values of different data types and display them on the front panel. You need to change the case selector every 32 bits for the next data type to be read from the spreadsheet, so you can select the appropriate case, to cast it to the right data type.

 

You will need to add a value to the row input of your index array, so a single string is read out, rather than a 1D array of strings. I would suggest this row indexing value changes every time 32 bits of data have been passed through the system, to reflect the data type you require the data to be type cast into.

 

Joel G
Applications Engineer
National Instruments UK & Ireland
0 Kudos
Message 9 of 21
(2,640 Views)

Yes that's exactly what I want to do. I am incrementing the row index every 32 bits by using the quotient and remainder block; I divide the number of bytes recieved by 4 (32 bits) and every time the remainder is zero i have a condition which increments the row index by one and reades the new data type. However, the new data type does not seem to be fed to the case structure at the same time as the data is fed in to be processed. How do I ensure these two inputs are in sync?

 

Thanks

0 Kudos
Message 10 of 21
(2,636 Views)