LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hex to Binary Zero stuffing

How i would i revise the attached VI so that it would incorporate zero stuffing. For example when 7E is entered how do I place a zero after the 5th 1.

Thanks

0 Kudos
Message 1 of 8
(3,858 Views)

Don't understand. There are the correct number of zero's shown in the numeric indicator and a false in all the correct positions in the Boolean array (which has 6 '1's', not 5) with 7E entered.

0 Kudos
Message 2 of 8
(3,842 Views)

I guess you are talking about this?

 

If you operate on the boolean array, a simple "insert into array" of a FALSE element would probably do.

0 Kudos
Message 3 of 8
(3,826 Views)

If you have "FF" 1111 1111 it is supposed to 1111 10111 with zero stuffing. does this help?

0 Kudos
Message 4 of 8
(3,805 Views)

You can't do bit stuffing like that with computers. Computers deal with bytes, not bits. That means that you have to "insert a bit" yourself by performing byte manipulations. You can do it the way you're doing it by using Insert Array as Altenbach suggested, and then converting the Boolean array back into a number whose datatype is one step larger than what you started with. In your case you started with a U8, so after the bit is inserted you'd end up with a U16.

 

Another way you can do is to do Boolean manipulations directly on the numbers. Essentially this involves OR'ing the number with a number that has the zero/one where you want it. You need to make sure both values are of the same datatype (i.e., the larger datatype you're going to end up with).

 

Note: You do not need to use a string to enter a hex value using alphanumeric characters. Just use a numeric control and set the properties to display the value in hex.

0 Kudos
Message 5 of 8
(3,780 Views)

Typically, such operations are done on a long stream of data.

 

All this can be done very efficiently using techniques used in the old bit twiddling challenge. Have a look at the results discussion for some ideas. You definitely don't want much green on the diagram. 😉 

0 Kudos
Message 6 of 8
(3,759 Views)

Can anyone help me get started I cant seem to get anywhere on this?

Thanks

0 Kudos
Message 7 of 8
(3,729 Views)

 


@Cummins99 wrote:

Can anyone help me get started I cant seem to get anywhere on this?


 

What exactly is "this"?

How long are your data streams?

Do you need to code for the encoding or decoding side, or for both?

What datatype do you need for the input and output?

What should happen if the resulting data does not exactly fit into multiples of bytes?

0 Kudos
Message 8 of 8
(3,720 Views)