Forums - Open Redstone Engineers
Analog to Binary Conversion - Printable Version

+- Forums - Open Redstone Engineers (https://forum.openredstone.org)
+-- Forum: ORE General (https://forum.openredstone.org/forum-39.html)
+--- Forum: Tutorials (https://forum.openredstone.org/forum-24.html)
+---- Forum: Advanced Tutorials (https://forum.openredstone.org/forum-26.html)
+----- Forum: Concepts (https://forum.openredstone.org/forum-28.html)
+----- Thread: Analog to Binary Conversion (/thread-3578.html)



Analog to Binary Conversion - Legofreak - 05-21-2014

We all know how to convert binary to analog. It is simply subtracting/adding the values 8,4,2, and 1 to a line of comparators.

When it comes to converting analog to binary, it is a bit more difficult.

There are two kinds of conversion that I know of:
1. get a single output from the analog and then decode it from there.
or
2. Logically process the analog signal.

I'll try to go over both.


Table Decoder
This design is big, but is easy to understand and also easy to sync the outputs.

First you need some kind of analog selector. This takes the analog signal and gives a single output among 15 lines.

Second you need to hook up a decoder to the selector. depending on the output of the selector, the decoder will display the correct binary value which you have laid out(normally with torches).


Logic Decoder
This design involves using the compare and subtract functions of the comparator to get the desired result. It can be confusing but once you get it, it makes a lot of sense.

There are 2 lines of comparators in this: a logic line, and a bypass line.
First, you take the incoming signal and compare it to a value of 8. If its less than 8, the signal will be ignored and pass through the bypass comparator. If its 8 or more, it will pass through that comparator and make some things happen. It disables the bypass, displays a 1 in the 8s place, and sends the signal on through a comparator to subtract 8.

The logic line is then reconnected with the bypass line and the process is repeated with values 4 and 2.

After all 3 processes, the only possible leftover is 1, so you don't need to have a process for that. Just combine the lines after the 2 process , put a repeater on it, and there's your 1s place.

Here's a block diagram I drew up in autocad for reference.
[Image: ana2binblock_zps5a1b39ec.png]
You can also subtract from the bypass instead of having a separate comparator to subtract from.

I hope this is informative. I know analog isn't very popular here but its my favorite subject in redstone.


RE: Analog to Binary Conversion - Chibill - 05-22-2014

Nice I might be able to adapt this in to ACD to make a esaier way to decode binary to ACD and ACD to binary.


RE: Analog to Binary Conversion - Legofreak - 06-03-2014

Here's the new 2-tick technique I developed recently. I'm not sure what to call it.

Input strength determines how far the signal goes through the dust line. Comparators are used to turn off outputs when needed. Any repeaters going into side B of a comparator must disable that comparator. All outputs of the same value are OR'd together.
[Image: ana2bin2block_zps91e5684e.png]