Below is some information to help you understand how the hardware of the voltmeter works. To learn how the software works, download and open the .ino file and read the included comments.
Microcontroller + Supporting Components
The microcontroller is the heart of the voltmeter, and is what controls how the system works. The microcontroller, or MCU for short, in our project is an Atmega 328P, the same MCU found in Arduino Unos.
While some MCUs can work just on their own, the 328P needs a few additional parts to function. The most important one is the crystal resonator, which the 328P uses to accurately time the execution of code. The resonator has two small capacitors connected to it as well. These capacitors will help the crystal resonate at the proper frequency.
The two large capacitors serve two different purposes. The first is connected to the +5V and GND pins of the 328P. This capacitor will supply the 328P during any sudden power draws. The time it takes for the voltage regulator to respond to a sudden spike in power draw can leave the 328P starved of power momentarily, causing it to reset. This capacitor acts like a tiny battery, storing excess energy to supplement the voltage regulator when needed. The second large capacitor is there to stabilize the analog measurements of the 328P. If we were not using the analog inputs, or we did not care about precision in our measurements, we would not need this part.
While some MCUs can work just on their own, the 328P needs a few additional parts to function. The most important one is the crystal resonator, which the 328P uses to accurately time the execution of code. The resonator has two small capacitors connected to it as well. These capacitors will help the crystal resonate at the proper frequency.
The two large capacitors serve two different purposes. The first is connected to the +5V and GND pins of the 328P. This capacitor will supply the 328P during any sudden power draws. The time it takes for the voltage regulator to respond to a sudden spike in power draw can leave the 328P starved of power momentarily, causing it to reset. This capacitor acts like a tiny battery, storing excess energy to supplement the voltage regulator when needed. The second large capacitor is there to stabilize the analog measurements of the 328P. If we were not using the analog inputs, or we did not care about precision in our measurements, we would not need this part.
7-Segment Display Multiplexing
A 7-segment display is a way of showing a number by lighting up 7 different LEDs (or 8 if you include the decimal). Since we have 3 decimals and 3 7-segment digits , this means that our display contains a total of 24 LEDs we need to control. However, there are not 24 pins on the bottom of the display, so how do we control them all?
To control this many LEDs with just a few pins, we use a trick called multiplexing. In multiplexing, the cathodes of all the LEDs in one digit are connected to a single pin on the 328P, and the anodes of the same segment in each digit are connected to a single pin. When we want to light up lights in just the first digit, we pull the cathode of the first digit low, and the pins that relate to the desired segments high. This allows current to flow through the LED and light up the number we want. Then, we turn the cathode of the first digit to high, the second to low, and repeat the process to show a number on the second digit. This process happens thousands of times per second, so our eyes just see all 3 digits turned on. If you use a phone camera to look at the display, though, it will be able to faintly pick up the blinking. You can see an example of this to the right, where an image was taken as the voltmeter was in the process of switching from one digit to another. |
Resistor Divider
If our Arduino was just reading from 0 to 5 volts, we could connect the voltage source right to an analog pin on the 328P and determine the voltage from that. However, we want to read higher voltages, so we use something called a resistor divider or voltage divider. A resistor divider is made of two resistors, connected to each other. The unused lead of the first resistor is connected to the voltage we are interested in measuring, and the bottom resistor’s other lead is connected to ground. Then, we can measure the voltage at the point between the two resistors. Depending on the ratio between the resistances of the two resistors, we can scale down the voltage value to a usable level. For example, a 100k resistor as the first and a 10k resistor as the second will scale the voltage down by about 91%, making a 50V input measure as only 4.54 volts. The relation between the values of the resistors and the input and output voltages is described by a formula called the "Resistor Divider Equation." The calculations can be done by hand, or by using online calculators.
Button + Pullup Resistor
We use a button to set the mode of the voltmeter. When pressed, the button connects a pin of the 328P to ground, which we can then detect and use to execute code. However, we need one additional component; a pullup resistor. Just having a wire connected between the 328P and the button leaves the pin in a state known as “floating” – it does not have a value. A floating pin will pick up random electromagnetic signals and can randomly trigger as a high or low reading when it should not. To solve this, we use a pullup resistor. This is a high-value resistor between 5 volts and the pin of the 328P, that keeps the level at 5 volts when the button is not pressed. When the button is pressed, current will flow through to ground instead, and the pin will read at 0 volts. If the resistor was not there, the button would short out 5 volts and ground, causing damage.