Analog and digital signals

Date
Mar 18, 2023
Tag
Hardware

Analog & Digital

notion image
  • An Analog Signal is a continuous signals in both time and value.
    • Example: the temperate throughout the day is continuously changing and could not instantaneously change from 0°C to 10°C
  • A Digital Signal (or discrete-time signal) is a time series consisting of a sequence of quantities
    • Digital Signal can instantaneously change in value. This change is expressed in numbers as 1 and 0 (the basis of binary code)
    • In practical applications, we often use binary as digital signal, that is a series of 0’s and 1’s.Since a binary signal only has two values (0 and 1) it has great stability and reliability.
  • Both analog and digital signals can be converted to the other

PWM

PWM, Pulse-Width Modulation, is a very effective method for using digital signals to control analog circuits.
Digital processors cannot directly output analog signals. PWM technology makes it convenient to convert digital signals to analog signals.
PWM technology uses digitals pins to send certain frequencies of square waves (high level output and low level output alternately last).
  • The total time of each set of high levels and low levels is generally fixed, which is called the period (the reciprocal of the period is frequency)
  • The time of high level outputs are pulse width
  • The duty cycle is the percentage of the ratio of pulse width to the total period of the waveform
    • The longer the output of high levels last, the longer the duty cycle and the higher the corresponding voltage in the analog signal will be.
The figure shows how the analog signal voltages vary between 0V - 5V corresponding to the pulse width 0% - 100%
The figure shows how the analog signal voltages vary between 0V - 5V corresponding to the pulse width 0% - 100%
The longer the PWM duty cycle is, the higher the output power will be.
PWM is not actually analog but the effective value of voltage is equivalent to the corresponding analog value.

Hardware & Software PWM

The main difference between hardware PWM and software PWM is the method used to generate the PWM waveform.
Hardware PWM is generated by a dedicated hardware module on the microcontroller or microprocessor, while software PWM is generated by the software running on the microcontroller or microprocessor.
Hardware PWM is generally more accurate and consistent in terms of timing and duty cycle than software PWM. However, software PWM is more flexible and can be used on any pin of the microcontroller or microprocessor, while hardware PWM is often limited to a specific set of pins.
When using hardware PWM, the waveform is generated independently of the CPU, which allows the CPU to perform other tasks. With software PWM, the CPU must generate the waveform, which can cause the CPU to be busy and affect the performance of other tasks.
Overall, the choice between hardware PWM and software PWM depends on the specific application and the requirements for timing, accuracy, and flexibility.

ADC (Analog-to-Digital Converter)

An ADC is an electronic integrated circuit to convert analog signals such as voltages to digital or binary form consisting of 1s and 0s.
Any analog value can be mapped to one digital value using the resolution of the converter. The more bits the ADC has, the denser the partition of analog will be and the greater the precision of the resulting conversion.
For a ADC module with range as 8 bits, the resolution is , so that means its range (at 3.3V) will be divided equally to 256 parts.
notion image

DAC (Digital-to-Analog Converter)

The DAC module PCF8591 has a DAC output pin with 8-bit accuracy, which can divide VDD (here is 3.3V) into parts. When digital quantity is 1, the output voltage is . When digital quantity is 128, the output voltage value is 3.3/256 * 128 = 1.65V. The higher the accuracy of DAC, the higher the accuracy of output voltage value will be.

Reference