From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Decimal to binary two's complement

Solved!
Go to solution

Hello!

I want to convert a decimal number (from -32768 to 32767) into a 16 bits Binary two's complement.

Any suggestion? 

Thank you in advance!

0 Kudos
Message 1 of 7
(3,844 Views)

What is the datatype of the "decimal number"? A I16 numeric integer? A decimal string?

What output do you want? (binary string? I16 numeric?) What is the byte order? 

 

It always helps to attach a small VI containing your input in a diagram constant to avoid ambiguities. Thanks!

0 Kudos
Message 2 of 7
(3,835 Views)

Hi,

I have a dac714 which is designed to accept binary two’s complement input codes with the MSB first. The output voltage range I want to obtain is ±5 V. What I am doing is to convert voltage values (DBL control, so that the user can select the desired voltage) into decimal values from -32768 to 32767 (DBL). What i want to get is a 1D array of boolean that goes in a digital output of my  usb 6211 and then into the dac.

I hope I was clear.

(I don't attach my VI because this is a small part of a very crowded one, I try to simplify it and attach later a simpler version)

 

Thank you

0 Kudos
Message 3 of 7
(3,811 Views)

Here is a simpler version of what I did so far. The conversion here is from digital to binary, what I wish is from digital to binary two's complement.

Download All
0 Kudos
Message 4 of 7
(3,801 Views)
Solution
Accepted by topic author Giulia30

Your code makes absolutely no sense.

 

Maybe this can give you some ideas.

 

Bits16.png

Message 5 of 7
(3,788 Views)

Thank you. 

 

0 Kudos
Message 6 of 7
(3,777 Views)

@Giulia30 wrote:

What i want to get is a 1D array of boolean that goes in a digital output of my  usb 6211 and then into the dac.


Stupid question: Why not just use an Analog Output on the USB-6211?  Or is the DAC714 the UUT?


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 7 of 7
(3,699 Views)