43 Make your own Instruments
Suppose you were stuck without access to meters and oscilloscopes? (Like we are for the remote learning during the pandemic.) How far could you get with just your microcontroller board to test your circuits?
Measure DC Voltage
A multimeter measures the difference between two DC voltages. One of them might be a ground potential, but it doesn’t have to be. The ADC on our microcontrollers measures only the absolute voltage of an input relative to ground, so we will need to measure two voltages and calculate the difference.
Measure Continuity
Measuring continuity is simply measuring resistance, and beeping if it’s low enough to represent a direct connection, so let’s just add a signal to our resistance measurement whenever it is less than 2% of full scale. That will also remind us to change the scale for better accuracy. We can use the LED to replace the beeper in the meter
Measure Resistance
The usual way to measure resistance is to run a small current through the load and see what the voltage drop is. We can do exactly the same thing and have our sketch do the calculations.
Multimeter Sketch
This sketch provides a basic multimeter function for the Arduino IDE. Find it at Code – Arduino/Learning Sequence SAMD/ S2.3_MultiMeter in the repository. It assumes there is a 10K resistor connected between pin 2 and pin A5. Load it and run it to see basic instructions or watch the video below (17:34, but the second half is code review). It displays the voltage present on multiple analog pins, the difference in voltage between pins 3 and 4 for differential DC measurements, and an estimate of the resistance between pin 5 and ground. The voltages in parentheses are RMS values to give an estimate of the noise.
Measure Transient Voltages
Oscilloscopes can follow voltages up to very high frequencies, faster than the analog conversion rate of a microcontroller, but a lot of important things happen more slowly and we could still watch them.
Adding Displays
One of the things that makes real instruments so convenient is their built in displays so you don’t need to drag along a computer.