4398

Measure: Frequency + Period + Pulse + Pulse/period + Capacity + Event counting. Bonus: decode DCF77 pulses and show date and time. The DCF77 pulses are also used to calibrate the system clock.

Recently several capacity meters were published in Elektor. Apart from the microcontroller they all require additional hardware such as a NE555 timer.
But it can be done with an Atmel ATmega328 and as little as 6 resistors. The software does the same as what the NE555 does: charging and discharging the capacitor under test with a known resistor and measuring the time needed. The availability of an analogue comparator and the input capture register for timer 1 in the Atmel chip are essential for this approach. Capacitors from a few pF up to 500 μF can be measured. Capacitors with a capacity over 250 nF are measured twice: one time charging the capacitor and one time discharging the capacitor. Both values are displayed. Capacitors with a serious leakage show 2 very different values. Electrolytic capacitors may show different values when the measurement starts, but should end up with 2 nearly equal values. That effect is caused by the restoration of the isolation layer inside the capacitor. 
I was glad to have a 40 years old capacitor with an official tolerance of 0,5 % and a rated value 3820 pF. This means its value is with 99% certainty between 3800,9 pF and 3839,1 pF. The UNO shield based meter and the 20 MHz prototype showed 3,87 nF, +/- 2 % means between 3792 pF and 3947 pF. Corrected for 30pF stray capacitance it is between 3762 pF and 3917 pF. I am very satisfied with the results.
To turn it into a more universal equipment, software for frequency, period, pulse and duty cycle measurement and event counting was added. Pulses up to 3 ms duration can be interpreted as servo control pulses and then be displayed as a percentage, where 0.0 % is a pulse of 1 msec and 100.0 % corresponds with a pulse of 2 msec.
Now the question of accuracy becomes important. The most critical timing in many microcontroller systems is the timing of the baud rate of an asynchronous serial line.
The tolerance of the baud rate is a few %. So the demands for accuracy of a microcontroller crystal are not very high. Frequency and period measurement require a much better accuracy. We cannot easily adjust the clock of an Arduino microcontroller, but we can measure the frequency deviation of the nominal frequency and correct in software. The supplied software uses the pulses of a cheap DCF77 receiver to calibrate the equipment. When building this meter as an Arduino shield be sure to use an Arduino with a real crystal. There are lots of Arduino lookalikes which use a ceramic resonator instead of a crystal. That is cheaper, smaller and good enough for most applications, but not here.
A dedicated print is designed for the meter. The crystal can be replaced by a 16 or 20 MHz TCXO (temperature compensated crystal oscillator) which has a much better stability and a guaranteed accuracy of +/- 50 ppm. The 20 MHz version allows the meter to measure pulses and periods as short as 3 ¾ μs. This means that the standard PWM signal of an Arduino can be measured over the full range from analogWrite(1,output) where the pulse is a little bit below 4 μs up to analogWrite(254,output), where the pause is just below 4 μs. With a 16 MHz clock this is not possible. The highest frequency to be measured is expected to be half the crystal clock frequency, but that is not verified yet. The print is designed for a Hammond box type 1591XXG and for through hole components and modules.
A front for the meter is designed in galva. (see www.f7bu.fr/galva-about).
The connection to the outside world is 4 pole one:
1. Capacitor measurement
2. Ground reference
3. Digital frequency/period/pulse/event input (Schmitt-trigger)
4. Vcc.
This allows small extra equipment to be fed by the meter. Such equipment could be: a prescaler for measuring higher frequencies, a DCF77 receiver or an amplifier for measuring analogue signals.
The meter so far is a fine instrument to measure signals from an Arduino project, but is has only a digital entry.
I miss the amplifier to allow for measuring analogue signals. I tried to make one using an example I found on internet, but it generated its own signals. The oscillating frequency was beyond the bandwidth of my scope, but the FPPCe meter had no problem measuring a frequency of several MHz, while my signal generator gave 1 kHz sinus. So such a design – reproducible please – is beyond my capabilities and beyond the capabilities of my test and measurement equipment. Anybody else?

At the end a few remarks about the photos and videos of this project.

The photos are taken from an older prototype an differ a bit from the final design I uploaded. More details are in the PDF files, which are uploaded with this project.
On the photo where the display is removed you can see the Atmel processor, the 20 MHz TCXO (with the black cover of isolation tape) and the 4 pole connector for an I2C display. Also good visible is the USB interface “at the wrong side of the board”.
The videos have – sorry – a Dutch voice over. I am a Dutchman, so English is not my native language. I apologise for having written funny English.
The video  shows the measuring of a 10 μF capacitor which has been in storage for about 30 years, may be more.
Video references:
See measuring a capacitor of 10 uF which has been in stock for 30 years at 
https://vimeo.com/515301873
or at
https://vimeo.com/515301633 
See measuring a leaking capacitor of 100 uF at:
https://vimeo.com/515301986
 
Firmware Upgrade. New version is 1.2 Date is march 22, 2021

Using the FPPCe meter the readout of capacitor values in the range of 1 to 10 nF turned out to be instable. Main cause: noise (50 Hz hum) picked up by wires between meter and capacitor to test.
 Even a cable of 20 cm caused trouble. So the small capacity measurement is changed and now repeats measurements until a total time of about 800 msec is used. Very small capacitors, like the capacity of the meter itself, with nothing connected, are measured 71 times. A capacitor of 220 nF is measured only twice. A capacitor of 270 nF is considered to be a “big” capacitor and is measured twice, once loading and once unloading. 

A bug was found in the module pulse.cpp. There was code that should not have been there.

The main module, FPPCe.ino, was modified to contain the new version number. (Version 1.1 was an intermediate version, which was never published). It also contains conditional code for different up- and down-arrow symbols. I tried it, but preferred the old ones.

Using the FPPCe meter in the 20 MHz version showed, that is possible to measure a frequency of 8 MHz, but it is not possible to measure a frequency of 16 MHz. The maximum frequency to measure will be half the clock frequency of the ATmega328.

This update only contains the modified modules.