Electronics Components: Introducing Microcontrollers
A microcontroller is a complete computer on a single electronic chip. It can be purchased for $50 or less. Like all computer systems, microcomputers consist of several basic subsystems:
Central processing unit (CPU): The central processing unit executes the instructions given to it by the program. The CPU can perform all the operations necessary for the proper operation of the computer, such as transferring data from one location in memory to another or receiving data as input from the outside world.
Clock: The CPU and other components of the microcontroller are powered by a clock that provides timing pulses that control the rhythm of program instructions as they are executed one by one by the CPU. For most microcontrollers, the clock moves at a speed of a few million beats per second. In contrast, the clock that drives a typical desktop computer ticks at a few billion beats per second.
Random Access Memory (RAM): Provides a scratch area where the computer can store the data it is working on. For example, if you want the computer to determine the result of an arithmetic operation (such as two plus two), you need to provide a location in RAM where the computer can store the result.
In a desktop computer, the amount of available RAM is measured in billions of bytes (gigabytes for a gigabyte). On a microcontroller, RAM is often measured in bytes. That’s right: not billions (gigabytes) or millions (megabytes, megabytes) or even thousands (kilobytes, kilobytes) of bytes, but plain old bytes. For example, the popular BASIC Stamp 2 has a total of 32 bytes of RAM.
EEPROM: A special type of memory that holds the program that runs on a microcontroller. EEPROM stands for Electrically Erasable and Programmable Read-Only Memory, but that will not be in the test.
EEPROM is read-only, which means that once the data is stored in the EEPROM, the data cannot be changed by a program running on the microcontroller’s CPU. However, it is possible to write data to an EEPROM by connecting the EEPROM to a computer via the USB port. Then, the computer can send the data to the EEPROM.
This is how microcontrollers are programmed. You use special software on a computer to create the program you want to run on the microcontroller. Next, you connect the microcontroller to the computer and transfer the program from the computer to the microcontroller. Then the microcontroller executes the instructions stipulated in the program.
Most microcontrollers contain a few thousand bytes of EEPROM, which is enough to store relatively complex programs downloaded from a computer.
One of the most important features of EEPROM is that it does not lose its data when the power is turned off. Thus, once a program is transferred from a computer to the EEPROM of the microcontroller, the program remains in the microcontroller until you replace it with another program.
You can turn off the microcontroller and put it on a cabinet shelf for years, and when you turn the microcontroller back on, the program that was recorded years ago will work again.
I/O pins: One of the most important features of a microcontroller is its I/O pins, which enable the microcontroller to communicate with the outside world. Although some microcontrollers have separate input pins and output pins, most have shared input/output pins that can be used for both input and output.
Typically, the I/O pins use the basic TTL logic interface: HIGH (logic 1) is +5 V, and LOW (logic 0) is 0 V.
Most microcontrollers can handle only a small amount of current directly through the I/O ports. 20-25 mA is typical. This is sufficient to light the LED, but circuits that require more current must isolate the higher current load from the controller’s I/O pins. This is usually done using a transistor actuator.