Mobile Science  Espanol
DCVoltmeter
by Ray Wisman and Kyle Forinash
Indiana University SE.

## Description

DCVoltmeter records, displays, saves to spreadsheet DC voltages (ranging from 0 to about 12 volts).

The application requires the LM231/331 voltage-to-frequency convertor in a simple circuit given below.

Designed for use in science education experiments that:

• measure the voltage as it changes over time,
• display voltage in a real time graph,
• record the voltage to spreadsheet.

The screen shots below illustrates the measurement of a slowly varying voltage. The voltage is displayed and graphed in real time.

The collected voltage measures can be exported to an Excel-compatible spreadsheet app and analyzed or shared.

Controls and Displays

Gestures select graph areas

 Tap one finger to mark and display the time and voltage at that point.Drag the mark. Two finger pinch or squeeze to zoom. Drag to pan left and right. Tap twice to remove markers.

Button function

 Start      Stop      Left        Right end of graph.    Reset window to full.    Calibrate.    Excel-compatible export.    Adjust resolution accuracy.*    Find highest peak voltage of window.     Help and information.

*Highest voltage accuracy is setting 8 with measurements about every 1.46s; Lowest accuracy is setting 1 with measurements about every 0.012s.

Use

There are two parts to measuring DC voltage: 1) the DCVoltmeter app, and 2) the voltage-to-frequency circuit.

The photo below illustrates the running app, circuit and voltmeter; after calibrating, the app and voltmeter differ by a few hundredths of a volt.

The yellow wire connects the circuit output at PIN 3 to the microphone input, the blue wire connects the voltmeter for verification. A potentiometer varies the measured input voltage for testing.

A one time calibration of the circuit using the gain adjust potentiometer is critical for accurate measurements. See below for calibration details.

The LM231/331 voltage controlled oscillator circuit converts voltages ranging from about 0 to 11 VDC to a frequency ranging from about 5Hz to 11,000 Hz.

Full details of the circuit below are available from the device manufacturer, listed in the acknowledgements.

 Optional filter

The DCVoltmeter app converts the frequency from the circuit to a corresponding voltage. The app receives the frequency input through the audio headset port.

PIN 3 of the LM231/331 device is connected to the microphone input (usually the black wire), a common ground should be connected between the LM231/331 and the headset (usually the green wire).

Calibration

Due to differences in circuit components, calibration is required for accurate measurements.

There are 2 calibrations possible:

1. Gain adjust - Do one time for a new circuit, normally the only calibration necessary.

Start the app. Disconnect the measured voltage input, Vin. Connect Vin instead to PIN 2 and press the button. Adjust the gain potentiometer until the app displays about 1.91VDC. Press the button.

2. App calibration - Normally not necessary after calibrating the gain adjustment but applicable each time the app starts.

Disconnect the measured voltage input, Vin. Connect Vin instead to PIN 2 and press the button. PIN 2 supplies 1.91VDC, in practice.

Limitations and technical details

Voltage range for input to the LM231/331 is about 0 to 12 volts DC, in practice. Accuracy, or at least agreement when measured against a medium quality digital voltmeter, is within a few hundredths of a volt, after gain adjustment calibration.

Time intervals between voltage measurements range from about 0.012s to 1.48s corresponding respectively to lower (setting 1) and higher (setting 8) resolution accuracy settings. While the interval between measurements varies due to overall system load, the accurate time of each measurement is recorded.

Number of measurements is limited by file storage, each voltage measure and time taken is written to a file; each measure requires 8 bytes, the fastest setting (1) records at about 800 bytes/second, or about 3Mb/hour.

Resolution accuracy can be selected from 8, the highest, to 1 the lowest. After gain adjustment calibration, voltage measurement accuracy in setting 8 should differ from a commercial digital voltmeter by a few hundredths of a volt.

The app measures the microphone frequency produced by the voltage-to-frequency circuit, converting the frequency to voltage using the equation:

voltage = (frequency + 2.6347) /851.53

derived by fitting measured frequency measured by the frequency counter circuit versus voltage measured by a voltmeter, to the linear equation.

The frequency output by the LM231/331 circuit is determined using the the Fast Fourier Transformation (FFT); at right is an example of the audio signal as input by the app. Resolution accuracy is reduced when measurement time is reduced due to the physical constraints of determining a frequency using the FFT. Because the microphone is sampled at 44100 Hz, the highest resolution accuracy requires a measurement of at least 44100 samples; because the FFT requires a power of 2 samples, nearest that includes the 44100 samples is 2^16 = 65536 samples. The sampling time required is then 1.48s, with a resolution of 1 Hz; meaning that a true frequency of 100Hz and 101Hz could be measured as 100Hz and 101Hz. Reducing the number of samples by half, to 2^15 samples reduces the sample time by half and resolution to 2 Hz; a true frequency of 100Hz and 101Hz could be indistinguishable.

The lowest resolution offered by the app is setting 1, at 2^9 = 512 samples, which yields poor accuracy in low voltage ranges due in part to lower voltages corresponding to lower frequencies. A 0.11 voltage corresponds to a frequency of 100Hz or one cycle every 0.01s; 512 samples at the 44100Hz sample rate occurs in about 0.01s, approximately the time interval to measure a complete cycle. If measuring higher voltages (above about 1 volt) and therefore higher frequencies, the lower resolution setting may be acceptable and accurate.

To determine the frequency, the app collects the specified number of samples specified by the setting and generates the FFT result, an array containing the magnitude of each frequency. Because the LM231/331 generates a wave of varying frequency and high/low time ratio, the FFT result includes the a fundamental frequency and higher frequency components of the square wave. The circuit, connections, external radio frequencies can add other, spurious frequencies to the FFT result. In theory, the fundamental frequency would be the highest magnitude and easily located. In practice, the noise, etc. make locating the fundamental frequency more challenging; as the audio signal figure indicates, simple methods such as counting the number of zero crossings are not applicable to the signal; the FFT seems to produce a reasonable trade-off of speed and accuracy for the app.

Locating the fundamental from the FFT results is done using the simple heuristic that the fundamental frequency is the minimum of other frequencies that are its multiples. What works pretty well: find the 20 highest magnitude frequencies, assume the fundamental is the highest magnitude, find a lower frequency that nearly evenly divides the highest magnitude frequency and is also a comparatively high magnitude, then assume the lower frequency is fundamental. Occasionally, the fundamental frequency and corresponding voltage measurement errors do occur, especially in the lower sample settings and low voltages (setting 3 or less), due to the fundamental frequency not occurring in the 20 highest magnitudes. The error is generally exhibited by the app as erratic voltage measures, that are multiples of the true voltage, corresponding to harmonics of missing fundamental frequency.

The above method appears to be accurate and suitably efficient for higher settings (8 to 4 which measures a voltage every 0.1s). Improving the accuracy for lower settings may be possible through windowing, auto-correlation, interpolation, joining small samples with previous samples, etc. (some suggested methods (http://stackoverflow.com/questions/4583950/cepstral-analysis-for-pitch-detection are yet to fully explored). However, the key problem is lower settings take fewer samples, which at low voltage and corresponding low frequency can miss a complete cycle; instead of finding the fundamental frequency, the FFT finds only higher frequency harmonics of the true fundamental frequency.

Voltage input changes often result in a voltage measurement error because the measurement includes multiple voltages with multiple corresponding frequencies. While these errors could have been mitigated using a low-pass software filter during voltage collection, it was decided to record the unfiltered voltages; allowing the user to export the measurements to a spreadsheet and perform their own filtering.

References for further examination of Mobile Science apps and use

R. Wisman, K. Forinash; 'Science in Your Pocket', International Journal on Hands-on Science (IJHSCI) Vol. 1, No. 1, September (2008) p7-15.

K. Forinash, R. Wisman, ‘Mobile Science – Acceleration’. Measures acceleration. Apple App Store (https://itunes.apple.com/us/app/mobile-science-acceleration/id389821809?mt=8).

K. Forinash, R. Wisman, ‘Mobile Science – Temperature’. Measures temperature using a simple circuit attached to the headset jack of an iOS mobile device. Apple App Store (http://itunes.apple.com/us/app/mobile-science-temperature/id467423322?mt=8).

R. Wisman and K. Forinash, ‘Mobile Science - Ohmmeter’. Application to measure resistance using a simple circuit attached to the headset jack of an iOS mobile device. Apple App Store, April 2013. https://itunes.apple.com/us/app/ohmmeter/id628027479?mt=8

K. Forinash and R. Wisman, ‘Mobile Science – Ohmmeter+’. Converts resistance to other units determined by arbitrary user defined equation. Application measures resistance using a simple circuit attached to the headset jack of an iOS mobile device. August 2013. https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=685431874&mt=8

R. Wisman and K. Forinash, 'Mobile Science - AudioTime'. Records, displays, saves, plays and finds dominant frequency of selected audio. November 2013. https://play.google.com/store/apps/details?id=edu.ius.audiotime

R. Wisman and K. Forinash, 'Mobile Science - AudioTime+'. AudioTime+ can time events by sound or photo gates and records, displays, saves, plays and finds dominant frequency of selected audio. November 2013. https://play.google.com/store/apps/details?id=edu.ius.audiotimeplus

R. Wisman and K. Forinash, 'Mobile Science - AudioSpectrum'. AudioSpectrum displays the frequency spectrum of a WAV file or audio sourced from AudioTime or AudioTime+ apps. December 2013. https://play.google.com/store/apps/details?id=edu.ius.audiospectrum

R. Wisman, K. Forinash; 'Mobile Science', Ubiquitous Learning; An International Journal, Vol. 3 No. 1 (2011) p21-34.

R. Wisman and K. Forinash, ‘Smartphones as portable oscilloscopes for physics labs’, The Physics Teacher, Vol. 50 No. 4 (2012) p242.

K. Forinash and R. Wisman, ‘Smartphones - Experiments with an External Thermistor Circuit’, The Physics Teacher, Vol. 50 No. 9 (2012) p566.

K. Forinash and R. Wisman, ‘Smartphones as Data Collection Tools for Science Education’, International Newsletter on Physics Education, Vol. 64 (2013).

K. Forinash and R. Wisman, 'Using smartphones as science laboratory instruments', American Association of Physics Teachers, Portland, July 13-17, 2013

Acknowledgements

Columbia University MEAPsoft for Java version of FFT.

Douglas L. Jones, University of Illinois at Urbana-Champaign, for original FFT version in C. http://cnx.rice.edu/content/m12016/latest/

AndroidPlot.com for plotting library and examples.

Texas Instruments for LM231/331 documentation and circuit. http://www.ti.com/product/lm231/

Legalese

This program is free software: you can use