# Lesson video

In progress...

Hey there, and welcome back to computer systems. I'm Mac your computing teacher for this unit.

In this lesson, we're going to be talking about logic problems and combining logic gates to solve more complex real world issues.

Like usual, you're going to need a pen and a notepad, but also like, you know, make sure that you've got a pencil because we're going to be doing some drawing in this lesson.

I've got my water bottle here so I can stay hydrated while I teach this lesson and you should make sure that you've got some refreshment if you need it throughout the lesson.

If you want to pause the video here and get everything that you need, I'll be here when you get back.

In today's lesson, you're going to learn how to construct a three input logic circuit and a truth table, and also how to write a Boolean expression.

Let's get started.

Before we move into the new knowledge, I just need to make sure that you can recall your prior knowledge either gained from lesson nine, or if you're joining us fresh from previous knowledge that you can recall logic gates.

So I've got a task for you to do.

If you head over to your worksheet, I've got two logic gates I would like you to name and a truth table I would like you to complete.

If you want to pause the video here, head over there and then come back when you're done and we'll go through it.

I asked you to name these gates.

So you have two there and hopefully you got that the first one is an AND, and the second one is a NOT.

So the AND has a flat back with a round top and the NOT is a triangle with a circle on the end.

The next task I wanted you to do was to complete the truth table for an OR gate.

Now I gave you a completely blank truth table this time because I wanted you to put the inputs in yourself.

So the first task is to do that.

Now you need to remember that when we're putting in inputs into a truth table, it's important that we count up rise.

We start from zero and then we count up by one each time.

This is so you know, you haven't missed any of the inputs and you're not skipping a number or haven't missed anything on the weight so put them in randomly, make sure you follow the procedure, put zero at the top and then count up by one for each column.

You can see the same is done here.

The top column is zero, then two in the second column.

Sorry, then one in the second column, two in the third column, three in the final column.

I know I haven't missed any because I can see it counting up.

Next you have to apply the OR logic to those.

So you're going to take these two, these two inputs and whether an OR gate would return true when provided then.

You should have got that only the top, the zero, zero would return false because OR gate needs one or both inputs to be true.

So the top one has no inputs as true and the bottom has, the bottom three each have either one or both.

So they all return true.

Great work.

Hopefully you're able to recall that.

If you need to pause the video here, just to update your notes, that's fine.

Resume when you're done and we'll carry on.

Let's get going.

Today we're going to be looking at more complex circuits.

I've got an expression for you here.

The washing machine will turn on if the button is pressed or a timer is set and it is full.

How would you go about designing a logic circuit to represent this expression? Hopefully you would follow the process that we went through in lesson nine.

Looks a bit like this.

So we identify the inputs.

We identify an output.

We identify a logical operator.

We draw the logic diagram and then we create a truth table.

If you didn't do lesson nine with us and you're starting fresh, don't worry or even if you're not quite sure how this works, we're going to step through it again so don't worry at all.

Stage one is to identify the inputs in the expression.

So if you want to pause the video here so you can read through it, that's fine, but I'd like you to try and see if you can spot where the inputs would be for this expression.

Well, the inputs are going to be the button being pressed, a timer being set, and the washing machine being full.

Of these three things are real things that we can have as a sensor.

That feed into our processors so we can detect whether a button is pressed.

We can detect whether a timer has been set and also whether it's gone off, and we can also have some sort of sensor detecting weight to tell whether the washing machine is full.

Step two, is that we identify the output of the expression.

If you want to pause the video again, just so you can have a read, I want you to try and point out the output of the expression.

Hopefully you got the washing machine turning on.

My washing going on automatically is the output that I'm after and some combination of those three inputs will result in that output.

Then I want you to identify the logical operator.

Again, pause the video if you need to, to have a read through and try and find the logical operator.

Cool.

Hopefully you notice there are actually two in this expression, so there's an OR and an AND.

How was that different to the example you saw in lesson nine or examples you might have seen previously? Well this one actually, yeah, has two logical operators where the ones before only had one so is a bit more complex.

So the next thing to do is to draw a logic diagram and just like before the first thing that we do is we put the inputs and outputs on our diagram.

We're going to put the inputs on the left-hand side and our outputs on the right-hand side.

So button, timer and full on my inputs and washing on is my output.

Then I need to put the logic gates to connect my inputs to my output, using the logic that I'm after.

So the first thing I do is I find the first logic gate in the diagram and in this case, the first logic gate is an OR gate.

So I connect to my two first, inputs button and timer, to that OR gate.

So the washing will turn on if the button is pressed or a timer is set.

So those are my two inputs for my OR gate.

Next, we find the second logic gate.

In this case, it's an AND.

Now I can use the output of one gate as the input for another.

So the result of our button or timer calculation is going to go in to our AND gate and the second input for the AND gate is going to be full which is our third input for the expression as a whole.

So the result of that OR gate feeds in as one of the inputs for the AND gate, and full, which is the third input is the second input on our AND gate and the result of whatever happens in the AND gate is whether or not my washing is turns on.

So key points to remember here is that we can use the output of one gate as the input for another.

This is going to come up quite a lot so make sure that you know this is something you could do, otherwise you might get a bit stuck later.

If you want to pause the video here and draw this down, make sure that you've got it in, that's absolutely fine.

Resume when you're done and we'll go on to a task.

So, you've seen me do it, do this on one expression.

I'd like you to have a go now doing this yourself so I've got a second expression for you here.

A picture will be taken if the motion sensor activates and the light is on or a proximity sensor activates.

If you want to pause the video here and head over to your worksheet.

I'd like you to complete the first four steps.

Identify the inputs, identify an output, identify logical operators, and then draw a logic diagram and stop there, resume the video and we'll go through it.

Welcome back.

How did you get on? I'm going to go through it now with you anyway, so don't worry.

The first step is to identify the inputs of this expression and input in this case are, a motion sensor activating, the light being on and the proximity sensor activating.

So we have three inputs again.

Second stage is to identify the output and the output in this case was going to be a picture being taken, a picture being taken.

So a picture will be taken with the right combination of those three inputs.

Next we identify the logical operators and there are two again this time.

So we've got AND and OR but they're in a different order.

The first example I showed you had OR and then AND.

In this case, AND is the first gate, OR is the second.

So how do we draw a logic diagram? Again, the first step is to put the inputs on the left-hand side and the output on the right.

So we got motion, light and proximity our three inputs on the left and picture, which just means taking a picture, on the right-hand side, which is our output.

We then take the first gate, which in this case is an AND and we feed our first two inputs or the inputs that are around it, into it.

So if a motion sensor activates and the light is on, then we're going to, that's the firsthand gate and then we're going to use the result of that to feed into our second gate, which is an OR.

So the result of that first AND feeds into the OR gate and then our third input proximity is the second input for that OR gate, and the result of the OR of those two inputs is going to be whether or not our picture is taken.

So if you want to pause the video here just to make sure that your diagram matches mine and then we'll carry on.

How do we draw three input truth tables? I'm going to go back to my first example for this one.

So this is the washing machine example again.

The washing machine will turn on if a button is pressed or a timer is set on, it is full.

You can see the logic diagram down the bottom here with our two gates on it.

How do we draw a truth table of this? well, it's very similar to the process we use for two input circuit, and the first stage is to identify the inputs and then make a column for each, so we've got button, timer and full those are our three inputs, and we've got a column for each.

Next we add in all of the possible input combinations for those three.

In this case, we're not going to stop at three we're going to stop at seven it's cause there's eight rows so we're going to start at zero and count up to seven, and that will give us eight input combinations, and we'll make sure that we haven't missed any of them.

I said, this is a key point to remember and follow this process.

Following this process means you will not miss any of the inputs.

So that's what I've done here.

I've got zero at the top, then one, two, all the way down to seven.

You can have a look and count them up yourself I don't think I've missed any and that's because I've followed that process.

Next we want to identify the first gate on the diagram in this case, it's button or timer and I'm just going to flip back so we can see that diagram again, so we've got OR gate first, which takes our button and timer inputs.

For the next stages that we identified the first gate, which is the, OR and then we apply it to the first two inputs so I've just highlighted that so that you can see so we're considering these two pink columns here, and then we're going to put the results of some OR logic in the purple column over here on the far right-hand side.

So I'm going to go through one by one and check whether what the result of an OR gate would be on those two inputs.

So zero, zero will result in a zero from an OR gate.

The second column is the same zero, zero and then the third column and all the ones that follow each have at least one, one in them so it's either one or both, which is perfect, exactly one OR gate once.

So our top two columns are zero, zero and then the rest are ones so that's just the OR gate.

We haven't finished is just that first gate that we've done.

Next we take the second gate.

In this case, we're going to use the result of our first bit of logic.

So we fed the result into the next gate didn't we? And we're also going to use the third input, which is full.

So I've highlighted the columns again so that you can see so we're considering full and AOB and I'm going to apply it and logic to that.

So the first one is not, the second one is not because it needs both ones for an AND gate to ring true.

The first column that will result in a one is called AND full.

Column six and column eight will also have ones in them because they've got two ones as their input.

You see here, I've just gone down the columns, comparing those not considering the whole thing, just looking at two things at once.

Two things, applying AND logic and putting it in.

So the washing machine will turn on if the button is pressed or a timer is set and it is full.

We've now completed our truth table.

What I'd like you to do is just pause the video and have a look at the statement again, and the combination of inputs and make sure that wherever there's a one in my AND, the C column, the inputs match the expression.

You can see that every time so if a, the button is pressed or a timer is set.

So in column four which has a one, the button has been pressed on a time, the button has not been pressed on top but the timer has been set and it is also full, perfect.

Same thing goes for column six and column eight.

That's how we construct a three input truth table.

Now what can you do to do this? I've got another task.

So I want you to take that second statement I gave you, the example that you drew a logic diagram for, a minute ago.

I want you to now draw a truth table for it.

So you've got motion, light and proximity and the results in a picture.

Pause the video here, draw a truth table for this, these three input circuit and then head back and we'll go through it.

It's important to stay hydrated, make sure that you're having some drinks if you need them.

Let's keep going.

Solve stage one, I'm going to put my inputs and give them three columns.

So you can see there's my first three columns there.

So I've got A motion, B light, C is proximity.

I didn't put the C there 'cause it made the formatting with the, as our third input and then we find the first gate in the expression and this is an AND gate.

So I'm going to consider A and B and then play some AND logic to it and put it in that fourth column.

So I've highlighted them so you can see them again.

So I want AND the logic, both of them need to be one.

So you can see that the only ones that rink the, meet these criteria is the last two columns 'cause they both have ones in them.

Hopefully you got that.

If you need to update it, pause the video here and change your table so that it matches mine.

I want to make sure you have the right answer going forward.

Next, we're going to have a look at the OR gate.

Now for this OR gate, we're going to use the third input which is proximity and the result of our AND gate, so A and B.

When I use those two columns, apply OR logic to them to create the, this last purple column.

So the top column has a zero for proximity and a zero for A and B, which means our OR gate will output zero.

Columns two, four, six, seven, and eight will all result in a true output from the OR gate and allowing electrical current to flow.

So picture will be taken in those instances.

If you'd like to pause the video here again, I'd like you to do two things.

One, make sure that your truth table matches this one.

Is really important that you have the right information going forward, especially if you're going to look back at this later to see a good example.

I'd also like you to do that same test.

So see where there is a one in this final column and just check whether the conditions match our original expression.

Resume when you're done and we'll carry on.

Right then, onward.

Next, we're going to look at how to write a Boolean expression.

I've gone back to my first example, since the washing machine again.

So washing machine will turn on if a button is pressed or a timer is set and it is full.

You can see the logic diagram down here that we've made and also the truth table that we finished up with.

How would we turn this statement into a Boolean expression? This is actually the easiest transposition you've done yet.

This is just removing the access words.

So let's have a look at what that looks like and we just say the result, washing on equals button OR timer, which is in brackets.

We use brackets to show which ones are taken separately.

So the first OR gate is a separate addition to our AND gates.

We're wrapping that in brackets to make sure that it's clear.

This one's done first and then we apply the AND gate and then we'll have AND full to show what our second input is, for the AND gate.

So essentially, turning it into a Boolean expression is just arranging it like a mathematical equation.

So we say washing on equals and then we put the logic, ran out plainly and removing the superfluous words.

So it's not a sentence anymore, it's more like an equation.

I'd like you to pause the video again and just note this down so that you have an example of all of these things.

Let's keep going.

I've actually got a longer task for you now.

I've got another expression on your worksheet and I would like you to complete the whole process that you've seen in this lesson so far.

So you've got brand new expression I want you to identify inputs, identify outputs, logical operators.

I want you to draw a logic diagram, complete a truth table and write a Boolean expression.

Pause the video now, head over to your worksheet, complete the task and come back when you're done and we'll go through it.

Welcome back.

How did you get on? Let's have a look at the results.

So this was the new expression I gave you.

So you had the warning siren will sound if the pressure is too high and the valve is not open or the temperature is too high.

So the first thing to do is identify the inputs and the outputs and hopefully you got the output is the siren.

So we've put that on the right-hand side, just down here and then we're also going to put the outputs on the left-hand side, which is more sort of over there.

We've got pressure, the valve being open and the temperature.

Those are our three inputs.

So we've identified inputs and outputs.

Next, we're going to have a look at the logical operators.

Now was a bit tricky with this one, 'cause it was actually three logical operations going on.

We've got an AND gate, a NOT gate and an OR gate.

So usually what we would do is, we'd take these logical operations and we'd go for the first one and then we would put, and we'd put the first one in but in this case because there's a NOT, we actually want to do that one first and this is because it only applies to one of our inputs.

Just a valve needs to go into that NOT gate and then be inverted.

So we won't ever to return a one when a valve is not open and we wanted to return a zero when the valve is open.

So we need to invert it.

So you put that into our diagram.

Next week, we then having done the NOT gate, we can ignore it for the rest of the time because it's sorted and then we start with the normal procedure of going with the first gate, which is our AND gate.

So we'll feed the result of our NOT gate and pressure into that and then connect them up just like this.

Next is the OR gate and the OR gate is going to take the result of our AND, and then the third input, which is our temperature.

So we're going to feed the AND gate into the OR gate and then also put temperature in there and the result of that OR gate will be our siren So whatever happens in that OR gate will determine whether our siren comes on or not.

Your going to pause the video here and just make sure that your diagram matches mine.

That's absolutely fine.

Resume in when you're done and we'll keep going.

Great work.

Next let's have a look at the truth table.

Now again, this is a little bit tricky because I threw that third gate at you that you probably weren't expecting, but hopefully you are able to use the procedure that we went through to complete it.

So the very first thing is to take that NOT gate and add a column for it because although we could just invert in our heads, it's better to have it all written down so that we know we're not making any mistakes.

So the NOT B column is just the inverse of whatever is in this B column over here.

We then take this result and pair it with the pressure, the A input for our AND gate.

So not B and A.

So we're going to take A and not B and then the result will come here.

So for an AND gate, we need both inputs to be one in order for it to ring true.

So the only times that that's going to be true is on these two rows here.

So row five and row six because we have a one for the pressure and a one for the NOT B and that will result in a one for our AND gate.

Then we do the third gate, which is the OR C.

So we're going to take the result of this AND, result of this AND, and then we're going to feed it in with temperature to our OR gate.

So zero, zero, which will result in a zero.

Got one here for temperature but a zero for our AND results.

That would be a one, so on and so forth, going down the tables.

We've got two, we've got a one here and a zero.

Again a one, this one's got one in the zero, in the temperature column and a one in the AND columns so that will also be a one because that's how OR logic works.

Alright, again, pause the video here if you'd like to and just update yours, if you made any mistakes.

It's absolutely fine if you did.

These things are quite tricky to get on board with at first, but lots of practise will help you get the hang of it.

Finally, this is a Boolean expression.

So we've got the result siren, then like a mathematical equation, we say that equals and then we use the brackets to separate them and one thing I'll need to, want to point out here is NOT.

Usually the logic operator comes after the input.

We've got pressure AND but with NOT gates, you actually put it in front of the input so not to valve.

So pressure and NOT valve, all in brackets, OR temperature.

Again, pause the video here, update yours if you need to.

Resume when you're done and we'll carry on.

That's actually all from me today.

Thank you so much for your hard work in this lesson.

I know that these complex circuits can be a bit tricky to get on board with at first, but you've done a great job making it through.

Last thing before I go is I want to ask you to share your work with Oak National.