Home    LittleBigPlanet 2 - 3 - Vita - Karting    LittleBigPlanet 2    [LBP2] Help!
#1

Logic help - bit shifting in a state switch

Archive: 15 posts


This one is going just a bit beyond my engineering abilities... so I'm calling out the experts to give me a hand with this.

I have a four-bit register... in this case each bit represents one of four lights (A, B, C, D) in on/off configuration.

The configuration of the lights is determined by incoming switches. This part is easy and taken care of. The problem is I want to hook up a controllinator so that the R1/L1 buttons shift the pattern of the lights to the right or left.

In other words, if the initial state of the switches is:

A: 1 B:0 C:1 D:1

Then R1 would move the value of A to B, the value of B to C, C to D, and D to A:

A:1 B:1 C:0 D:1

And L1 would move this pattern in the opposite direction, A to D, B to A, C to B, D to C, returning to the original pattern.

On paper, I've figured out a way to determine which bits should invert in the operation (using XOR gates), however when it comes to storing "bits" and performing operations on them, I'm not quite sure how to implement this.
2011-01-29 01:01:00

Author:
Thegide
Posts: 1465


Ooh, you're doing a puzzle game? Or is it a small part of a regular level?

My first thought is to use a 2-port selector set-reset for each bit. A left shift could be done by connecting L1 AND bitX to the set input of bitX+1 and L1 AND NOT bitX to the reset input of bitX+1.

By the way, did you read Rtm's LBP2 blogs yet?
2011-01-29 01:14:00

Author:
Rogar
Posts: 2284


By the way, did you read Rtm's LBP2 blogs yet?

For shift registers in digital they won't help. Especially 2-directional bitshift.

The issue you are likely to face with this is (annoyingly) the zero-latency effect(s) that are supposed to make LBP2 logic easier. Probably. I don't know, I'm actually hammered right now and just guessing. I'll try to remember to think about it in the morning
2011-01-29 01:37:00

Author:
rtm223
Posts: 6497


Haha, that is classic! Yeah I've already run into some of the zero latency issues with circuit activation - I'm not sure if buffering with a very short timer could help. If there's not a purely digital solution, I think I could come up with some wheel-based logic that rotates the outputs to different inputs.2011-01-29 01:47:00

Author:
Thegide
Posts: 1465


In they beta I made bit shifters and other arithmetic components, For the bit shifter I used temporary storage and wired it back into itself. And for a n-bit shifter I used analog logic to run an counter for a clock signal for the 1bit shifter. If I get a chance I will recreate it along with my machine to send bits over a single line with a built in clock signal.2011-01-29 02:20:00

Author:
Zmathue
Posts: 62


Um... maybe I'm missing something, but it sounds like you've got four states that you need to be able to cycle through (since it seems that all but one of your lifts are 1, and 0 moves sequentially through them). Couldn't you do that with a selector?2011-01-29 04:29:00

Author:
Sehven
Posts: 2188


You may want to try creating some RAM in addition to your lights with a 0.1 second cycle time. Basically, every 0.1 seconds each of the 4 bits of RAM would copy the current light configuration. Clicking L1 or R1 would move the current lights to the left or right of the RAM, not to the left or right of the lights themselves.

Personally, I'm still happy with zero-latency. rtm223 and I argued about this back in LBP1 when I put a circuit board on the suggestion forum. My circuits get fairly large and a required 0.1 latency between each step would really slow response times. When zero-latency becomes an issue, a 0.1 second RAM cycle can usually take care of the problem.
2011-01-29 04:46:00

Author:
dcf
Posts: 468


Um... maybe I'm missing something, but it sounds like you've got four states that you need to be able to cycle through (since it seems that all but one of your lifts are 1, and 0 moves sequentially through them). Couldn't you do that with a selector?

The states change. That particular configuration with one zero is only an example. There are 2^4-1 possible state configurations, all of which need to be cyclable (the -1 is for the 1 1 1 1 state which immediately initiates a reset to 0 0 0 0)
2011-01-29 14:15:00

Author:
Thegide
Posts: 1465


I just did it, but it's probably overengineered... I used a selector with 4 states:
1: accept and store the data input
2: store the data in a buffer
3: shift left
4: shift right

I just published a level (For Thegide: shift register), with a prize bubble containing all of the mechanism
2011-01-29 21:33:00

Author:
Shadowheaven
Posts: 378


The states change.

Ah. Sorry, guess it's over my head.
2011-01-29 22:13:00

Author:
Sehven
Posts: 2188


I just did it, but it's probably overengineered... I used a selector with 4 states:
1: accept and store the data input
2: store the data in a buffer
3: shift left
4: shift right

I just published a level (For Thegide: shift register), with a prize bubble containing all of the mechanism

Awesome! I'll have to check this out when I'm on later. I've been trying away at this for hours with limited success. Thanks very much for taking the time do wire this together If it does the trick, I will be sure to give you credit in the level.
2011-01-29 22:30:00

Author:
Thegide
Posts: 1465


This is just off the top of my head, and it may be more complicated than it needs to be, but suppose you have 2 bits represented by selectors with 2 inputs.

Now for right shifting.
You need two AND gates
Take output 2 of bit 1 and run it into one input of each AND gate.
Take output 1 of bit 2 and run it into the other input of the AND gates
Place an OR gate below that, and run one of the AND gates into it directly, then the other goes through a NOT gate before going to the OR.
Run that OR out to the cycle input of bit 2.

What this will do is tell you if bit 1 is in the same state as bit 2. If it is, no action needs to be taken. If it is different from bit 2, then it hits the cycle input to flip the bit.
2011-01-29 22:46:00

Author:
tdarb
Posts: 689


Awesome! I'll have to check this out when I'm on later. I've been trying away at this for hours with limited success. Thanks very much for taking the time do wire this together If it does the trick, I will be sure to give you credit in the level.

A little warning: my wirink is awful, and it doesn't do the reset from 1 1 1 1 to 0 0 0 0 (although it shouldn't be a problem to implement it by adding ...but now I'm too sleepy), and you'll have to use the switch for the 2nd state before every time you activate the 3rd or the 4th; feel free to ask me anything, I like doing this sort of thing
2011-01-29 23:58:00

Author:
Shadowheaven
Posts: 378


This is just off the top of my head, and it may be more complicated than it needs to be, but suppose you have 2 bits represented by selectors with 2 inputs.

Now for right shifting.
You need two AND gates
Take output 2 of bit 1 and run it into one input of each AND gate.
Take output 1 of bit 2 and run it into the other input of the AND gates
Place an OR gate below that, and run one of the AND gates into it directly, then the other goes through a NOT gate before going to the OR.
Run that OR out to the cycle input of bit 2.

What this will do is tell you if bit 1 is in the same state as bit 2. If it is, no action needs to be taken. If it is different from bit 2, then it hits the cycle input to flip the bit.

Hmm I hadn't thought about using selectors to represent bits - initially I used toggles but I suppose that doesn't matter. I think your circuit is overly complicated though. A simple XOR gate would do the same thing to tell you if the bits are different and need to be flipped. There are other difficulties in the implementation though.


A little warning: my wirink is awful, and it doesn't do the reset from 1 1 1 1 to 0 0 0 0 (although it shouldn't be a problem to implement it by adding ...but now I'm too sleepy), and you'll have to use the switch for the 2nd state before every time you activate the 3rd or the 4th; feel free to ask me anything, I like doing this sort of thing

Resetting the system is easy; I already had a circuit doing that. Each input is wired through an OR gate. There is an AND gate on the bit outputs which is activated on 1 1 1 1, which initiates a toggle on each bit causing the auto-reset.
2011-01-30 17:22:00

Author:
Thegide
Posts: 1465


The issue you are likely to face with this is (annoyingly) the zero-latency effect(s) that are supposed to make LBP2 logic easier.

Indeed. If you're still having trouble I've built something very similar for another project, so you can swing by my moon sometime.
2011-02-03 02:54:00

Author:
Aya042
Posts: 2870


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.