LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Inverting a Binary String

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!

0 Kudos
Message 1 of 22
(6,142 Views)

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.


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 2 of 22
(6,133 Views)

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.

 

use xor.png

 

0 Kudos
Message 3 of 22
(6,123 Views)

See attached VI.

 

George Zou
0 Kudos
Message 4 of 22
(6,120 Views)

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!

0 Kudos
Message 5 of 22
(6,082 Views)

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

0 Kudos
Message 6 of 22
(6,081 Views)

@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.

0 Kudos
Message 7 of 22
(6,064 Views)

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.

 

 

Kudos and Marked as Solution == Thanks
0 Kudos
Message 8 of 22
(6,041 Views)

NOT the number to invert it, AND with 7FFFF to 'truncate' to 19 active bits (all above will be 0's).

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 22
(6,032 Views)

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.

0 Kudos
Message 10 of 22
(6,027 Views)