LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Update binary data to cluster with fixed point element

Solved!
Go to solution

Hi All,

 

I am stuck with a small problem. I have a binary data of 8 bit lenght representing some information. But the data varies as the first 8 bits are divided e.g 0-3 bits represents a specific data, 4-5 represents some other data and 6-7 represents. Now I am showing the data on the front panel using a cluseter with fixed point. Normally in text based language I can update a stucture with specific lengths of numerica data easily but I cant seem to figure out a function in labview that will do that. Have a look at the VI for my current Implementation. But I am sure there is a easier way to do this.

 

The data I am dealing with is huge so I want an efficent way to update my cluster which doenst invole me making case stuctures.

 

Best Regards.

A.

0 Kudos
Message 1 of 10
(4,372 Views)

Hi Ali,

 

so you have an U8 value and you want to typecast into some other datatype? Just do a typecast…

 

Edit after looking at your VI:

- Why is the input a FXP, when you have just 8 bits?

- You can use simple boolean functions combined with shift operations to get the interesting values:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(4,368 Views)

Hi Grad,

 

The U8 i just use as a sample to make a small example. the data is U16 that I want to type cast to my existing clusters that have been handed to me already but the problem is the that information bits are not same meaning they change with respect to the data. They can be divided as  5-5-3-3 or 4-2-4-2-1-1-2 , hence the cluster have specific fixed point length. The thing is I already have the big cluster with the specific lenghts i was hoping to find a way to set the values automatically somehow so that I dont have to write a specific VI for every structure that I want to update.

0 Kudos
Message 3 of 10
(4,343 Views)

Hi Ali,

 

my name is not "Grad"…

 

They can be divided as  5-5-3-3 or 4-2-4-2-1-1-2 , hence the cluster have specific fixed point length

So you have a cluster, that will have elements for all possible combinations?

You need a case structure for each different combination of values. Each case will convert your U16 as needed and puts the values into the specific cluster elements.

No way for a simple typecast here…

 

Other idea:

Convert your U16 values into an array of U16 values. Use a FOR loop that takes the "5-5-3-3"/"4-2-4-2-1-1-2"-values as input…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 10
(4,336 Views)

sorry for  the typing error, my bad.

 

I am trying to avoid case structure  for each different value.

 

the for loop idea is much better but I am having trouble is getting the word lenght from my fixed point numeric. I have tried using cluster to array soo that I can use each elements length but converting it to array causes the each element to be of a fixed lenght. Any idea how to sequntialy access the word lenght of each element in the cluster ? see the pic

0 Kudos
Message 5 of 10
(4,330 Views)

Hi Ali,

 

again: why do you use FXP when you operate on U16 values?

 

Next time you please attach your VI instead of some images - they are hard to debug…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 10
(4,325 Views)

maybe I am not clear in defining the problem.

so the data I receive is U16 ... a array of 32 elements (U16), combination of bits  in a single U16 has different meaning. For examples the first one is divided as 5-5-4-2, the second one is 4-4-4-4 and so on.. The element in the cluster represents the information in each U16 element. So I was trying to write a generic function that I can just give as input the word and reference to my cluster that I want to update.

 

The FXP are the output data in the cluster that I am trying to update. The input is a array of size 32 with U16 numeric.

 

 sorry for not uploading the VI, I thought Knights of NI dont need VI's 😉

0 Kudos
Message 7 of 10
(4,320 Views)

also the FXP input in the example VI  was jsut an example so that instead of dealing with 16 bit, I thought it would be easier to deal with 8 bits first

0 Kudos
Message 8 of 10
(4,318 Views)
Solution
Accepted by AliA15

Hi Ali,

 

So I was trying to write a generic function that I can just give as input the word and reference to my cluster that I want to update.

Then you would need to parse the datatypes of each cluster element - and you would need a variant input. Seems not practicable (in my opinion)…

 

Using U16 is as easy as U8 - use the same boolean operations as shown above!

 

Generic example:

check.png

You just need to adapt the array constant on the left for each type of "cluster"…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 10
(4,312 Views)

I think that might just work.

 

Thanks a lot.

0 Kudos
Message 10 of 10
(4,297 Views)