An intelligent digital system needs memory. I explain here how memory is implemented using electronics.
Everyone has seen an electric keyboard on a house wall. We can put any of the keys to either ON or OFF state. There is no third state possible. Now once a key is made ON or OFF, the state doesn’t change on its own. This key continues to be ON till it is made OFF and vice versa. So this array of keys represents a binary number at any given instance.
If 1 means ON and 0 means OFF, the key array on the wall will represent the binary number say :
1 0 1 1
The left most key is most significant and the right most is least significant. (This is very similar to our normal decimal number system.)
In electronics, Hi state (means 1) is represented by +5V and Lo state (means 0) is represented by 0V. A transistorised circuit has this ability of changing and maintaining the output state. This circuit outputs “1” when its control terminal is “set” and outputs “0” when its control terminal is “reset”. The circuit output maintains its state till it is changed deliberately using its control terminal. This circuit is known as a “Flip-Flop”. The circuit is stable in any of the two states at a given instance so it is also called as bi-stable multi vibrator.
A digital intelligent system works on binary numbers. Binary numbers are stored in registers which are like keyboard arrays. Registers are made of flip-flops. Flip flops are bistable multi vibrators. They can be stable in either of the state Hi or Lo. This simply means that a binary number can be stored in an array of flip-flops easily. We can change its value using control terminals and leave the array as it is till we want to change it. Each flip flop can store only two values 0 or 1. This smallest unit of memory (flip flop) is called a bit. Usually flip-flops are arranged in groups of 8,16,32,64. Each flip flop represents a bit. The 8 bit array is known as a byte. 16bit array is called as a word. The 32 bit array is called as the double word. 64 bit array is called as the quad word.
Well, everything is a number inside the micro controller. The flip flop array has an address (a number), data that is stored in an array is a number, an instruction is expressed in terms of numbers. So to deal with anything needs just to be a number. If the controller can process numbers, it can do anything.
In my earlier blog I explained how micro controller “understands time”.
The clock i.e. the crystal oscillator provides triggering pulses to the micro controller. Suppose at the 145th pulse, control terminals of a flip-flop array (say a byte) set the array value to be 235 and at 200th pulse the controller changes the number to 100. Then in the mean time, the number 235 is said to be “memorised”.
This system of storing numbers with reference to time, is called as the memory which can “remember” anything. Because anything is expressed as a number for a micro controller!