What's the Difference Between Digital and Analog I/O?
Posted on Jun 14, 2017 7:00 AM. 6 min read time
Analog and Digital I/O is a fundamental concept in robotics. What is the difference between them? We answer a question from the forum.
Over on our DoF forum, we get a wide variety of questions from the community. A Robotiq customer once asked "What is the real difference between analog and digital I/O? Which one should I use and when?"
This is a great question! Analog and digital I/O is a basic concept, but it is a fundamental one in robotics.
Catherine Bernier gave a great answer in the forum. I thought it was worth expanding on the topic here on the blog. I will answer the first half of the question in this article, and the second half of the question in the next article.
What Is I/O?
Let's start with the basics. I/O stands for "Input/Output." This means that we are talking about all the ways that a robot can interact with the real world.
Input usually refers to sensors, e.g. switches, potentiometers, cameras, etc. Output usually refers to the motors of the robot's joints, but it can also mean warning lights, alarms, etc.
For more information on robot sensor types, check out our eBook on adding sensors to robots.
The Differences Between Analog and Digital
There are two ways to differentiate analog and digital signals: by sensor type and by processing method.
In her forum answer, Catherine used a helpful example to explain the differences between analog and digital sensors. It involved using sensors to detect when a door opens and closes. I'll use the same example here, because I like it! It clearly demonstrates how different sensors can be used to detect the same real-world event.
Analog vs Digital Sensors
Imagine that you want to detect whether a door is open or closed. You set up two different circuits, each with a different sensor:
- An on/off switch placed on the door frame. This is a digital input. It will allow you to detect when the door is closed and when it is open, but will not detect anything between these states
- A potentiometer attached to the door hinge. This is an analog input. It will allow you to detect the amount that the door is open or closed. For example, you could use it to tell if the door was 50% open, 12.3376…% open, or any other amount between completely closed (0% open) and completely open (100% open).
Let's imagine that you attach a light bulb as an output to both circuits. This is an analog output. This is what will happen to the light bulb using both sensors:
- On/off switch. When the door closes, the light bulb will turn off. When it opens, the light bulb will turn on.
- Potentiometer. The light bulb will dim depending on the amount that the door is open. When the door is 25% open, for example, the light bulb will be at a quarter of its full brightness.
So far, so simple.
Analog vs Digital Processing
The second factor that differentiates analog and digital signals is how they are processed. This is where it starts to get interesting.
Analog and digital processing differ in two fundamental ways:
- How they handle time:
- Analog processing is continuous. As soon as an input changes, the output also changes. The only delay is the time it takes for electrons to move through the circuit, which is effectively instantaneous for robotic applications.
- Digital processing is discrete. When an input changes, there is a delay until the system registers the change. The length of this delay is determined by the "sampling frequency" and is controlled by a clock.
- How they affect resolution:
- Analog processing has a theoretically infinite resolution as the signal is not rounded. Like any infinite number, this infinite resolution is never achievable in practice.
- Digital processing can only handle signals which are represented as 0 or 1 (on/off). All signals must be reduced to a binary number, which involves rounding the value.
Let's go back to our door example.
To demonstrate the effect of time, let's apply the two different types of processing to our on/off switch. Here's how that would look:
- On/off switch with analog processing. As soon as the door opens, the circuit responds to the change and the light bulb turns on. When the door is closed, the light bulb immediately turns off.
- On/off switch with digital processing. Let's say that the sampling frequency is 0.1Hz. Every 10 seconds, the system reads the switch and sets the light bulb accordingly (closed=off, open=on). You could open and close the door many times within those 10 seconds and the light bulb would not change.
To demonstrate the effect of resolution, let's apply the two different types of processing to our potentiometer. Here's how that would look:
- Potentiometer with analog processing. The light bulb will dim to the exact amount which corresponds to the opening of the door. For example, if the door is open 18.128472…%, the light bulb will be 18.128472…% of its full brightness.
- Potentiometer with digital processing. Let's say that the signal is mapped to a two-bit number. This gives us four distinct values (0, 1, 2 and 3). When the door is fully closed, the value is zero; when it's fully open, the value is 3. Between these extremes, the system can only detect when the door is 1/3 open and 2/3 open. If the door is opened 20%, for example, this will be approximated to 1/3 of the full brightness of the light bulb.
In these examples, I have intentionally used a low frequency and a low resolution to demonstrate the effect of digital processing compared to analog processing.
In reality, robotic systems run at much higher performances. For example, the Robotiq Force-Torque Sensors use a sampling frequency of 100Hz, which means that they are updated every 10 milliseconds. The FT300 can effectively measure 600 discrete values (+/-300N in steps of 0.5N).
At face value, analog seems to give better performance than digital. However, in practice, digital signal processing has sufficient performance for almost all robotic applications. When run at high speeds, the difference between the two processing methods is hardly noticeable, and digital processing has some very important benefits.
Why Digital Is Better for Robotics
In practice, we use digital signals and digital processing for almost everything in robotics.
There are a few reasons for this, including that:
- Computer programs require digital signals. Some analog AI programs are starting to appear, but the vast majority of programs have no way to directly incorporate analog signals.
- Digital signals can be transmitted without interference by electrical noise. Analog signals are highly affected by noise.
- Digital processing is much cheaper and more versatile than analog processing.
Although digital signals are are better for robotics, the real world is analog and always will be. To reduce the effect of noise, analog signals are turned into digital signals as soon as possible in the process.
For example, a traditional Force Torque Sensor uses resistance-based strain gages, which produce an analog signal. To reduce the influence of electrical noise, the analog signal is immediately converted to a digital signal before it is transmitted to the robotic system. However, even though the signal is only analog for a very short time, they are still affected by noise.
The sooner you can convert from an analog to a digital signal, the better. In contrast to traditional sensors, the Robotiq Force Torque Sensors use a unique type of capacitance sensor which uses AC voltages. The signal that they produce begins as a digital signal, which makes them highly noise-resistant.
Read our force sensor eBook to find out more about how these sensors work.
Do you have any questions about analog and digital I/O? What other fundamental robotics questions would you like answered? Tell us in the comments below or join the discussion on LinkedIn, Twitter, Facebook or the DoF professional robotics community.
Leave a comment