Home    LittleBigPlanet 2 - 3 - Vita - Karting    LittleBigPlanet 2    [LBP2] Everything Else LittleBigPlanet 2
#1

Simulating LBP2's Logic on a Computer using Logisim

Archive: 17 posts


With me not being in the beta to play with things for real, I've been wanting some way to plan out some things to do with LBP2's logic on my computer.

I was initially doing this with Logisim (http://ozark.hendrix.edu/~burch/logisim/)'s basic gates, and even made some circuits to simulate how LBP2's Toggle, Selector and Counter work.

Then I read rtm223's post explaining the way the gates deal with analog signals (http://www.lbpcentral.com/forums/entry.php?2069-Analogue-Logic-1-Fundamentals), and my mind was blown.

I'm now working on building circuits in Logisim from the ground up that deal with LBP2's A/D duality. I'm also making them look more or less like LBP2's actual circuits (at least, as much as I can with Logisim's limited drawing tools), as shown here:
http://balorn.com/lbp2/logicpics01.png

There are some questions that have arisen while doing this, though:
How, exactly, does XOR deal with analog inputs? I understand it acts similar to OR but then does something to combine it with the digital signal, but I don't know any details.
Do the combiner and splitter do anything with the digital part of the input, or can it be effectively ignored and then reconstructed from what the analog output will be?
For a purely analog input (from the analog stick, for example), what is the threshold where the digital part becomes On? I'd guess 50% but it would be nice to know for sure.
Does the battery always output digital On, or does the digital part only count as On beyond a certain threshold?
How does the Selector deal with analog?
Is the sign of the digital part of the signal always the same as the sign of the analog part, or is there some situation where they could be different?


Anyway, here's what I've currently implemented:

Functions to make a digital and "analog" (-100 to +100, as an 8-bit signed integer) dual signal wire and split it back out when needed - the maker can take both A and D, or can make the other part given just one (for example, if Digital 1 is the only input, it will make the analog part +100), and will limit the analog input to within -100 to +100 if it is outside that range
NOT, AND and OR circuits that (as far as I can tell) work exactly as described by rtm223 for both the analog and digital parts of the signal
XOR function that currently only deals with the digital part of the signal (the analog output is set to 0 or 100) until I get details on how to build the rest
Combiner that works for analog and I think works for digital
Splitter that currently works for analog and ignores digital


Next I'll probably work on a Timer (which will need to have Max, Speed and Clock inputs on top for due to how Logisim works, but should be doable) and then maybe the Selector, if I can find out how it deals with analog. I'll release it once I've confirmed how some things work and clean it up more.
2010-10-26 08:31:00

Author:
Balorn
Posts: 92


I have been looking for a program that can be used to create/simulate LBP2 logic.

I am going to download that asap. Hopefully I can get a hold of how to use it.

Sorry I cant answer any of your questions.
2010-10-26 08:46:00

Author:
TheAffected
Posts: 626


Keep in mind out of the box Logisim isn't LBP2-specific, but the basic gates can be used if you don't care about the analog part of things or LBP2's absurdly powerful Selector/Timer/Counter/etc.2010-10-26 09:08:00

Author:
Balorn
Posts: 92


Yeah I read before I downloaded that it is a program that is for students. I understood that it isn't LBP2 specific but I can defiantly use the basic gates, and when I figure it out, recreate the analogue.2010-10-26 09:17:00

Author:
TheAffected
Posts: 626


...recreate the analogue.
That's what I'm working on actually

After all, do you really want to have to build (and debug) something like
http://balorn.com/lbp2/logicpics02.png
when someone has already done it for you?


(That's the current version of my MakeDual circuit, if anyone's curious.)

Also, according to rtm223, the "digital" parts, while mostly 0 or 1, can technically also be -1, meaning the digital part of it is really running on a variation of balanced ternary (http://en.wikipedia.org/wiki/Balanced_ternary), which Logisim doesn't handle natively (just as well, actually, since many, but not all, LBP2 circuits drop the sign anyway).
2010-10-26 09:33:00

Author:
Balorn
Posts: 92


Are you able to share stuff you have created on the program??2010-10-26 09:39:00

Author:
TheAffected
Posts: 626


My initial attempt, which includes digital-only emulator circuits for the Toggle, Selector (4 inputs but stackable to more) and Counter can be downloaded here (http://balorn.com/lbp2/LBP2%20Logic.circ).

The new version I'm working on with full analog duality support I don't consider functional enough to share since I'm not sure how several things actually work yet.
2010-10-26 09:47:00

Author:
Balorn
Posts: 92


Dude you are awesome. 2010-10-26 09:55:00

Author:
TheAffected
Posts: 626


So apparently Logisim's drawing tools don't actually always save everything properly, so after saving and then reloading my work-in-progress dual analog-digital project the graphics became horribly broken (http://balorn.com/lbp2/logicpics03.png).


Unless/until that's fixed, I'll have to live with approximations that don't really look as close as I'd initially hoped.
2010-10-26 11:37:00

Author:
Balorn
Posts: 92


Do you tried make color inverted icons so it will have less black to draw?

Oh and not A/D, rtm is right i called it wrong, "Analog signal processing" would be better name
2010-10-26 13:02:00

Author:
Shadowriver
Posts: 3991


See edits in red:


There are some questions that have arisen while doing this, though:
How, exactly, does XOR deal with analog inputs? I understand it acts similar to OR but then does something to combine it with the digital signal, but I don't know any details.It does a min() function on the analogue signals and then passes that value through, if the digital output is equal to 1. I think. I don't know what it does with negative digital inputs. I'm sort of leaving it alone in terms of analogue processing as I'm not comfortable with the way the function behaves.
Do the combiner and splitter do anything with the digital part of the input, or can it be effectively ignored and then reconstructed from what the analog output will be? Yes. The combiner works as a digital subtractor and the splitter will still split out positive and negative digital signals. You absolutely cannot reform it from the analogue signals:
The combiner goes to FALSE if both inputs are TRUE. It's still essentially a subtraction circuit, but with ternary digital output:



- | + | out
---|---|------
0 | 0 | 0
0 | 1 | 1
1 | 0 | -1
1 | 1 | 0


It's very similar to the XOR, just that you get that negative 1 output from it. The idea really of this device is to replace the three-way switch with winches on control method, but it has a more strongly defined output for when both inputs are active.

For a purely analog input (from the analog stick, for example), what is the threshold where the digital part becomes On? I'd guess 50% but it would be nice to know for sure. Analogue sticks and the analogue triggers have a threshold which I think is around 20%. There is also probably some notion of hysteresis in there. I've been meaning to get a probe on those controls and measure it but keep on forgetting.
Does the battery always output digital On, or does the digital part only count as On beyond a certain threshold? Always on, unless it's at 0%. Pretty sure negative percentages output a negative digital signal as well - will add to list of things to probe
How does the Selector deal with analog?It ignores it on inputs, outputs are always at 100% or 0%
Is the sign of the digital part of the signal always the same as the sign of the analog part, or is there some situation where they could be different? They are not inherently linked at all. If at any point they are the same it is simply coincidence.


Anyway, here's what I've currently implemented:

Functions to make a digital and "analog" (-100 to +100, as an 8-bit signed integer) dual signal wire and split it back out when needed - the maker can take both A and D, or can make the other part given just one (for example, if Digital 1 is the only input, it will make the analog part +100), and will limit the analog input to within -100 to +100 if it is outside that range For extensibility, I'd suggest implementing as a 32 bit signed int and scaling up by at least 1000. So that a value of 1% is encoded as 1,000%. Especially in the timer, your circuits will break if you assume that granualrity is 1%
NOT, AND and OR circuits that (as far as I can tell) work exactly as described by rtm223 for both the analog and digital parts of the signal


Next I'll probably work on a Timer (which will need to have Max, Speed and Clock inputs on top for due to how Logisim works, but should be doable) and then maybe the Selector, if I can find out how it deals with analog. I'll release it once I've confirmed how some things work and clean it up more.
2010-10-26 13:11:00

Author:
rtm223
Posts: 6497


Yeah, I'm going to make white-on-black icons and see if those save/load better. (Edit: Nope. Resorting to boxes with words for now.)

And what I'm doing actually is technically A+D, not just "analog signal processing", since my goal is to have these properly simulate both the analog and digital parts of LBP2's logic exactly as LBP2 itself does.


For extensibility, I'd suggest implementing as a 32 bit signed int and scaling up by at least 1000. So that a value of 1% is encoded as 1,000%. Especially in the timer, your circuits will break if you assume that granualrity is 1%
Noted. Due to limitations of Logisim, I'll have to limit it to 30 bits if I want it carried on the same wire as the digital signal (which is my major goal here), but an effective range of around +/- 536,870,911 should be enough for reasonably accurate simulation. =P

I'll probably also make subcircuits that will drop the 30-bit down to a much more usable +/-1000 (1=0.1%) to make seeing/setting things easier, but have all the circuits still deal with the maximum precision whenever possible.

----
Edit: Done and tested, seems to behave as expected. I extended all the logic up to 30 bits on the analog side (digital is still 2 bits: signal and sign). I also made a circuit that takes an input (+/- 0x3e8 or optionally +/- 1000 as BCD) and multiplies it out to 30 bits, and another that takes the 30 bit +/- 0x1fffffff and compresses it back down to +/- 0x3e8 (no BCD on the output; it's just for display and Logisim can handle that natively with a probe), and confirmed there don't seem to be any rounding errors with a half dozen different random inputs. I also made the analog side of XOR and the digital side of the Combiner act as rtm223 described them (thanks again!).

Now to sleep... once I get up I'll see about making the Timer, and if I get that working I'll share what I have so far. The Selector, at least, will be trivial since it ignores the analog side and I already made a digital-only version of it I can just copy-paste and fiddle with the I/O pins (and believe me, that's a mess I'd rather not rebuild if I don't have to).
2010-10-26 13:47:00

Author:
Balorn
Posts: 92


OK, Controlinator results:

The controlinator's digital component for the analogue sticks switches on at 75% and off again at 25%, which is a hell of a lot of hysteresis. It also handles digital negatives.

The R2 / L2 just switch on at >1%

The rest of the buttons (the pressure-sensitive ones) have basic on/off 0% / 100% outputs, as the pressure sensitivity is not supported by the controlinator.

A note on digital negatives BTW. There are 2 versions of zero. Only directional type signals can tell the difference, but depending on what the signal source is, the zero is either interpreted as "go backwards", or "stay still". So realistically, you have four states in there to deal will, but you can fudge that into your 2 bits of data when you get around to it.
2010-10-26 22:05:00

Author:
rtm223
Posts: 6497


How does this handle feedback loops? Do we know it does it in a way similar to LBP2? Then we could experiment to see whether the equilibrium state of a feedback loop system resulted in some useful result (the multiplication of two values, for instance). (Note: There is logically no way to create a multiplication function given the basis functions available - f(x,y)=xy is not in span<max(x,y),min(x,y),|x|-|y|,x.dt> This does not preclude solutions using some kind of feedback. Also a rather simple physical (geometric) solution can be used to multiply two numbers together, so physical logic may not be obsolete just yet! )2010-10-26 23:35:00

Author:
thor
Posts: 388


The controlinator's digital component for the analogue sticks switches on at 75% and off again at 25%, which is a hell of a lot of hysteresis. It also handles digital negatives.
The R2 / L2 just switch on at >1%
L2 and R2 give analog signals as well? Nice! I'd hoped so, but never heard confirmation of that. Interesting that the different inputs have different thresholds. I was about to say I'd just note this and move on since Logisim doesn't have analog inputs, then I remembered its Joystick (http://ozark.hendrix.edu/~burch/logisim/docs/2.6.0/en/libs/io/joystick.html) (limited to 5 bits per axis, but it's there), so I guess I can't justify ignoring it completely.

Hate to keep bugging you with questions, but for completeness, how about the 2-way and 3-way switches? (I'm assuming the Button outputs either Off+0% or On+100% with no negatives.)


A note on digital negatives BTW. There are 2 versions of zero. Only directional type signals can tell the difference, but depending on what the signal source is, the zero is either interpreted as "go backwards", or "stay still". So realistically, you have four states in there to deal will, but you can fudge that into your 2 bits of data when you get around to it.
Actually, that makes things easier for me. I was already using 2 bits for the digital component (one for 0/1 and one for +/-). I was considering adding some logic to convert -0 to +0 since I'd assumed they'd be the same, and was even considering adding logic to make 1/0/-1 stored in one bit as 1/0/Floating to get an extra bit in the analog part of the circuit, and now I don't have to.

From what I've gathered most of the logic will ignore the digital sign anyway (most seems to strip out the analog sign) so most of my circuits have been simply dropping it, but they are set up to potentially handle it and I did make the Combiner output it as you described.

I am curious on one thing about the splitter though. You mentioned earlier that it's possible for the digital and analog parts of a signal to have different signs. What happens if you send such a signal through a splitter? Does the digital go to one and the analog go to the other, or does one take priority? I also wonder what would happen if such a signal went into something where direction mattered; I'd guess it would use the digital part if it can only take direction and the analog part if it can use the speed as well, but would be interesting to find out for sure (this would be easier to test if you could just poke values into the LBP2 signal like I can into Logisim instead of having to jump through circuitboard hoops, but...).

Again, MASSIVE thanks for your help on this. <3

EDIT: Okay, I lied, no timer yet but I'm going to post what I've done so far anyway so the curious can see what I'm working on. You can get the first beta version of the circuits here (http://balorn.com/lbp2/LBP2DualityBeta1.circ).

Things that (I think) work:
Circuits to create and split a combined digital/analog wire (digital=0/1 bit & +/- bit, analog=30 bit signed)
Circuits to convert between 1/10ths % (+/- 1000) and a 30-bit signed value (with optional BCD on the input for ease of use)
A circuit to convert the output from Logisim's joystick to two D+A signals (H and V) with proper hysteresis on the digital part for how the Sixaxis sticks behave
NOT, AND, OR, Combiner and Selector circuits that I'm reasonably sure behave properly
XOR and Splitter circuits that I think probably work properly, maybe

Things I have NOT made yet:
Timer, Counter and Toggle circuits (I do plan on making all these Soon?)
A nice bar graph display for the analog part using Logisim's LED Matrix (low priority, but doable)
Random circuit (don't know if I will make this as I don't have much info on the different random modes)
Nice graphics for the circuits that Logisim will actually save and load properly

I also haven't done much to optimize how each of these work internally. Quite a few things could probably be done more efficiently, but I want to get them working properly first.

EDIT 2: I've made Toggle and Counter circuits, graphics for the circuits, and even put some 1-bit "outputs" (which are dark/light green for 0/1) on the circuits so you can see digital logic and counter progress at a glance. The updated version is available here (http://balorn.com/lbp2/LBP2DualityBeta2.circ).
http://balorn.com/lbp2/logicpics04.png ph33r my 1337 @rt 5ki112!

I also made a Timer circuit (not currently in the above file) that works for counting up and can even take analog input to control speed up or down (that was an interesting bit of math to work out within Logisim's limitations), however I've been unable to get it to behave as described in rtm223's example circuits (http://www.lbpcentral.com/forums/entry.php?2069-Analogue-Logic-1-Fundamentals). I believe the problem is I don't have the correct answers to the following:
What happens to a Timer when it's full but is still receiving a positive Speed input?
What happens to a Timer that is empty but is still receiving a negative Speed input?
Ideally, I'd also like to know what the digital part does in these cases.
2010-10-27 00:12:00

Author:
Balorn
Posts: 92


Updated version here (http://balorn.com/lbp2/LBP2DualityBeta3.circ).

All of the implemented LBP2 circuits (NOT, AND, OR, XOR, Combiner, Splitter, Selector, Toggle and Counter) should now behave exactly as they do in LBP2 itself for both analog and digital signals.

The only exception to this is digital negative 0, because I do not have a reliable way to generate a negative 0 or test if a 0 is negative in-game; once I do, I can implement that as well. (I understand it almost never matters, but for the sake of completeness...)

Still no Timer or Randomizer, though. I have some ideas to make the latter, though it will be difficult to do with an arbitrary number of outputs. Still need to do more testing regarding the Timer.

Edit: Or not. Several of the assumptions I and others had made turned out to be incorrect. See here (https://lbpcentral.lbp-hub.com/index.php?t=39041-Logical-Peculiarities).
2010-10-31 01:20:00

Author:
Balorn
Posts: 92


Look great

I made video on gates vs analog signal and i just notice ( and i probably discovered America) that +/- symbol acts more like directional information then actual +/- number, good to see your stuff apply that.
2010-10-31 04:49:00

Author:
Shadowriver
Posts: 3991


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.