Home    LBP Showcase / Reviews / Recommendations    Object Showcase
#1

Zero Latency Ana.logue Logic Toolset

Archive: 15 posts


http://lbp.me/v/zjrzp3

Equals
- Compares two analogue values, outputs 100% if they are the same, 0% otherwise
- Works with signed values
- Most likely won't work with super-normal signals
- Zero latency, outputs the value in the same frame it was input, gives it greater applications when dealing with continuously changing values

http://if.lbp.me/img/ft/34f784a77387597f58b688507b0145c11fa30381.jpg

Equals with Tolerance
- Works as equals but has 3 inputs - x, y and t
- 3rd input controls tolerance for x and y to be considered "equal"
- Symbolically, outputs 100% if |x-y|<=|t| and 0% otherwise
- Works with signed values, though t is taken as modulus
- Zero latency

http://i4.lbp.me/img/ft/954ef7c6f8b6fd27d5e6c4ef4279a16968e5f261.jpg
http://i9.lbp.me/img/ft/639c1480a21e8b70ecb10eade4986622e4fa46a0.jpg

Less Than (Less Than or Equals To)
- Compares 2 values x and y, outputs 100% if x<y (x<=y respectively) and 0% otherwise
- Works with signed values
- Less Than is just a Less Than or Equals To with the inputs swapped and the output inverted, but I've made both chips for convenience
- Zero latency

http://if.lbp.me/img/ft/e4f067a2b074c29d437e17514d52f028b65a6b93.jpg

Addition (Subtraction)
- Adds (subtracts) two values x and y
- Works with signed values
- Results that overflow are truncated at -100%/100%
- Thanks go out to rtm223, this is basically his implementation optimized
- Zero latency

http://i0.lbp.me/img/ft/49091393746037da3d731e0d6a89a3be06f813b4.jpg

Multiplication
- Approximates multiplication of two values x and y, treating 100% as 1.0
- Works with signed values
- Accuracy is around 1%, for specific values it is slightly higher
- Surprisingly low thermo (less than half a notch)
- And yes, zero latency - the multiplication is calculated within the same frame that the input is.

http://ic.lbp.me/img/ft/e6c75e88b2c8998380bb559a93f90fc089b14630.jpg
http://if.lbp.me/img/ft/75f019be58c54bb5cf1733da5e51c037dc28b5a7.jpg
2011-03-31 19:14:00

Author:
thor
Posts: 388


the logic is very good it looks like, and i only skimmed the post, but what could this be used for2011-03-31 22:23:00

Author:
septamus112
Posts: 82


the logic is very good it looks like, and i only skimmed the post, but what could this be used for

All kinds of things, someone just asked "how can I add some kind of dead zone for the sixaxis" and the solution is quite simple when you have these tools:
http://dl.dropbox.com/u/19532904/circuit.png

Generally people want to compare analogue signals all the time, like "I only want this to start spinning when the light is at 50% brightness" or "I want both the left stick AND the d-pad to control movement, how do I add their signals?" or "which counter is further along in terms of percentage complete?" These tools are actually more useful than some others like XOR because they're very hard to make simply and quickly (whereas XOR is simply made from other gates). Being zero latency means you don't have to worry about frame-delay caused by sequencers either. So you can know precisely if your timer has reached 50% yet or not. Now I'm not sure if multiplication has much use - but I'm sure there's one somewhere.
2011-04-01 00:06:00

Author:
thor
Posts: 388


Multiplication can be used for scaleing since it's inversion of divination, thru it might be too big for massive particle system or something, where thermo counts on lot of same objects2011-04-01 03:32:00

Author:
Shadowriver
Posts: 3991


Ok, Thor...could you possibly make a list of the potential practical applications of this system in laymens terms, because although I'm sure it's all highly impressive, the description in the original post makes absolutely no sense to me whatsoever. I'm sure that guys like Aya, comph and rtm know exactly what you're talking about, but for people like me who don't speak geek, it might as well be posted in Japanese. The dead zone for six axis is a good start, but what else can this be used for?2011-04-01 09:35:00

Author:
Ungreth
Posts: 2130


Ok, Thor...could you possibly make a list of the potential practical applications of this system in laymens terms, because although I'm sure it's all highly impressive, the description in the original post makes absolutely no sense to me whatsoever. I'm sure that guys like Aya, comph and rtm know exactly what you're talking about, but for people like me who don't speak geek, it might as well be posted in Japanese. The dead zone for six axis is a good start, but what else can this be used for?

Hmm well here are some ideas off the top of my head:

See who's winning
Each time someone scores in a multiplayer game, they increment their own personal counter. OK so by looking at it, you can see that player 1 has scored 5/10 and player 2 has scored 7/10. But how can you light up a sign to show who is currently winning? Well you want to light up player 1's sign if player 2's score is less than player 1's score, and vice versa for player 2.
http://dl.dropbox.com/u/19532904/winning.png
Note: Lights must be set to "dimmer" mode

Stepped brightness
You want a light to get brighter over time, but you only want a fixed number of brightness levels. Here's an example for getting brighter when the timer reaches 50% and 100%.
http://dl.dropbox.com/u/19532904/stepped_brightness.png

Convert a one-directional signal into a bi-directional signal
I want an object to move left and right, according to a timer. The timer moves left and right (it is set to forwards/backwards and inverted, and connected to itself), but when I connect it to a mover on the object via "speed scale" it only moves in one direction.
http://dl.dropbox.com/u/19532904/%5B0%2C100%5D%20to%20%5B-100%2C100%5D.png

Stealth Detector
Detect if the player moves the analogue stick too fast and sound an alarm if they do.
http://dl.dropbox.com/u/19532904/sneak.png
2011-04-01 22:33:00

Author:
thor
Posts: 388


Thanks Thor. That post made it so much clearer for me to understand the applications of your logic tool. It actually sounds like a pretty nifty piece of kit!

I built a stealth detector system for Tenement, implemented in the room where you encounter the ghost with the box on her head. If you run through the room she attacks, but if you creep slowly then she won't detect your presence. I'm not sure how I did it because I take a trial and error approach to logic....ie: I blindly mess around with stuff until it does what I want it to do. I wonder if the logic I used there might actually have been similar to the analogue system showcased here.

Anyway...good stuff. Very useful.
2011-04-02 11:38:00

Author:
Ungreth
Posts: 2130


I'm not going to have a chance to try this out for the next few days: would you mind giving an explanation of how the multiplication works? Like are you decoding the signal to binary and implementing multiplication with logic, or what?2011-04-08 18:42:00

Author:
tetsujin
Posts: 187


Hey, I just checked it out. Neat stuff. It's too bad your multiplication wasn't more accurate.

Anyways, I noticed the lack of division in your toolset, which makes me sort of happy. I drove myself nuts over the past two days creating my own multiplication and division systems. They aren't without latency, but they work very well. I can do multiplication of any unsigned signals with two digits to perfect accuracy. I didn't bother with sign, but implementation would be easy. XOR anyone?

At any rate, the reason that I even bothered with multiplication was because I came up with a solution to division. It's so simple it's not even fair (the X is my multiplication chip):

http://i9.lbp.me/img/ft/499b6ddb15fd18d861c254e1fcdb2677633fa0a3.jpg

Dividend is on top, divisor is on bottom. Currently it can only display answers less than or equal to 1.000 (by virtue of the signals that can go into my multiplication system). What happens is that the timer acts as a feedback loop. It's sort of a stupid system based on checking the timer's current state to see if it's correct answer. It multiplies the timer's signal value by the divisor and checks (using subtraction) against the dividend.

If the result is too low, the timer counts up. If the result is too high, the timer counts down. Thus, it's a recursive system that takes a little but of time to find an equilibrium (3 seconds max).

On the plus side, both it and my multiplication are dynamic, so it can be constantly working. In addition, they are both very low thermo. I hope I'm not the only one who is interested in this sort of thing...

N.B. - interesting choice going with binary on the multiplication. I went a different route, and it's working well: place value. Multiplication by 10 is simple enough. Division by ten takes a little bit more work (hence the latency issues). I basically used the distributive property of multiplication in conjunction with multiplication as repeated addition to get it to work. I broke everything down into single digit multiplication (e.g. 6 x 7), and then interpreted the results, applied the correct place value, summed where necessary, and displayed the result. I'm proud of the result, even if it's not instantaneous.



Edit: I'm sure I'll find a way to share my multiplication chip at some point.
2011-04-08 21:34:00

Author:
comphermc
Posts: 5338


I'm not going to have a chance to try this out for the next few days: would you mind giving an explanation of how the multiplication works? Like are you decoding the signal to binary and implementing multiplication with logic, or what?


Hey, I just checked it out. Neat stuff. It's too bad your multiplication wasn't more accurate.

N.B. - interesting choice going with binary on the multiplication. I went a different route, and it's working well: place value. Multiplication by 10 is simple enough. Division by ten takes a little bit more work (hence the latency issues). I basically used the distributive property of multiplication in conjunction with multiplication as repeated addition to get it to work. I broke everything down into single digit multiplication (e.g. 6 x 7), and then interpreted the results, applied the correct place value, summed where necessary, and displayed the result. I'm proud of the result, even if it's not instantaneous.



Well I went for a binary multiplier because I was able to find optimized circuit diagrams online for such a thing. I think I found a good trade-off between thermo/accuracy but the real reason I went for 6-bit accuracy was because I could simply copy the circuit diagram for the "Dadda multiplier" that I found and it worked straight away (rather than having to follow the algorithm for constructing the circuit). So yes here's how it works entirely:

First the two values are converted into 6-bit binary, multiplied bitwise and then combined with a dadda multiplier, and finally converted back into analogue. The dadda multiplier is a clever way of combining the 36 values you get from bitwise multiplication into the full multiplication by arranging adders in just the right way.

I realised that it is simple to prove that the partial derivative of the output of any zero-latency microchip with respect to one of its inputs is a constant integer (or else is undefined). This is because you're effectively limited to using direction splitters, direction combiners and OR gates in series along with fixed constants (disregarding weird digital behaviour of other gates such as the AND gate, they can all be built from these 3 gates). This means you have to discretize your input space and give each section a constant integer partial derivative. In the case of multiplication, the partial derivative wrt one variable should be the other variable, meaning it's in the range 0-1. So effectively I just rounded the partial derivative to the nearest integer, meaning when one value is over 0.5, I add on a linear term from the other variable (it's actually the remainder from the analogue-to-binary conversion). This actually gives quite a bit of extra accuracy.

Sign is handled separately and is put in at the end.



At any rate, the reason that I even bothered with multiplication was because I came up with a solution to division. It's so simple it's not even fair (the X is my multiplication chip):

Dividend is on top, divisor is on bottom. Currently it can only divide if the dividend is larger, and it only has two digits of accuracy (by virtue of the signals that can go into my multiplication system). What happens is that the timer acts as a feedback loop. It's sort of a stupid system based on checking the timer's current state to see if it's correct answer. It multiplies the timer's signal value by the divisor and checks (using subtraction) against the dividend.

If the result is too low, the timer counts up. If the result is too high, the timer counts down. Thus, it's a recursive system that takes a little but of time to find an equilibrium (3 seconds max).

On the plus side, both it and my multiplication are dynamic, so it can be constantly working. In addition, they are both very low thermo. I hope I'm not the only one who is interested in this sort of thing...


Looks very good... I think you've beaten my attempt (https://lbpcentral.lbp-hub.com/index.php?t=53559-How-to-divide-analogue-signals) because mine suffered a bit from the limitations of the joystick rotator. Mine is probably lower thermo though owing to not having to use a multiplication chip. Your solution is very elegant actually. What's its behaviour when the result should be >1?
2011-04-09 12:12:00

Author:
thor
Posts: 388


What's its behaviour when the result should be >1?

Kerplosion.

Nah, it just displays 1.000, currently. Since it checks using multiplication, it just starts counting up, and when it reaches 1.000 is can't count any higher (timer limitations). Admittedly division is very slow since when it gets close to the answer, the value of the subtractive difference that drives the timer gets small, and the increment speed drops significantly. There are theoretical ways of speeding up the calculation, which can be as simple as multiplying the subtraction result by 10 (or some other constant).

Hell, I could make a system that is a bit more dynamic, but I'm not really sure at this point what would be effective and/or accurate.

Lastly, I noticed last night that division is really only an approximation. It's not a bad approximation, but something like 2/10 will output .195x, which is close enough for me. Because of the recursive/feedback nature of the system, the last 1 or 2 digits flicker between values (and I was just using phorts 4-digit probe). My motivations for sorting out division is that a friend of mine is planning to make an RPG that makes use of a chance to hit formula. I don't recall what it was, but it uses both multiplication and division. Thus, an approximation is fine, since the player never actually sees the calculations.
2011-04-09 13:13:00

Author:
comphermc
Posts: 5338


I like the way you check if it's equal! It's kinda ingenious..

I've modified your less-than-equal switch a bit.. Since I don't care about signed values for my project.
http://cl.ly/1k1F1d2S3A2H2q0H0G2l/bigger-equal.png
(Please forgive my extremely quick sketch )


... My motivations for sorting out division is that a friend of mine is planning to make an RPG that makes use of a chance to hit formula. I don't recall what it was, but it uses both multiplication and division. Thus, an approximation is fine, since the player never actually sees the calculations.

Well nowadays, it only needs divison.. Though I might add an extra step to bring the player with the higher level a small advantage. And that requires multiplication with variables.
The complete formula for "chance to hit" is: (ATT/(ATT + DEF)(2ALVL/(ALVL + DLVL)
Which might bring some difficulties because your solution only divides with a smaller divisor than the divident.

BTW: This is a quite known formula for "chance to hit" and I've only modified it slightly... I think it is the one that's used in Diablo II.

Hmm, I might revisit "my" solution.. and make it faster, by putting in some optimization. Should be able to make it calculate with just a few frames..
2011-04-11 12:30:00

Author:
Tamland
Posts: 106


For some reason, the equals chip wasn't working for me. I hooked up a 1% battery and a 2% battery and it said that they were equal. 2012-03-30 03:52:00

Author:
Unknown User


I am so very completely and utterly ****ing confused lol. Like, off the charts scale mind blown followed by wtf are all of you saying?...

But awesome work, I think

You just lost me from the start. I'll just stick with "ooh, cool pictures!" and then go cry about how hard I failed at programming.
2012-06-07 16:05:00

Author:
hellfire
Posts: 78


This would help me so much with my level! Espcially with my factor system like happiness XD2012-06-09 08:04:00

Author:
waaghgork
Posts: 160


LBPCentral Archive Statistics
Posts: 1077139    Threads: 69970    Members: 9661    Archive-Date: 2019-01-19

Datenschutz
Aus dem Archiv wurden alle persönlichen Daten wie Name, Anschrift, Email etc. - aber auch sämtliche Inhalte wie z.B. persönliche Nachrichten - entfernt.
Die Nutzung dieser Webseite erfolgt ohne Speicherung personenbezogener Daten. Es werden keinerlei Cookies, Logs, 3rd-Party-Plugins etc. verwendet.