LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem facing on conversion of decimal number to binary number

I tired the circuit shown in first figure below using a for loop. It works well for well till the input is 511 as shown in second figure but when the number is increased above it, or iteration are increased it results incorrectly as shown in third figure 

 

1.

sasimitha_3-1715839442336.png

 

2.

sasimitha_4-1715839496533.png

 

3.

sasimitha_5-1715839554439.png

 

 

 

0 Kudos
Message 1 of 11
(809 Views)
  • It is not a "circuit", but a picture of block diagram. We cannot run pictures, so attach the VI instead.
  • There should not be any orange anywhere
  • You need a while loop because you don't know the number of iterations needed.
  • You are not converting to binary, You still have a decimal number, but are only using the digits 0 and 1. That's not the same value as the input.
  • You should clean up your code instead of having wires going in all directions
  • Whatever you are trying to do will fit on a quarter postage stamp. It can be done in one step If you set the integer indicator to binary display format, all you need is a wire.

 

altenbach_0-1715840369784.png

 

0 Kudos
Message 2 of 11
(806 Views)

@altenbach wrote:
  • You are not converting to binary, You still have a decimal number, but are only using the digits 0 and 1. That's not the same value as the input.

As a simple programming exercise, here's something similar that takes an integer and converts it to a decimal number that looks the same as the binary representation of the input. Seem silly!

 

There are many other ways to do that, though...

 

altenbach_0-1715842286947.png

 

Message 3 of 11
(778 Views)

I attached my vi below , how should not be any orange anywhere

0 Kudos
Message 4 of 11
(775 Views)

sasimitha_0-1715858628117.png

Tried the solution in LABVIEW 19.0 Version, but output is not as expected

sasimitha_1-1715858780083.png

 

0 Kudos
Message 5 of 11
(725 Views)

Just another solution:

dkfire_0-1715862933998.png

 

0 Kudos
Message 6 of 11
(710 Views)

@sasimitha wrote:

... how should not be any orange anywhere


Because you are dealing with integers exclusively. There are no fractional bits. Your lower shift register is I32 and after multiplying with 10 N times, you are hitting the ceiling.

0 Kudos
Message 7 of 11
(696 Views)

@sasimitha wrote:

 

Tried the solution in LABVIEW 19.0 Version, but output is not as expected

 


Obviously, you made a mistake but unless you attach your new VI attempt, we cannot help you troubleshoot. We cannot run your picture!

 

(Also note that I was using U64, not I64, but that should not make a difference. What is the datatype of the diagram constants?)

0 Kudos
Message 8 of 11
(694 Views)

Note that even my solution will not work if the input is large, because even U64 can only have about 20 decimal digits or less, but you can have up to 64 bits in the input.

 

As long as you stay withing these limits, even this will work:

 

altenbach_1-1715869901967.png

 

 

 

0 Kudos
Message 9 of 11
(676 Views)

Do you want it as a number or as a string of 0's and 1's? If string, you can do like this:

Yamaeda_0-1715871218068.png

 

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 11
(666 Views)