Digital Signals

Created:  
Updated:   06Aug2024   03:10:58   UTC 2024-08-06T03:10:58Z
Rating:   (0 reviewsThis article has not been rated yet)

Digital signals represent data as a discrete sequence of voltages over time in contrast to analog signals that are continuous values over time. Binary or logic digital signals have two voltage values: usually one near the reference voltage (ground or zero volts) and the other at the positive I/OInput/Output supply voltage (VS). The ground voltage is represented by binary digit bit 0 and the supply voltage is represented by the binary digit bit 1, as illustrated in the figure below.

Digital Binary Logic Signal

Digital signals can be pulses from a sensor/meter or represent information like numbers, text, audio, images, and video. The transmission of digital signals are more resilient to noise and interference than analog signals, and transmission errors can be detected and corrected. Digital data can also be encrypted, compressed, stored in memory, and edited.

This introduction to digital signals covers its usage, waveform properties, bit ordering, voltage level encoding, and timing.

Usage

Digital signals are output from a wide variety of sensors. These can output as simple on/off or detection states such as push buttons switches, magnetic contact switches used for a door/window alarm, tilt switches, vibration switches, IRInfrared beams, PIRPassive Infrared motion sensors, rain detection sensors, etc. Digital sensors are not just limited to detection of an event, but can also output numerical measurements of temperature, pressure, light intensity, distance, acceleration, rotation speed, and more.

Digital temperature sensors output the digital reading of temperature and some can be set with threshold alarms as a thermostat. Electronic temperature is usually measured with materials that have temperature dependent electrical properties, such as the resistance in thermisters (e.g., DHT11/DHT22), the Seebeck effect in thermocouples, or the internal bandgap reference of a PN junction diode in a silicon bandgap temperature sensor (e.g., MCP9808). These produce small variations in analog voltage that can be amplified and passed into an ADCAnalog-to-Digital Converter (ADC, A/D, or A-to-D) to give a digital output. In some cases temperature can be measured directly to digital as in the DS18B20 sensor, by having two oscillators, one that is temperature stabilized and the other temperature dependent, where the difference in frequencies correspond to a temperature.

Distance can be measured with an Ultrasonic Range Sensor that has a digital output. The output goes high when an ultrasonic burst is transmitted and remains high until the sensor receives the echo. The distance can be computed by clocking the time the output is high and using the known velocity of sound in air (340 m/s): the distance in meters is (high level time in seconds) x (340 m/s) / 2.

Rotation speed can be measured from the pulse interval of an IRInfrared beam interruption, reflection in digital tachometers, or a hall effect sensor near an oscillating magnetic field (e.g., having magnet on the rotor with a hall effect sensor as used in water flow sensors). These sensors output digital pulses at a rate that corresponds to the rotation speed of the object measured.

Acceleration can be measured with digital accelerometers using the piezoelectric effect (when microscopic crystal structures get stressed by acceleration forces a voltage is generated) or by changes in capacitance (when forces move internally capacitive plates), or other methods. These small internal voltage changes are usually amplified, converted into a digital value with an ADCAnalog-to-Digital Converter (ADC, A/D, or A-to-D), and output with a digital communication protocol such as I2CInter-Integrated Circuit. Also referred to as IIC or I2C. or SPISerial Peripheral Interface.

Properties of a Digital Signal

Useful information from a digital signal can be obtained from the following properties:

  • voltage levels representing logic states
  • number of state transitions
  • the fraction of a signals period in an active state, called the duty cycle
  • timing of state changes

In the simplest case with a switch, the voltage levels reveal whether its on/off, the number of logic transitions tells you how many times the switch was turned on/off, the time spent in each logic state says how long the switch was on/off, and the time between states provides how often the switch was flipped.

These properties of digital signals play a significant role in interpreting data from an electronic system. The number pulses from a water flow sensor tells you how much water has flowed through a hose/pipe and the time interval between pulses can be used to determine the water flow rate. The duty cycle of a digital signal can determine motor speed. The timing of digital communication signals is involved in data transfer speed, synchronization, and sampling.

The properties of a digital signal can also be used to facilitate the transmission, reception, and interpretation of digital data. These include

  • Bit ordering
  • Encoding (voltage pattern)
  • Bit rate and Baud rate
  • Bandwidth

Each of these properties will be covered in the following sections.

Digital Signal Waveform

A digital waveform can be characterized by logic states, their transitions, and how long in each logic state, as shown in the figure below. The time within a logic state is called the bit interval denoted by t. Logic state changes are triggered either by the rising edge or falling edge. The rising edge is the transition from low voltage to high voltage, whereas the falling edge is the transition from a high voltage to low voltage.

Digital Signal Waveform Components

In the real world, these transitions do not occur instantaneously due to waveform distortion. In that short transition time there is ramp up/down that is shaped by noise, attenuation, and/or high impedance. This distortion rounds the corners near the start and end points of the transitions. How do you define the rise time and fall time with rounded corners? They are defined in terms of percentages of the peak voltage of the high state as illustrated in the figure below: the rise time is defined as the time for the waveform to rise from 10% to 90% of the peak voltage (Vp) and the fall time and the time for it to drop from 90% to 10% of Vp.

Digital Signal Waveform Distortion

Bit Ordering

Suppose we want to send the number 45 serially over a transmission line. The number 45 is 00101101 in binary. Is this binary data transmitted from left to right (00101101) or right to left (10110100)? The order in which the bits are transmitted over a communication channel is called Endianness. There are two types of endianness. Little-endian has the Least Significant Bit (LSBThe Least Significant Bit (LSB) in a binary number is the bit that represents the smallest place value carrying the lowest weight. It is also sometimes referred to as the low-order bit or right-most bit due to the convention in positional notation of writing less significant digits further to the right.) sent first and Most Significant Bit (MSBThe Most Significant Bit (MSB) in a binary number is the bit that represents the largest place value carrying the most weight. It is also sometimes referred to as the high-order bit or left-most bit due to the convention in positional notation of writing less significant digits further to the right.) sent last (10110100). Big-endian transmits the MSB first and the LSB last (00101101).

Little-endian Serial Bit Ordering (LSB First, MSB last)
Big-endian Serial Bit Ordering (MSB First, LSB last)

Which method is used depends on the device and protocol. The standard for UARTUniversal Asynchronous Receiver-Transmitter is little-endian (LSBThe Least Significant Bit (LSB) in a binary number is the bit that represents the smallest place value carrying the lowest weight. It is also sometimes referred to as the low-order bit or right-most bit due to the convention in positional notation of writing less significant digits further to the right. first), whereas I2CInter-Integrated Circuit. Also referred to as IIC or I2C. is big-endian (MSBThe Most Significant Bit (MSB) in a binary number is the bit that represents the largest place value carrying the most weight. It is also sometimes referred to as the high-order bit or left-most bit due to the convention in positional notation of writing less significant digits further to the right. first). The SPISerial Peripheral Interface protocol does not specify endianness and comes preconfigured in the device and/or allows this to be configured in software (e.g., in the Arduino SPI library, this is controlled by the setBitOrder() function). Big-endianness is the dominant ordering in networking protocols, such as in TCP/IPTCP/IP is a suite of internet communication protocols. TCP (Transmission Control Protocol) is responsible for establishing reliable, ordered data delivery, and handling congestion control, while IP (Internet Protocol) focuses on routing packets of data to their destination..

If endianness is not specified on the device and you have no idea, you will have to use a logic analyzer or oscilloscope to record the signals and then try to find the markers in the data to decipher the order (easier said than done).

Voltage Levels

When digital data is sent over a transmission line the bits are encoded into a pattern of voltages called a line code to represent the digital data. A digital signal can be encoded to alternate between positive and zero volts, between a positive and a negative voltage, or between positive, zero, and negative volts.

Encodings

The three main categories of digital encoding are:

Unipolar:
All the voltages are on one side of the axis. Usually a positive voltage represents a binary 1, and zero volts indicates a binary 0.
Polar:
Has positive and negative voltage levels. Usually a positive voltage represents a binary 1 and a negative voltage indicates a binary 0.
Bipolar:
Has three voltage levels: positive, negative, and zero. The zero level represents binary 0, and binary 1 is represented by alternating positive and negative voltages.

During the bit interval, the signal can remain at the binary voltage level assigned to it for the entire bit time in a non-return-to-zero (NRZ) encoding or go to zero volts during the bit interval in the return-to-zero (RZ) encoding. These different encodings are illustrated in the figure below.

Serial Binary Encodings

Manchester encoding, also referred to as biphase encoding, is used in Local Area Networks (LANLocal Area Networks). This encoding can be unipolar or bipolar that has a transition in the center of each bit. A 1 is transmitted first as a positive pulse for the first half the bit interval and then as a negative pulse for the remaining time of the bit interval. A 0 is transmitted as a negative pulse for the first half the bit interval and then as a positive pulse for the second half of the bit interval. This transition at the center of the bit interval facilitates synchronization, but at the cost of doubling the bandwidth.

There are many more encodings that exist, which are beyond the scope of this article as an overview of digital signals, but a more comprehensive list can be found on Wikipedia and javatpoint.com.

Encoding Trade-Offs

Why are there different encoding schemes? There are several reasons with trade-offs that are justified depending on the application and equipment used, but the two most common reasons deal with transmission synchronization and average DCDirect Current buildup.

Synchronization:
Transmitters and receivers have a tendency to get out of synchronization with each other. If the transmitter sends a long string of consecutive 1s or 0s, it is difficult to keep both devices in sync with each other because there is nothing in the data that can be used to recover the timing. Transitions act like a clock pulse that helps the devices stay synchronized.
Average DCDirect Current Buildup:
With the simple unipolar encoding an undesirable average DC buildup occurs on transmission lines due to the charging of line capacitance. Using bipolar signals helps, where the positive pulses can cancel the negative pulses to average the DC voltage to zero, but does not eliminate the problem completely.

Standard communication protocols, such as UARTUniversal Asynchronous Receiver-Transmitter, I2CInter-Integrated Circuit. Also referred to as IIC or I2C., and SPISerial Peripheral Interface, that are used microcontroller boards, SBCSingle Board Computers, and USBUniversal Serial Bus Serial Adapter devices have the simple unipolar NRZNon-Return-to-Zero encoding. For 5V devices, the voltage levels typically alternate between 0V and 3.3V to represent logic bits. For 3.3V devices, the voltage levels alternate between 0V and 5V. Different encodings are typically used in applications over a longer distances and to recover the clock so the signals are not out of synchronization. Since I2C and SPI have a separate clock line for synchronization, clock recovery is not required. With UART the baud rate is configured for both the transmitter and receiver, and the start and end bits are included in the transmitted data, so clock recovery is also not required.

Digital Timing

This section covers basic concepts and terminology related to the timing of a digital signal.

Frequency and Period

The period of a signal is the time interval it takes for the signal to repeat itself. The frequency of a signal is the number of repetitions (cycles) that occur in a specified amount of time (expressed in cycles/second or Hz). A signal's frequency is inversely related its period. A digital signal does not necessarily have to be periodic, especially if the voltage pattern represents binary data. A digital signal waveform is composed of the sum of an infinite number of sine waves, a fundamental sine wave plus many harmonics. For digital signals that are not periodic, the highest fundamental frequency of that digital signal with alternating 1s and 0s can be used to define the frequency.

Frequency and Period of a Digital Signal

The highest fundamental frequency depends on the type of encoding used. The figure below shows this for the different encodings discussed in the previous section.

Highest Fundamental Frequency for Different Encodings

Duty Cycle

The duty cycle of a signal is defined as the percentage or fraction of a period a signal is high or low (whatever state is considered active). Duty cycle is typically expressed as a ratio or percentage. The duty cycle the amount of "on time", which is different than the frequency of a signal. For example, the figure below has two repeating signals with the same frequency, but different duty cycles. The top signal has a duty cycle of 50%, whereas the bottom signal has a duty cycle of 25%.

Duty Cycle of a Digital Signal

A duty cycle of 100% is the same as setting the voltage to a constant "on" (or high) state. A 0% duty cycle would be the same as the signal in a constant low ("off" or grounded) state.

Bit Rate and Baud Rate

The data transfer speed of serial transmissions is usually indicated by the value of the bit rate or baud rate.

Bit Rate:
The bit rate is the number of bits that occur in a given unit of time, expressed as bits per second (bpsbits per second or bit/s). You may also see the bit rate expressed as bytes per second (B/s), which corresponds to 8bit/s. The bit rate is the reciprocal of the bit interval t, or bps = 1/t. For example, if the bit time is 104.17μs, the bit rate is bps = 1/104.17μs = 9600bps.
Baud Rate:
The baud rate is the number of signaling elements or symbols that occur in a given unit of time. This symbol rate is measured in baud (Bd) or "symbols per second". The signaling element or symbols is some change in the binary signal, where each symbol may encode one or several binary digits (bits). If the system has only 2 symbols (on/off or high/low) transferred, then the baud is equivalent to bits per second (bpsbits per second) (e.g., 9600 baud means that data is being transferred at 9600 bits per second). In general, the bit rate is related to the baud rate by the equation in the figure below.
Bit Rate and Baud Rate Equation

As an example of more than one bit per symbol, consider a system that has 2 bits per symbol. This has 2bits/symbol = 22 = 4 possible voltage levels. Assigning 0V, 1V, 2V, and 3V to each of these bit pairs is shown in the table below.


2Bits/Symbol
Bits Voltage Levels
00 0V
01 1V
10 2V
11 3V

Suppose we want to send the number 45, which is 00101101 in binary, serially one symbol (voltage level) at a time every 104.17μs (9600 baud). The transmission voltage sequence from the LSBThe Least Significant Bit (LSB) in a binary number is the bit that represents the smallest place value carrying the lowest weight. It is also sometimes referred to as the low-order bit or right-most bit due to the convention in positional notation of writing less significant digits further to the right. to MSBThe Most Significant Bit (MSB) in a binary number is the bit that represents the largest place value carrying the most weight. It is also sometimes referred to as the high-order bit or left-most bit due to the convention in positional notation of writing less significant digits further to the right. would be 1V (01), 3V (11), 2V (10), 0V (00).

Example of 2 Bits Per Voltage Level

The bit rate is now double:

bit rate = baud rate x bits per symbol
bit rate = 9600 x 2 = 19200 bps

The bit rate is greater than the baud rate because there were multiple voltage levels, each representing more than one bit.

Bandwidth

In digital signals, bandwidth is used to refer to the maximum data transmission capacity (in contrast to analog signals where bandwidth is defined as the range of frequencies that can be transmitted by a particular system or medium). The bandwidth of a digital system using wired transmission depends on the physical characteristics of the wires: the inductance and capacitance per foot, its length, size of the conductor, and the type of insulation. All wire cables have inductance, capacitance, and resistance that act as low-pass filters: the signal's harmonics that are higher in frequency than the cutoff are filtered out and distort (round off) the signal as it travels through the wire. A simple model of this is shown in the figure below.

Transmission Line Model

Inductive or capacitive coupling between wires can also cause cross talk, the undesired transfer signals from one wire to another. On old analog telephone lines, you could sometimes hear other conversations in the background of your call from crosstalk. To prevent this, the transmission wires are twisted together at different rates so the distance between the wires varies along the length of the run. Shielding the cables also provides some protection from crosstalk and interference from other noise sources.

The encoding method used also affects the bandwidth. For example, the bandwidth of RZReturn-to-Zero is twice that for NRZNon-Return-to-Zero. The fundamental frequency contained in a digital waveform is the same as the highest frequency pulse. This was shown by the dashed sine waves in the previous figure on the Highest Fundamental Frequency for Different Encodings.

Another aspect of bandwidth is noise. Increasing the bandwidth gives higher transmission rates, but allows more noise to pass. This tradeoff puts limits on the channel capacity to ensure reliable transmission.

Conclusion

This introduction to digital signals covered its usage, waveform properties, bit ordering, voltage level encoding, and timing. Understanding the properties and usage of a digital signals is the first step to interfacing for data acquisition in order to read in data and communicate with devices. The next step is to understand the electrical characteristics of digital inputs and the compatibility between devices that are covered in the articles below.

Related Content


Digital Input into a Microcontroller or Single Board Computer

Created:   11Aug2022   19:03:45   UTC 2022-08-11T19:03:45Z
Updated:   06Aug2024   05:16:16   UTC 2024-08-06T05:16:16Z
Rating:  (0 reviewsThis article has not been rated yet)

Covers the electrical characteristics of digital inputs into the GPIO of a microcontroller board or single board computer: voltage thresholds, leakage current, pull resistors, and maximum voltage and current levels.

Interfacing Digital Input with Signal Coverter Circuit

Created:   27Mar2023   22:51:48   UTC 2023-03-27T22:51:48Z
Updated:   24Jun2024   08:11:19   UTC 2024-06-24T08:11:19Z
Rating:  (0 reviewsThis article has not been rated yet)

Covers the electrical compatibility of a microcontroller board or single board computer with external devices: Voltage Dividers, Level Converters/Shifters, Over-Voltage Protection, and Electrical Isolation.

Article Rating

Sign in to rate this article

Sign In


(0) Comments

Sign in to leave a comment

Sign In