Page 1 of 1

Binary Decoder

Posted: Sun Nov 27, 2016 8:10 pm
by Endus322
Ive been looking at all the binary decoders, but not a single one has shown fully what they have done? Ive seen a design with two constants, and an arithmetic, but they dont show the second constant or the arithmetic. Im not sure if it still works, but I would like to know what is in the arithmetic and constant. - Endus322

Re: Binary Decoder

Posted: Mon Nov 28, 2016 2:57 am
by DaveMcW
The constants are 2^n, the arithmetic is EACH * Input. The result is negative numbers for 1, and positive numbers for 0.

Re: Binary Decoder

Posted: Mon Nov 28, 2016 10:34 pm
by Endus322
DaveMcW wrote:The constants are 2^n, the arithmetic is EACH * Input. The result is negative numbers for 1, and positive numbers for 0.
so one constant is set to my binary number, what do i set as n. Arithmetic is set to each * blue (blue is binary number), what item do i do for the 2^n

Edit: Do i set the lamps to = 1,2,4,8,16,32 ect, and start from the right side?

Re: Binary Decoder

Posted: Mon Nov 28, 2016 11:03 pm
by DaveMcW
You need 32 constants, from 2^0 to 2^31.

Re: Binary Decoder

Posted: Wed Aug 23, 2023 9:34 pm
by frequentPhoenix
These topics give me the same confusion. This is some help, but still. Is one constant the "target number" and the other the "2^n" constants? like actually typed out, 0, 1, 2, 4, the rest. Do they all have to be the same signal?

Working blueprint or picture with details much appreciated.

Re: Binary Decoder

Posted: Fri Aug 25, 2023 4:30 pm
by Premu
Hm, what exactly do you want to achieve? Which problem do you want to solve?

In general:
To set a single bit in a signal, you have to do a bitwise OR with the appropriate number (meaning 1,2,4,8,etc. - it has to be 2^n)
To check if a bit is set, you have to do a bitwise AND with that number.

StilI it's important to know what you want to actually do. I use a bitwise signal to activate target stations for my recycling train based on the trains content, for example. But my solution might not work for you at all.