11-07-2017 11:04 AM
Morning Everyone,
I need to convert a 19 bit binary string into 1's compliment. (I think that's the right nomenclature?)
E.G. I need 1111111110000000010
To become 0000000001111111101
I have added a picture of my code.
For those curious. I am processing 32 bit ARINC-429 format words from avionics. Specifically, I am using case structures for the temperature and pressure altitude words. The sign bit is the 19th bit, and the data switches the 0s to 1s and 1s to 0s. I need to reverse this so I can convert it into my new negative engineering unit.
Thanks everyone!
11-07-2017 11:28 AM
Is there a reason you can't just act on the integer value before your Scan Into String? It would be super simple there to just add in a NOT.
11-07-2017 11:48 AM
It all depends what you want to do. If you are only interested in the lower 19 bits, then use the NOT as crossrulz suggested. If you do care about the upper 13 bits and don't want them to change you can always use an XOR with the appropriate mask.
11-07-2017 11:48 AM
See attached VI.
11-07-2017 03:51 PM
What is going into the top of that XOR gate? I have never seen a blue box with a small x in it? Also, what is the significance of the "0007FFFF"
Thanks!
11-07-2017 03:53 PM
This is very close to what I need. The problem with this is I get a full 32 bits. 19 bits of data plus an additional 13. Since I am converting all the zeros to 1s these padding zeros show up as ones, and my binary to decimal conversion is thrown off.
Any idea how I can truncate these 13 bits off the data to get back to 19 bits? My %19b in my format box doesn't seem to be doing what I thought it would.
Thanks
-Dave
11-07-2017 05:03 PM
@lavid2002 wrote:
What is going into the top of that XOR gate? I have never seen a blue box with a small x in it? Also, what is the significance of the "0007FFFF"
Thanks!
Right click on a U32 constant and make the Radix visible.
11-08-2017 03:53 AM
you can just convert the integer to array of boolean and use array palatte to truncate it .
but i think using mask as jamiva mention is better.
11-08-2017 05:10 AM
NOT the number to invert it, AND with 7FFFF to 'truncate' to 19 active bits (all above will be 0's).
/Y
11-08-2017 06:41 AM
Just plugged this in on my desktop, and it looks like what I need. I'm going to go try it on the airplane now.