Introduction: DIY RAM for Your Micro
As you might know, my DIY RAM instrucables were quite popular a few months ago, well for a week. I showed you how to make a TTL RAM and a CMOS RAM. This time I am going to show you how to make a full byte of ram for your microcontroller**!!! It will use the CMOS version and be a D Latch based design, sorry for you TTL fans. That's next thought!!! We will be using the 74hc(t)00 Quad NAND gates.
**Restrictions apply. See back for details. Not valid in all States and Territories. Valid in some parts of Canada and most of Europe. No purchase necessary.
Step 1: The Stuff You Need to Have or Get
The Stuff You Need to Have or Get is what we will need for the RAM. (you think: Gee really?)
Its a much shorter list this time:
8 74hc00 or 74hct00 Quad NAND Gates. For the circuits used in this instructable, only these chips will work.
8 4.7k -10k resistors
8 small signal diodes - the common 1n4148 variety works well
A breadboard with at least 63 rows, or you will need more than 1.
Wire - it helps to connect things (you think: Is he for real here?)
Wire Cutters - (you already think: Let Me Guess...) Yup, they make cuttin' wire so nice!
Needle Nose Pliers - optional, but i find them nice for bending and placing wire.
8 Resistors (that work with the LEDs)
Step 2: Chips and Breadboards
What is nice about this ram is that each bit is self-contained on each chip. This means that 8 chips = 1 byte (8 bits) or 4 chips = 1 nybble!!!
With self contained ram bits, it is a lot easier putting them onto the breadboard. This is very opposite of the TTL RAM, which was complicated enough that you had to go transistor by transistor. The CMOS RAM was easier to place, but it was very large and cumbersome, so we only made 1 bit (that and it used all of my MOSFETS).
Basically, all you need to do is line the chips up down the board, and keep them oriented the same way.
Step 3: Wiring the Chips
Shown here is the basic wiring diagram for each of the chips. What it does is it turns the chip into a self-contained D-Latch. Remember the D latch? Well it used exactly 4 NAND gates for 1 D latch, and guess what, there are 4 NAND gates on a chip!!!
The wiring diagram should be easy to follow. The red lines that connect the pins are wires that you need to place on each chip. You do not need to place wires leading out on the D, CLK, Q, and NOT Q. I would recommend connecting you ground and supply pins to the rails though.
This configuration will not work with the 4000 series, because of conflicting pinouts, but for those of you who are going to comment and say "Can I use the 4011?" Or insert another 4000 series NAND gate there. I have provided the D latch schematic. You can find a 4011 datasheet and do it yourself.
Step 4: The Diode and Resistor
Well, your ram is just about done, the only problem is that the input cannot be connected to the output, meaning that you will need 8 microcontroller pins to send data to the ram, and 8 pins to fetch data from it. We don't want that, we just want to use 8 bidirectional pins to receive data and send it. How? A resistor and a diode.
What we are going to do is add a diode from the Q pin (either 10 or 11) to a free row on the breadboard. The black strip on the diode should be toward the free row pin. If it is toward the connection to the Q pin, it needs to be flipped around. Now you need to connect the diode to the Data input pin (pin 1) using the resistor. Repeat for all 8 chips.
Step 5: How It Works
The D Latch is a cool little device. I can store data by only changing its stored data when the clock signal is high. What it does is it latches onto a bit. If Q is on, it sends a HIGH signal to the input of NOT Q, this makes NOT Q turn off. This, in turn, sends a LOW to the input of Q, turning Q on. This is how it latches. Lets assume that NOT Q is high. When a HIGH signal is sent to the clock and data, a LOW signal is sent to Q and a high is sent to NOT Q. This makes Q turn on and NOT Q turn off. When the clock is set LOW, the data line has no effect, so the circuit latches.
In order to use the same pin to send and receive data, we had to add a resistor and diode between the Q and Data signals. We needed the diode because the latch can be affected by changes on the Q pin and diodes, as you know, only let current go one way, in this case, from Q to Data. The resistor was needed to limit the current going from Q to Data. Without it, the latch would get messed up, because Q would be pulled to ground.
Step 6: Interfacing to Your Microcontroller
Remember that joke I made in the Intro about the restrictions? Well there was some truth to that, It works in only some parts of Canada...No, just kidding, but you will need an 8 bit port to connect the data lines to and one more pin as the write enable. I have included a C code for AVRs and Arduino*.
*The RAMRead() function does not work right when the chip is on the board because pins 0 and 1 are attached to the FTDI chip, which messes up the reading.
Have Fun Saving a byte of internal Micro RAM!!