12-11-2015 04:40 AM
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.
Solved! Go to Solution.
12-11-2015 04:43 AM - edited 12-11-2015 04:50 AM
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:
12-11-2015 05:40 AM
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.
12-11-2015 05:49 AM - edited 12-11-2015 05:56 AM
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…
12-11-2015 06:18 AM
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
12-11-2015 06:25 AM
12-11-2015 06:33 AM
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 😉
12-11-2015 06:35 AM
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
12-11-2015 06:40 AM - edited 12-11-2015 06:45 AM
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:
You just need to adapt the array constant on the left for each type of "cluster"…
12-11-2015 06:48 AM
I think that might just work.
Thanks a lot.