字幕表 動画を再生する
in the previous video, we hooked up this e prom and were able to hook some switches up here to our address lines.
And by setting these thes address lines, we can get different data out of the data lines.
We could program it by setting the address that we wanted to program and then setting, hooking these jumpers up to put whatever data we wanted into the chip and then pushing this button here to write that data.
And I was fine for writing a few bites and programming a few bites into the e problem.
But if we want to program more than just a few bites, that's gonna get really old.
So this video, I want to look at a much faster way of programming this chip with a lot more data.
And to do that, we need to find some way of automatically setting all of these address lines and data lines and the right enable and the output enable the control lines all of these different inputs here to this chip.
We need to find some way of automatically setting them to the right values and kind of sequencing through all those values to program the chip.
That's what I'm gonna do is look at using an Arduino for that because they are Do we know lets us hook it up, You know, from us be to our computer, and then it gives us a bunch of digital outputs that we can program.
I could certainly use this Arduino, you know, no problems there, but I'm gonna use instead the Arduino Nano, which has exactly the same functionality, has all the same outputs.
That's just in a more compact form factor here, which is really nice because it will plug right into our bread board.
We complete the Nano directly into bread board here, and then it has a USB port that we can use to plug it into the computer.
And once we plug it in the computer, it also powers the board, which is very nice.
And the other nice thing is that that power is is also available here.
There's five volts and ground so we can hook that up to the bread board and we can actually use the USB.
The same USB that's that's connected to the Arduino toe also provide power to the rest of our bread board.
So we got the Arduino plugged in all.
Go ahead and make sure everything's working just by loading up one of the basic examples here.
The blink example.
And that's basically just flashes the led that's on the board.
So I'm gonna make sure under tools, I've got the Arduino Nano selected as my board and I've got the right port selected there and go ahead and compile an upload and it looks like everything's working fine are led.
Is is now blinking on the board.
So how is this gonna work?
Well, if we look at the data sheet for the 28 c 16 the UT problem that we're looking at in the last video you can see we've got our address pins.
We've got address zero through tents.
There's 11 address pins And then, of course, a data pins, you know, 012345678 data pins.
And then we also need our output enable we need to be ableto set that and then we need to pulse are right.
Enable pin from Hyde alot.
That's a bunch of pins that we need to control.
And if we look at the Arduino, you see we've got in terms of the digital pins that we control.
There's basically 14 pin.
So there's zero and one here, which are also marked a Xrx and T X and then 23456789 10 11 12.
And then D 13 is over here to those air the digital pins that we can control from the Arduino.
So that's that gives us 14 pins.
So how do we use those 14 pins that we've got to control essentially the 11 address pins plus the eight I opens?
So that's Ah, 19 pins, plus the right enable and output enable pins.
That's 21 pins.
So we need to be able to control 21 inputs, essentially to the E problem, using just 14 data signals on the Arduino.
So that sounds like a bit of a problem, but But actually, it's worse than that, because this these 1st 2 pins T X and Rx, you can only use those if you're not using the serial interface with the USB.
And as you'll see, we really want to use that serial interface because if we would have read what's on the e problem, would be nice to be able to read the data from the prom and then send it to the computer so we can display it on our screen or something.
So it's easy to read.
And to do that, we need to use the serial interface through this USB, and that takes up these 1st 2 pins.
So instead of 14 that leaves us with with only 12 data pins to work with.
And so you could say, Well, we definitely need to be able to control the eight data pins because that's ah, you know whats You know where we have to write all ate at the same time when we hit this.
This right signal.
All eight of these bits are getting written to the chip at the same time.
So, you know, we definitely need eight data, the signals, but we've only got 12 here, so if we use eight of them for for a data signal going into the into the chip, then that only leaves us with four additional lines.
Unfortunately, there is a solution here.
There is a way to use on Lee a couple pins on the Arduino to control a whole bunch of signals, and the way to do that is with something called a shift.
Register says the name would imply a shift register is a kind of register and registers store data, and so we can, ah, basically build one using D flip flops.
And so this is a 74 less 74 which has two D flip flops on it, and I've got got it hooked up here so that this button here controls the input to the ER to the D flip flop.
And then I've got, ah, clock hooked up to it as well, And so, just as a reminder of how this works.
If the clock pulses, then it latches whatever is on the input.
And so if I'm not pushing this button and the clock pulses, then it stores a zero.
If I am pushing the button here and the clock pulses, it stores a one and then if the clock pulses again and I'm not in putting anything here, it stores a zero.
But what we do with the shift register is we take the output of that D flip flop, and we hook it into the input of another D flip flop and So what happens now is if I clock the one into this D flip flop that one is now serving is the input for the next D flip flop.
You'll notice I've also connected all the clocks of these d flip flops together.
And so on the next clock pulse, this one here is the input for the next D flip flop.
And do you see on that clock pulse that one comes over here and I can hook that to another D flip flop on the next clock pulse.
It moves over there, and I can have that hooked up to another D flip flop.
And you know, I can put a one in over here on the 1st 1 and you see that one goes here.
But also this one moves to the next.
He flip flop, and we can extend this for as many stages as we want.
And so from this stage, it can go here and here and here and here.
So I've got eight stages essentially hooked up here, but you could have arbitrarily many stages, as many stages as you want hooked up here and every clock, everything just moves down.
One stage And so you can put whatever data you want into this thing by just controlling the one input here and the clock so I can put whatever value I want in here.
So if I want to put 10101010 into this shift register, I just need to clock in those those bits so and clock in a one and then a 01010 10 And now my outputs collectively show that 10101010 And I was able to get that data into these eight outputs.
You've just using us well, really.
Two inputs with the one in the single input and then the clock, because a shift register has just a single input.
But as many outputs as you want, it's very useful in a case where, you know, like an Arduino where we have a limited number of output pins and we and we need more.
And so that's why shift registers actually very common in Arduino projects and one of the most common shift registers its uses the 74 h c 595 and it's an eight bit shift register, Cyril input.
And this is kind of the block diagram here.
And so it has this eight stage shift register, which is what we what we just built here.
And so it has a D s is the data serial input, and then it has the shift clock pulse.
And so that's their, you know, basically our data in and our and our clock pulse and then this m r is a master resets that just resets the whole thing.
But really, it's just these two inputs that control all eight of those bits.
So I've got a 74 h c 595 here, and I've booked a few things up.
I've got, you know, power and ground hooked up to it here and then the outputs.
There's eight outputs those air hooked up to these ladies and so that that's thes eight blue wires that come over to the ladies and then through the ladies to ground and the 74 h c 595 doesn't have any kind of current limiting on the output.
So we need to make sure we have current limiting resistors there, so we don't, uh, push too much current through our ladies.
I also got pin 10 here tied to five volts.
And that's that Master reset.
So just by tying at the five volts, that's not gonna not reset.
Ah, and then pin 13 here is an output enable and so tied that to ground.
It's an active low.
So that just enables our outputs.
So then, beyond that, we've got these two inputs.
We've got our data input.
Here is the green wire, and then we've got our clock.
And so this should work very similarly to the shift register that that we already built.
In fact, we can hook it up to the same input.
So I'm gonna hook the clock to the same clock as as, ah, shit register that that we built before.
And I'm gonna hook the input, the data, serial data input into that same button there, and I'll hook up power as well.
And so now, whatever we clock in here should also get clocked in here because this chip should behave the same way as this eight stage shift register here.
So let me clock a few fits in here and you can see we've got 11011011 And that's the same thing that we've got down here.
11011011 So great.
Using just two pins and these could be two pins coming from our art.
We know we can control eight or even more.
We could we could cascade these like we could have the output.
The last output of this go into the input of another one of these seven for 85 95 and get 16 additional are 16 additional outputs here.
This is perfect.
But there is one other part of the 74 h c 595 that is important to understand and that is that there is this eight bit storage register.
And so there's this pin 12 which is the storied register clock pulse.
And what that does is it sort of serves as a as a register between the shift register and the output.
So what we what we've been seeing is that with each clock pulse, the data shifts in and we see it, you know, we see it shift as the clock pulse has come with The data shifts along like that.
But pin 12 what pin 12 lets us.
D'oh is if we type in 12 low like that, then we can shift data in here and it will just stay in the chute register.
It won't actually go to the output until we tell it to.
And that could be very nice, because we can put some data in here.
So there's some data and you see that that data is, you know, that it is getting shifted into the 7 45 95 Even though we don't see it on the output, it's in here.
All we need to do is then take this pin 12 this storage clock pulse, we take that high.
You see, now the data shows up on the output, and that could be very handy, because if you want to change all eight of these pins, you don't necessarily want to shift it around because who knows what that's gonna do to whatever this is hooked to?
You want to be able to set whatever you want on all eight of them simultaneously.
So let's say we want to turn all of these off.
We could just shift in Paul zeroes and then once all zeros air shifted in.
Then we just put that and it shuts them all off.
If you want to turn them all on, you can shift all ones in.
Once all the ones air shifted in, we could turn them all on.
And so, really, to use this properly, we want to use all three of these signals.
But that still gives us an awful lot because we can use three signals to control eight or 16 or 24 32.
However, many, uh, outputs we want control.
So the 7 45 95 is definitely gonna help us overcome this problem of not having of pins on the Arduino.
Okay, so we determine that we're gonna need two of the 74 h c 595 So let's add two of them to our board here, and it will hook up power and ground to both of these.
We could also tie 10 pin 10 which is that Master reset.
We could just tie that high because we're not going to be using that.
Then we can also type in 13 which is the output enable we can tie that low because we always want the output to be enabled.
Now, coming from our do we know, we're gonna have our serial data.
Our shift register clock and our storage register clocks of those three pins 14 11 and 12 as a pen 14 is our serial data.
And that's gonna be de tu on Arduino d two is going to go to pin 14.
Then d three is going to go to pin 11 which is the shift register clock pulse and then d three on the Arduino is going to go over here.
Thio pin 12 which is the storage register clock pulse.
So with these three signals, we can push data into the shift, register and control the eight outputs, which are these pins over on this side.
And I think one over here.
Now hook up the second shift register conveniently.
They give us a tap here for this this last bit because if we're clocking data in here, that data first gonna go to this bit and then it's going to shift its way along here until it gets to this last bit and want to able to keep shifting it into the next chip.
And so what we want to do is connect Pin nine of the first chip back into pin 14 which is the serial data input of the second ship.
So we hook pin nine here to pin 14 that provides the input for this next chip, and then the clock should be the same.
Actually, both clocks should be the same to the shift register clock from the first ship is hooked to the ship registered clock.
The second ship.
And that's the same shit register clock that's coming from the Arduino in the same thing for the storage register clock.
And so those clocks are all just hooked up the same.
So now from the Arduino, we should be able to just with these three pins, push data out into all 16 of these outputs.
So before we get too far and start hooking, Ari prom up and everything be good idea to test to make sure this is actually working the way we think it is.
So for that, I've got another board here with a bunch of ladies and resistors hooked up that we can hook up to the outputs of our shift registers just to see that they are, in fact, working.
I've got 11 led is here, even though they're 16 outputs.
But I think that's okay, because we're only gonna be using 11 of these outputs for the address lines because there's only 11 address lines, so I'm just gonna hook these up in order.
And so the outputs for these 7 45 9 fives are pins 15 and then one through seven.