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: 

2's complement

Hi anyone got any nice ways of converting 12bit 2's complement into its decimal format?
0 Kudos
Message 1 of 22
(25,443 Views)

Hello Paul,

I hope, I that I understood right.

The VI in the attachment creates the 2´s complement and shows the decimal value. It´s for 8 bits.

 

Regards ThomasD

0 Kudos
Message 2 of 22
(25,409 Views)
Hello PaulMc,

here is my solution to converting 12 bit Two's complement to decimal.

I hope I did not make any faults 🙂

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 22
(25,385 Views)
Hi,
Here is my solution.
 
Xu 
Message 4 of 22
(25,364 Views)
Hello Xu,

your solution seems to have problems with negative numbers...

I included a similar method to yours in my example.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 22
(25,344 Views)

Hi guys

GerdW your solution worked best.

My own solution had a problem with 0x800, it would equal 0 and not -2048, but all other values worked.

Cheers

Message Edited by PaulMc on 10-25-2005 02:47 AM

0 Kudos
Message 6 of 22
(25,342 Views)
Hi guys,
 
one more try - dac12bit.vi............ - used as sub.vi  for  12 Bit ADC  MAX168 
with possibility to decide, if the IC is used in unipolar or bipolar mode. 
 
Find it in Diagram of MAX168.vi   ( controlled via LPT - Port ).
 
Regards
Werner
Download All
0 Kudos
Message 7 of 22
(25,310 Views)

Hi GerdW,

You are right, My vi was wrong. I forgot to set the default values of the "32-bit" controls on the frontpanel to FALSE.

Try this corrected one, please. Hope no error this time.
Thank you,
Xu

0 Kudos
Message 8 of 22
(25,285 Views)
Did I modify this correctly to work with 16 bits?
0 Kudos
Message 9 of 22
(25,193 Views)
sorry Christian,
 
if you would send your code again ....- with   LV 7.1 code attached
 
not everybody around has already upgraded to LV8
 
Werner
0 Kudos
Message 10 of 22
(25,182 Views)