What is analog handled by Microcontroller? What is digital? [Let's start here]
The first concepts to understand when dealing with MCUs are analog and digital. Many people may be surprised that they cannot explain what the difference is between analog and digital. This chapter explains both concepts in an easy-to-understand manner, which is very important when dealing with MCUs in Basics of Embedded Technology section.
What is Analog?
Analog means a continuous physical quantity. For example, sound and light intensity in nature are continuous analog quantities. When these quantities are converted electrically and observed, they are continuous waveforms.
A long time ago, vinyl records and cassette tapes were typical of analog, in which information was recorded from the original sound so that it could be reproduced as information in the shape of grooves in vinyl records when recorded, while cassette tapes record information by means of magnetism.
Since these media, as they are called, are recorded with analog information, they deteriorate over time. It is also called noise. In the case of vinyl records, the sound is blurred, and in the case of cassette tapes, the sound stretches or shrinks due to the stretching of the tape itself, etc.
What is Digital?
The digital concept, popularized with the advent of computers, is a method of representing discrete numbers for continuous physical quantities in nature.
A discrete number is a number that represents a certain quantity separated by a short period of time (sampling period). The process of time dimensioning is called sampling, and the process of quantization is called quantization of the magnitude of a quantity into a discrete number.
Expressing the magnitude of these numbers as binary zeros and ones is called encoding. When we say that digital is a world of only 0s and 1s, we mean this encoding.
In addition, the shorter the sampling period, the closer the sampling period is to a continuous one, which in the case of sound, for example, is closer to nature and improves the sound quality.
The sampling period is called the sampling frequency, which is expressed, for example, as 44.1 kHz for CD sound quality; the sound on a CD is processed 44,100 times per second, so it sounds continuous to the human ear.
Analog information degrades, whereas digital information does not. For example, since CDs record encoded values on CD media, sound reproduction involves extracting these encoded values as digital values at a sampling frequency of 44.1 kHz, converting these digital values to analog values using a function called a Digital-to-Analog (DA) converter, and then recording the analog values on a CD. The sound is represented as sound.
There seems to be a great deal of misunderstanding about this digital degradation, but the answer is obvious when you consider the nature of digital. Images and sound sources may deteriorate due to compression during copying, but this is a data conversion problem, not a deterioration of the digital itself due to copying.
The important point here is that although the information that can be handled inside MCU is only digital values, everything is ultimately analog because this world is made up of analog things.
For example, a digital sound source is converted to an analog sound source by a DA converter inside MCU, but this sound source is in the state of an analog voltage signal, so nothing can be heard as it is.
It is necessary to interface analog technologies such as analog electronic circuits (amplification circuits) that amplify minute analog signals as faithfully as possible until they become audible to the human ear, and headphones that reproduce the amplified analog signals with the best possible sound quality.
It is important for embedded engineers to have a basic understanding of the interface, which is the link between the digital and analog worlds.
Analog and digital I/O handled by MCU
There are two types of inputs and outputs to a MCU: analog and digital. Analog input is the conversion of various physical quantities in nature into electrical signals by sensors. Analog input requires a process called AD conversion to convert it from analog to digital so that MCU can process it.
In contrast, switch states, repetitive ON/OFF (0 and 1) pulses, or signals according to various communication standards are digital inputs that can be processed directly by MCU.
MCUs take in inputs, process them digitally according to programming, and output them as electrical signals, which can be either analog or digital.
When outputting as an analog signal, the information processed by MCU must be converted from digital to analog, a process called DA conversion. The electrical signal output as an analog signal is converted to the desired physical quantity by a conversion device (amplifier) according to the purpose.
In contrast, state outputs that can be turned on or off, pulse at a desired frequency, or output according to a communication standard are called digital outputs.
I hope you now understand that analog and digital are very important concepts when dealing with MCUs.
The image of analog as old and outdated and digital as new is a misnomer far removed from its original meaning, but I hope that you now understand that digital is simply a latecomer to the analog world originally found in nature, and that old and new are not comparable in dimension.
Among digital technologies, the advent of MCUs, in particular, has made it possible to realize highly functional devices at lower cost and in smaller sizes because they can be configured using familiar programming (software), whereas in the past they were configured using analog circuits (hardware), which required both sense and experience.