Jump to content
Sign in to follow this  
Flareon350

How to use logic gates?

Recommended Posts

So I'm not gonna hide it. Yes I do not know how any of the logic gates work, with the exception of the AND gate. The main CC2 game really didn't teach it well in all honesty (either that or I really just don't understand them).

 

Since I don't know how to use them, I won't be using them much in my CC2 levels unless I learn how. But due to the fact I can't learn anything through watching videos and reading up on stuff like that, I need some help learning. So could someone who does know what they all do teach me and maybe provide examples for me to understand? I really could use some guidance with these tiles.

 

The reason for this thread is because I may not be alone in not understanding how they work so anyone else in the future who doesn't know how to use logic gates can view this thread and maybe learn as well.

 

I'd appreciate it if someone could help me learn how to use these so I can maybe build a crazy logic level one day. :)

  • Upvote 1

Share this post


Link to post
Share on other sites

I'll try to give you a short overview over the elements and their mechanics :)
 
The logic gates are AND, NAND (not and), OR and XOR (exclusive or) will give you based on their inputs on the side (in the following table x and y) the result (marked as r) at the top - T stands for true or a high signal F for false or a low one:

r: AND (*)
 x y r
(T,T,T)
(T,F,F)
(F,T,F)
(F,F,F)

r: NAND
 x y r
(T,T,F)
(T,F,T)
(F,T,T)
(F,F,T)

r: OR (+)
 x y r
(T,T,T)
(T,F,T)
(F,T,T)
(F,F,F)

r: XOR
 x y r
(T,T,F)
(T,F,T)
(F,T,T)
(F,F,F)

Except for the exclusive or there are no surprises as the words are used the same manner in everyday language. For XOR remember, that if both inputs are the same, the output will be false and if they are different, the result will be true.
 
The not element negates a signal, this means False will give you True as a result, and vice versa.
 
Each of the gates has a delay of 1 tick to it, this means, the output will not be instant. If you e.g. realize a diode by putting two not gates after each other, there will be a delay of two ticks compared to the reference signal.
 
The latch gates are a bit trickier - they are essentially what is more well known as D-latches (compared to a D-flip-flop which is edge-sensitive it is level-sensitive, sometimes called transparent D-flip-flop), this means they will change their state according to the data (D) input as long as the enable (E) input is high. You can use them to store the input state.

 D E Q
(F,T,F)
(T,T,T)
(x,F,Q previous)

To get more detailed information about all the logic gates, I recommend using the internet and a search engine of your choice. If you search for the electronic real world counterparts you will find a lot of detailed explanation (much more than I or anyone else could ever write here) and examples of using them B) (Keep as well in mind, wikipedia is never the worst starting point...)

If you have any specific questions about their behavior especially their mechanics within CC2 I and I guess a lot of other members are glad to help...

  • Upvote 1

Share this post


Link to post
Share on other sites

This is an excellent topic. I too, would appreciate help on the subject. Unfortunately, I think it’s kind of one of those things that really takes a while to learn cause it’s sort of like a type of math. Just explaining it won’t be as simple as having a single post or even a video. And it’s pretty important imo, considering you can build a mini-computer in a level :D [see the UART level in the downloads]

 

What I’m doing for myself, is I’m experimenting on my own and learning as I go. That’s a really slow way of doing it, but I plan to upload levels, possibly a pack of demos and explanations on the subject as I learn. And in my regular levelpack I have currently two tutorial levels demonstrating logic gates in *slightly* more detail than CC2’s game.

 

 

A quick tip I can say off the top of my head: if you put a inverter in a wire loop [just make a wire rectangle and pun an inverter in it somewhere]. The wire will cycle on and off rapidly. With this you can make things happen like a cloner clone rapidly with no buttons being pressed at all; or have a timer go up or down without button presses as well. This is sort of where I started and will probably have demos of first. I started getting fascinated by this when I saw it first in "Crazy 1 and 2".

  • Upvote 1

Share this post


Link to post
Share on other sites

This seems like something that a lot of people have trouble with, so I decided to go ahead and make a basic set of lessons showing how each wiring element in CC2 works.
http://cczone.invisionzone.com/index.php?/files/file/570-introduction-to-wiring/
It doesn't go into how to wire up multiple gates together to make complex circuits, but it covers all the elements individually.

  • Upvote 2

Share this post


Link to post
Share on other sites

Thank you everyone, especially Felix! I think a tutorial for logic stuff was highly needed, just no one spoke up about it :P

 

I think I get how latches work now but I'm still playing the tutorial (solved all of them, just playing around with stuff). I'll have to test some stuff out on my own to make sure I know how to use them.

Share this post


Link to post
Share on other sites

is it possible to set up "IF statements" with wires?

 

Let's say I want the following:

You clone a monster to randomly press one of three buttons, each connects to a latch or otherwise connects to another button which you press, to open the door to the exit. [six buttons total]

Now if you clone another monster, and it presses a different button, it turns off the first latch and turns on the other one it went to. So now, chip can only pressed the latest button triggered to open the door.

Is this possible?

Share this post


Link to post
Share on other sites

is it possible to set up "IF statements" with wires?

Almost all useful logic circuits are conditional on their input, so yes as you can see most circuit as a conditional expression. :)

 

You clone a monster to randomly press one of three buttons, each connects to a latch or otherwise connects to another button which you press, to open the door to the exit. [six buttons total]

I'm not quite sure what you mean with otherwise connects to another button.

 

Now if you clone another monster, and it presses a different button, it turns off the first latch and turns on the other one it went to.

You cannot turn on or of logic gates, however you can set their output to a high signal or a low one.

 

So now, chip can only pressed the latest button triggered to open the door.

Not a hundred percent sure what you are describing here.

 

But if I guess correctly, you either want three outputs, where two are set at random and Chip has to set the third signal to high to get to the exit, or you want one of three outputs set, if Chip triggers the corresponding event to a certain output, another one is chosen at random and Chip has to set a corresponding signal again to finish the level.

In the first case just connect both inputs of each of the latches to get a one time use too set a signal and connect their outputs with two and gates to have the condition all three have to be high.

If you tried to describe the second behavior, it's a bit trickier, since you have to reset the states (or duplicate the circuit). To do this, connect the inputs of the latches via or gates to get essentially a SR-latch. Now you have one input to set a state and one to reset it (as e.g. in the level SET AND RESET). The set connection has to be connected to your random events, the reset one should be triggered from an and gate which gets its signal from the corresponding output of the latch and the circuit Chip is triggering (e.g. a button). The same connection can trigger future events, as e.g. a second random set. To determine what should occur, use a counter, in case of just a few events, you can use the counter tile, otherwise to make the circuit more generally applicable, build a binary counter out of the gates... B)

Share this post


Link to post
Share on other sites

is it possible to set up "IF statements" with wires?

 

Let's say I want the following:

You clone a monster to randomly press one of three buttons, each connects to a latch or otherwise connects to another button which you press, to open the door to the exit. [six buttons total]

Now if you clone another monster, and it presses a different button, it turns off the first latch and turns on the other one it went to. So now, chip can only pressed the latest button triggered to open the door.

Is this possible?

If I understand correctly you want something like this

 

F7hCbq0.png

 

Where the monster pushes one button, and chip must push a corresponding button to exit, and if the monster pushes another button, the first one wont work and the new button's corresponding button needs to be pushed.

Share this post


Link to post
Share on other sites

I think this does what you're looking for. Assuming at most one of the buttons is ever held down at a time, only the output of the later one's latch will be on. If you want to control whether a button opens a door, you can (for instance) feed the latch output into an AND gate and have the button connected to the other input of the AND gate. All this is easily extended to any number of latches.

 

 

logic.png

Share this post


Link to post
Share on other sites

I think this does what you're looking for. Assuming at most one of the buttons is ever held down at a time, only the output of the later one's latch will be on. If you want to control whether a button opens a door, you can (for instance) feed the latch output into an AND gate and have the button connected to the other input of the AND gate. All this is easily extended to any number of latches.

Yeah this is basically a better explained version of what I made :P

Share this post


Link to post
Share on other sites

thanks for so much help!

 

I’m actually not really sure what I am looking for because I’m really just experimenting, but I think this will help me a lot.

 

Actually, the examples so far aren't exactly what I was looking for, but they give me ideas anyway :P

No, sorry Felix, your sample is exactly what I was looking for! :rolleyes:

 

One of my goals is to try and reduce the size of a logic set up so levels like my “Drawing of the Seven” don’t have to take up an 80x80 grid. Not that there’s anything wrong with it taking up a huge space,  but for the sake of learning.

 

unrelated note: I like those graphics a lot! where can I get those? on here, or on Steam?

Share this post


Link to post
Share on other sites

This seems like something that a lot of people have trouble with, so I decided to go ahead and make a basic set of lessons showing how each wiring element in CC2 works.

http://cczone.invisionzone.com/index.php?/files/file/570-introduction-to-wiring/

It doesn't go into how to wire up multiple gates together to make complex circuits, but it covers all the elements individually.

 

this is a very good set of tutorials. If you're planning on making a big set, I'd put those in there. I like that they work without much or any hints.

 

I have a level coming together with demos of simple but useful circuit designs but it's unfinished. But I might just upload it as is for now, it might be a while before I can think of more stuff to add to it.

 

here it is so far: http://cczone.invisionzone.com/index.php?/files/file/573-logic-gate-demo1/

 

like I said, it's a bit simple now, but I hope to add more to it. -H- also has a sample level like this in the level discussion thread.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×