The physical world is analog and if we want to interface with it using a digital device there are conversions that need to be made. To do this we use an Analog to Digital Converter (ADC) for translating real world analog quantities into digital values. But we can’t just dump any analog signal into the input of an ADC, we need this analog signal to be a measurable voltage that’s clean and conditioned. Meaning we’ve removed all the noise and converted the measured value into a usable voltage.
Things That Just Work.
This is not new information, least of all to Hackaday readers. The important bit is that we rely on these systems daily and they need to work as advertised. A simple example are the headlights in my car that I turned on the first night I got in it 5 years ago and haven’t turned off since. This is not a daytime running lights system, the controller turns the lights on when it’s dark and leaves them off during the day. This application falls into the category of things that go largely unnoticed because simply put: They. Work. Every. Time. It’s not a jaw dropping example but it’s a well implemented use of an analog to digital conversion that’s practical and reliable.
Sensors and Transducers
These might seem like synonyms, and they are sometimes used interchangeably but they are two different things. A measurement system is made up of three parts: a sensor, variable conversion element, and signal conditioning. The confusion between a sensor and a transducer is understandable since one of them includes the other, but not the other way around. A sensor is a device that measures a physical quantity and outputs a variable. The variable output from a sensor is not always a usable signal, which is the difference between a sensor and a transducer. A transducer measures a physical quantity (sensor) and converts the output variable to a usable signal. It’s kinda like the concept that every square is a rectangle but no rectangle is a square. Blink if you’re still with me, well, I’m moving on anyway.
Sensors are used to directly measure the chosen input variable, in our headlight example the input variable is light intensity. The sensor used in this case would be a photocell. Let me curb some needless comments here and agree with you: yes, they are also called light dependent resistors, photoconductive photocells, and other names I’m sure. The way a photocell works is that the resistance across the cell changes over a set range with changes in light of a specific wavelength. Let’s have a closer look at what that means in a practical situation.
You can see from my demonstration photos that for the given photocell there is a resistance of 500 Ohm in a well lit environment and a resistance of 3.5M Ohm in a dark environment. Yes I am rounding the values to make nice round figures but for our purposes this is just fine, mainly because I decided it to be. If we were to design a measurement system using this photocell we would take some more detailed and specific data but we’ll assume our way through this fantasy build.
I mentioned sensors and transducers were akin to squares and rectangles, some of you will complain about that analogy but I’m sticking with it. A transducer is the combination of a sensor and variable conversion elements. The sensor measures an input variable and often times the result is not as user friendly as we would like it to be. In our headlight example the changes in light intensity result in a varying resistance. Since we are working towards the input of an ADC we need this signal to be represented as a change in voltage rather than resistance.
One way this problem can be solved is by using a resistor bridge or Wheatstone bridge as it’s often referred to. By creating a pair of voltage dividers with a known supply voltage and well chosen resistors, we can control the output range of our bridge circuit. In our example circuit (Figure 2) we have the positive arm of the bridge on the left and the negative arm on the right. The positive arm is a voltage divider made up of the photocell (Rs) and resistor Ra. The negative arm voltage divider is a combination of a potentiometer (Rc) and the resistor Rb. In Figure 2 I included the potentiometer (Rc) as a real world representation of how I would build the ability to calibrate the bridge into the circuit, it isn’t otherwise used in our discussion.
Null Type Wheatstone Bridge
We will create a null type Wheatstone Bridge, which means that the output at the Vout terminals will be zero at the nominal resistance of the photocell. There is a null output (Vout=0) when Ra*Rc = Rb*Rs.
We can choose the nominal resistance to be any value within the range of the photocell (which is 500 Ohms to 3.5M Ohms). For simplicity sake let’s use a fictional photocell resistance value of 30K Ohm at dusk. To stick with nice round numbers we’ll run two tests. One using 1K Ohm resistors for Ra and Rb, the other using 100K Ohm resistors.
To illustrate the differences in those two resistance values I used Multisim to run a parameter sweep on Rs (which is R3 in the simulation) from 0 Ohms to 50K Ohms, which should give us a good idea of how this system will behave throughout the changes in light on a typical day. The Y-axis in the plot is the voltage at the output terminals (Vout) and the X-axis is the resistance of the sensor.
You can see that there is quite a significant difference in the behavior, the plot on the left using 1K Ohm resistance for Ra and Rb gives us an exponential response and on the right the 100K Ohm response is almost linear. This is good to know and implement one or the other as needed.
So far we have a system that takes light intensity as an input variable through a sensor and the sensor outputs a resistance. Next a variable conversion element in the form of a Null Type Wheatstone Bridge takes the resistance and converts it into a usable voltage. The next step in the process is to take the signal that we converted from resistance to voltage and improve it. This bit changes depending on the situation, some sensors output changes that are so minute they need to be amplified to a voltage level that is easier to work with. Using an amplifier can improve the sensitivity and resolution.
If we use the 100K Ohm model the output voltage range is from 2.7V at the brightest part of the day to -8.9V in complete darkness. Those are usable values that we could input into an ADC however we can remove the inductive noise that might be found in an automotive application using an op-amp.
We can use a differential op-amp circuit to suppress any signal that is common to both inputs Vin1 and Vin2 (in this case we’re supressing the noise). The resistors are labeled using only R1 and R2 to keep the math of this simple. In this configuration we can calculate the output voltage Vout = R2/R1*(V2-V1). We aren’t required to implement any gain in this situation so we can make this “unity gain” by letting R2=R1. If we did want a gain of say 100 then we would choose R2 to be 100K and R1 to be 1K, that is assuming the op-amp we used was capable of such a gain.
At the end of the day it doesn’t matter how powerful your ARM is or how cleverly you call your assembly subroutines, if you don’t understand how to build the analog front end your code won’t save you. This kinda goes hand in hand with Gerrit’s article about software and mechanical engineers. This analog stuff isn’t trivial, you can’t fix it with an OTA update. Now if we can get past all the sensor v. transducer arguing we have a pretty good plan laid out to measure light intensity with a voltage as the output. We removed some common mode noise by using a differential amplifier and if we want a gain we know how to achieve that as well.
In the next installment we’ll go a little further down the path to having the analog signal converted to a digital value. We’ll have a look at some Instrumentation Amplifier examples and we might even have a look at an ADC.