LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

make Cluster containing a byte a nibble and 2 bit data

hii,

I have   to read  data  from the bus  which I do get as  Bytes.
But  I want to parse the Information.  Ist easy if ist Bytes and words as I have built  Cluster for that.
How  to build a Cluster with  a nibble and  2 bit data  all together eg (8bit, 8bit, 4bit, 2bit)
The Minimum value for a constant is 8 bit .If there is a Cluster ist  gonna be  str. type def and can be used Overall.
yes there are other methods to parse but  I prefer  to implement Clusters.
any  Workarounds here.

regards,
Akshay

0 Kudos
Message 1 of 9
(3,197 Views)

I have no idea what you are talking about.

 

How is the cluster supposed to look like? (type of elements, number of elements, etc.)

 

Can you attach a simple VI showing a typical input and how the result should look like?

0 Kudos
Message 2 of 9
(3,190 Views)

Someone has the document that describes the data structure.  If it's not you, then you'd better obtain it.  Once you have it, share it with us.

 

Some hints:  It's okay to represent that numbers that are smaller than a byte as a U8 - as long as you remember that you need to encode it properly - if you ever need to do that.  If these numbers represent choices, you can use a text ring or an enum to limit the user only to valid values.  (Each method has its own pros and cons; choose wisely, Grasshopper!)  e.g., for a 2 bit number, use a U8 text ring or enum that only allows choosing 0, 1, 2, or 3.  This works especially well for encoding.  (You then need to fit that into 2 bits, but most of the work is already done for you.)  It gives the user a context for the numbers, and it saves you the headache of needing to handle invalid values.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 9
(3,163 Views)

Well, a computer works off of Bytes, not anything less.  So just store your smaller data as a U8 as previously suggested.  It is simple enough to perform masks and bit shifts to the received data.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 9
(3,154 Views)

a word of  thanks to all responders.

 

yes I did not clarify the method.

I am basically  trying to typecast the Input data(frames) , which are chunks of 8 Bytes each into a cluster.

But in the System we use   2 Bytes , 1 Byte, a nibble,2 bit or 1 bit data  to represent the state of the DuT.

as I and many of you mentioned there are other methods but  typecasting with a Cluster is simple because I can save the Cluster as strict type and use it elsewhere.

The issue is labview 2013 does not allow a "data type"  to be represented as a nibble or 2 bit data. It could  have been very helpfull

 

the png tries to Show the same

regards

Akshay

 

 

0 Kudos
Message 5 of 9
(3,112 Views)

There is no datatype with less than 8 bits, so typecasting will not help you here. If you want to split fractional bytes into individual U8 values, you need to mask and shift. Just create an inlined subVI that converts your array to the desired cluster. It's not difficult.

0 Kudos
Message 6 of 9
(3,106 Views)

@altenbach wrote:

There is no datatype with less than 8 bits, so typecasting will not help you here. If you want to split fractional bytes into individual U8 values, you need to mask and shift. Just create an inlined subVI that converts your array to the desired cluster. It's not difficult.


I'm terrible at masking, so I actually break them out as individual bits and deal with them that way.  It's less efficient code-wise, but for my personal efficiency it's not.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 9
(3,092 Views)

Are you working on a Windows, RT or FPGA target?

 

Only on FPGA can you actually define datatypes smaller than 8 bit.  But there is no typecast on FPGA, so I suppose that doesn't really help either.

 

Do masking and shifting or Byte to Boolean Array and index out the sub-arrays you need to parse them to U8.  Create coverter VIs for both directions and you should be fine.

0 Kudos
Message 8 of 9
(3,076 Views)

thank you all for your Support

 I am working on a  normal PC  no specific H/W. 

yes the normal methods , I will be implementing using those.

 

regards

Akshay

0 Kudos
Message 9 of 9
(3,068 Views)