12-08-2010 07:21 PM
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
12-08-2010 09:22 PM
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.
12-09-2010 01:53 AM
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.
12-09-2010 07:04 AM
If you have "FF" 1111 1111 it is supposed to 1111 10111 with zero stuffing. does this help?
12-09-2010 09:07 AM
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.
12-09-2010 11:08 AM
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. 😉
12-10-2010 05:05 PM
Can anyone help me get started I cant seem to get anywhere on this?
Thanks
12-10-2010 05:27 PM
@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?