Signals Handled by MCUs
Understanding Analog and Digital Signals
An explanation of analog and digital signals.
Analog signals change continuously over time, while digital signals consist of discrete (stepwise) values.
Below are the characteristics of each.
Analog Signals
A key characteristic of analog signals is their continuity. They contain an infinite number of intermediate values, forming a smooth, uninterrupted line when graphed. In fact, analog signals exist all around us.
Digital Signals
In contrast, digital signals are discrete rather than continuous. This means they lack smooth transitions, appearing as stepwise changes when graphed. An important feature is that they consist only of 0s and 1s.
Why Digital Signals are Necessary
Most signals around us are analog, requiring special circuits to interface with digital systems. However, digital circuits are preferred in many applications due to their smaller size, lower power consumption, and greater resistance to signal degradation.
Analog signals contain intermediate values, making them prone to degradation due to slight variations (changes) in components. To minimize these effects, larger components are required, limiting their ability to be miniaturized. At the same time, maintaining an intermediate voltage level requires constant current flow, leading to a trade-of between power consumption and circuit size.
Digital signals, on the other hand, have only two states: maximum and minimum. They can be generated by turning components ON or OFF, making the less susceptible to component variations. This allows for smaller circuit sizes while eliminating the need for continuous current flow, reducing power consumption.
Next we will discuss signal degradation. As mentioned earlier, analog signals represent continuous values, meaning they can take intermediate values like 0.3 or 0.75 between 0 and 1. When these signals are stored or transmitted, they can degrade over time. For example, if a signal of 0.75 is stored but degrades to 0.7 after a few years, the original data is not preserved. Similarly, if a signal of 0.3 is transmitted but 0.4 was received, the original data was not accurately sent. This degradation is a fundamental drawback of analog signals.
In contrast, digital signals consist of only 1s and 0s. A threshold, typically around 0.5, determines whether a signal is interpreted as a 0 or 1. Revisiting the previous example, if a stored value of 1 degrades to 0.9 over time, it is still recognized as 1 since it remains above the threshold. Likewise, if a transmitted signal intended as 0 is received as 0.1, it is still interpreted as 0. This method makes digital signals inherently more resistant to degradation.
Digital data storage relies on encoding information as sequences of 0s and 1s. For instance, in ASCII character encoding, the letter ‘a’ is represented by the sequence 01100001. Beyond ASCII, various other encoding standards exist, enabling not only character representation but also the storage and transmission of images, audio, and other forms of data entirerly in binary format.
Internal MCU Signals
As previously mentioned, the internal processes of the MCU utilize digital signals that offer excellent reproducibility. However, most real-world signals are analog. Therefore, when inputting signals into an MCU, analog-to-digital (A/D) conversion is required to transform the signal into digital format, enabling complex operations such as calculations and analysis. Conversely, when outputting processed results as analog signals, digital-to-analog (D/A) conversion is performed. This makes A/D and D/A conversion essential functions for an MCU.
Binary and Hexadecimal
Digital circuits can be represented entirely by transistors, where the output state is either H (High) or L (Low). By assigning H=1 and L=0, the circuit's state can be expressed in binary. This mathematical representation of digital circuits led to their rapid development, making binary an essential numbering system for handling digital signals.
The decimal numbers from 0 to 7 can be written in binary as follows.
0=0b000
1=0b001
2=0b010
3=0b011
4=0b100
5=0b101
6=0b110
7=0b111
Here, the prefix 0b is used to indicate that the number is in binary format, with the b derived from 'binary.'
Another important numbering system in digital signal processing is hexadecimal, which uses the digits 0 to 9 and A to F to express decimal numbers from 0 to 15 as follows.
0=0x0
1=0x1
2=0x2
3=0x3
4=0x4
5=0x5
6=0x6
7=0x7
8=0x8
9=0x9
10=0xA
11=0xB
12=0xC
13=0xD
14=0xE
15=0xF
The prefix 0x indicates that the number is in hexidecimal format ('x' for hexidecimal).
Binary and Hexadecimal Conversion
In the decimal system, large numbers can become cumbersome when expressed in binary. For example, 255 is written as 0b11111111, which is lengthy and prone to misreading. However, using hexadecimal, the same number can be written as 0xFF, reducing the number of digits and minimizing errors. This is one of the key advantages of hexadecimal notation.
Another reason hexadecimal is preferred over of decimal is its ease of conversion from binary.
For example, converting 0b0010110011111000 to hexadecimal can be done by grouping it into 4-bit segments and converting each segment. In this case, 0b 0010 1100 1111 1000 = 0x2AF8.