PDA

View Full Version : How to multiply Analogue values (range 0-100)



Loius
03-11-2011, 04:40 PM
Here's an LBP.me link to a copyable level including the multiplier as a prize:

Analogue Multiplier (http://lbp.me/v/ysny7p)

Turns out it's not too horribly difficult. Thanks to RTM for huge logic blog!

Here's what does the magic:
http://i116.photobucket.com/albums/o16/LoiusAllieran/LBP/APhoto_2.jpg
Stick this chip on a small Holo square (or material of your choice).

On the bottom left is a clump of boxes - the two on the left are Timers, the two on the right are single-count, self-resetting Counters - that is, they're Pulsers.

Both timers are 0.1 seconds. The top one is inverted and its input mode is Count Down. The other is not inverted and its input mode is Count Up. Each timer activates the other and resets itself. This setup sends one pulse alternating between top & bottom every 0.1 second.

The follow follows RED tag, speed 100.0, accel 100%. The mover is Speed 30.0, Accel/Decel 100%, set to Speed Scale input mode.

The GREEN tag is for detecting output.

The two input lines are your values to multiply as percentages - 100% * 50% = 50%; 1% * 50% = 0.5%.

Well that does nothing. Fancy! Wait, let's add a couple things:
http://i116.photobucket.com/albums/o16/LoiusAllieran/LBP/APhoto_1.jpg
A RED tag (for the follower to follow), and a GREEN Sensor - min range 0.1, max range 10.0, output closeness. The RED tag should be exactly one large grid square from the Sensor.

The chip visible in that picture is the chip from up above attached to a bit of chrome (its movers prevent it from moving)

If you run the chip now (and hook its output to a display of some kind), you'll see it's only outputting a value for 0.03 of a second. Well, if you need a constant signal, that's just a bit more work:

http://i116.photobucket.com/albums/o16/LoiusAllieran/LBP/APhoto-1.jpg
The Selector is a 6-stager set to increment itself - stages 2, 4, and 6 activate toggles, each of which activates a different copy of the multiplier from above. This gives the chips an offset so they each run on a different 1/30th of a second. The OR gate takes all three outputs from the multipliers and outputs a constant result. Is a thing of beauty.

One caveat is that this system is incapable of calculating multiples of 99.1-100. If either input is 99.1 or higher, the output will be zero. This is a limitation in sensors themselves, but since you can write a special case for 99.1*99.1 = 100 and add that to the OR. (If you need precision in that range... ask RTM. xD)

This system is accurate to two decimal places, and generally close in the third.

Again, thanks to RTM233 for the wonderful logic blog.

waD_Delma
03-12-2011, 07:18 AM
Why don't you turn those moving things to holo and place them to same place? I tried that and it removes changing of last decimals.

Loius
03-12-2011, 08:41 AM
I tried holo originally, but I changed it... for some unknown reason. xD
I wonder if that gets rid of the inaccuracy, too...