Introduction
I just finished a course programming the TI LaunchPad, featuring the MSP340FR6989 micro controller. One of the lab projects involved a sliding potentiometer which turned a LED “on” or “off” depending on how far the arm on the pot was to either end.
The software for this lab that was provided by the course polled the Analog to Digital Converter (ADC) to determine whether the input voltage to the ADC was at 50% of the full potential. If it was above the 50% mark the LED turned “on”. Otherwise the LED turned “off”.
The LaunchPad uses 3.3v; therefore, the voltage at 50% would be 1.65v. I noticed that I needed to move the pot’s arm almost to one end for the LED to turn “off”. I would have expected the switching to happen somewhere around the midpoint of the pot’s slider. I decided to have a closer look to determine what was going on.
The Voltage Divider
The circuit used in the ADC lab is a simple voltage divider. This type of circuit is used to quickly and simply take an input voltage and reduce it to a certain level. While this type of circuit is not appropriate for every situation, it is practical since it requires only two resistors. The schematic for how the lab’s pot was wired to the LaunchPad is shown in Figure 3.
The input voltage (Vin) is 3.3v and is sourced directly from the LaunchPad. As mentioned earlier, a voltage divider consists of two resistors. In this case, the first resistor is 470 Ohms and is connected to Vin. The second resistor is connected in series with the first and is a 10K variable resistor, or potentiometer. The other end of the slider pot is connected to ground. The Vout voltage going to the LaunchPad’s P9.2 pin is tapped from between the two resistors. Vout depends on both of these resistors’ values.
How can we know what Vout will be depending on the resistor values? Luckily for us, there is formula for that, as shown in Figure 4 which I borrowed from Wikipedia.
Z1 and Z2 are the two resistors. Using this formula we can calculate the theoretical Vout by filling in the values for Vin and the two resistors. We know that Vin is 3.3V and we’ll assign Z1 to the 470 Ohm resistor. Our slider pot is Z2. We can vary the resistance of this component to calculate Vout. In fact, we’ll go a step more. Since the software is supposed to switch the LED when it reaches 50% of Vin, we also know Vout: 1.65v. Now we can solve for Z2 and see what the resistance of the pot should be for the LED to switch. Luckily, Wikipedia also provides the formula to solve for either resistor. Since we arbitrarily assigned Z1 to the 470 Ohm resistor and the 10k slider pot to Z2, we want to solve for Z2 as is shown in Figure 5.
Let’s analyze this formula for a moment. The key is in the division in the denominator. We want Vout to be half of what Vin is, so of 3.3v we want 1.65v. What do we get when we divide a number by half of itself? We always get 2! Then if we subtract one from that we always get 1 and it doesn’t take a trig expert to know that 1 / 1 is 1. The conclusion is that in the specific case when we want Vout to be half of Vin, the second term cancels out because it will always be one. This just leaves the value of the first resistor. In our case R1 (or Z1, depending on which formula you are looking at) is 470 Ohms; therefore, to get 1.65v out of 3.3v the pot resistance needs to be 470 Ohms. The following table shows the first formula in action based on varying values of the slider pot.
While we could tend to think that the LED will switch “on” and “off” when the slider is halfway because the software is checking for half the input voltage, this is only an illusion. Having the LED switch when the slider is almost at the end of the slider makes sense because the slider needs to be where the pot’s resistance is 470 Ohms and if the pot’s total resistance is 10K (as in 10,000) then 470 Ohms is expected to be almost at the end that marks 0 Ohms.
What if we wanted the LED to switch when the slider is at the half way mark? Now that we know that both resistances need to be the same value for the voltage out to be half of the input voltage, and we know that the pot’s total resistance is 10K then we can conclude that the halfway point of the pot will give us 5K; therefore the other resistance needs to be 5K. This is as easy as swapping out the 470 Ohm resistance with a 5K resistor (or its closest value).
Regards!
Voltage divider formulas source:
Top Comments