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,847 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,838 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,814 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,804 Views)
Solution
Accepted by Giulia30

Your code makes absolutely no sense.

 

Maybe this can give you some ideas.

 

Bits16.png

Message 5 of 7
(3,791 Views)

Thank you. 

 

0 Kudos
Message 6 of 7
(3,780 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,702 Views)