DIY RAM for Your Micro

24K6120

Intro: 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.

Optional:
8 LEDs
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!!

21 Comments

What if I wanted to use 32 quad NAND gates to make 4 byte ram, could I multiplex them or use some other method to reduce the digital pins needed from the Arduino.

What I would recommend is buying some inverter (NOT) logic chips as well as AND logic gates and wiring them together to make a 4 to 16 line decoder. This way you could have up to 16 bytes of RAM using only 14 pins.

Something like this? But, with 4-16 de-mux & 16-4 mux instead of the 1-2 de-mux & 2-1 mux. As well as, 16 Octal D-flipflops instead of the 2 in my diagram.

I could also use a line driver instead of the analog switch.

You just need a decoder which can decode binary inputs, and put out the enable lines to go to the enable lines for the D-latches. One way to do this is to buy some 4-input AND gates (or make your own out of several 2-input AND gates), and use some not gates in combination with them to complete the decoder. If you need some more help I would be happy to create a schematic for you.

That would only allow you to write to the D-Latches. The schematic I provided allows you to read the current state of the latches by setting ~R/W to LOW, setting Address & Reading data lines. My circuit also allows for Writing to the latches by setting ~R/W to HIGH, Setting Address & Data lines, then clocking CLK.

By adding a few additional gates you could easily use my system to address 8 bytes of RAM using only 10 pins. If you used a few more gates you could make a system which uses only 6 pins.

To do the 10 pin version basically all you need to do is use the decoder system I described before, but add some AND gates between the decoder and the EN pins for the D-latches. You also want to add AND gates between the outputs and the arduino pins. The output's AND gate's inputs should be wired to the output pin from the decoder, to the read enable, and to the output of the D-latch. The output from the AND gate should go to the arduino pins you're using for data output. Oh yeah, and the AND gate between the EN pin and the decoder is for write-enable, so wire one input to the decoder output, one input to the write-enable pin, and the output to the D-latch EN line.

To attach it all to the arduino you need to connect 4 pins to the arduino to act as address pins, 4 pins to act as data output pins, one pin to act as read-enable, and one pin to act as write-enable.

This project seems really cool. Any news on the core memory possibility?

NAND gates? so that would effectively make it an SSD?
No, SSD's are not the same. Flash memory is very different than RAM. Flash memory retains it's contents after power has been removed whereas RAM requires power and, when dynamic, constant refreshes. Flash memory is based on EEPROM technology and is fairly new (developed in the 80s I believe).

Not true, not true at all. That's why there are sub-categories of RAM called "volatile" and "non-volatile". Non-volatile means it retains it's data even after its power is remover. An example of this is core-memory (not to be confused with core-rope ROM), both of which were used on Apollo.

Could you send me the full Arduino code? I am not sure how to program the write enable part.

Hi I have 4 DRAM ICs each 256kb so 1Mb in total IC part number:MT4C4256-8 can i use them it with arduino?
does the readRam{}; command work with arduino uno r2 or r3 ? Please some body answer me
cant you replace the NAND gate chips with transistors?
Yes you could, i wrote an instructable on that a while ago, just search "cmos ram"
Could you dramatically improve size/storage ratio by using integrated D-Latch chips?

Nice instructable!
I could, but that's boring!!!
next step use a set of nmos trans, via nmos logic inverters with depletion nmos load.
that's quite fun.
Fair enough ;) I think it's great that you've done it the way you did, so that people have a better idea of what's going on inside RAM. After all the symbol for a D-Latch is just an ambiguous box, whereas you can actually see what an inverter does.
Well thats great. I always need an extra byte for my arduino ;-). No, really: cool instructable!
More Comments