Pico C-Plus and Pico C-Super (110687)
The popularity of All Things Test & Measurement among Elektor readers got substantiated once again recently by Pico C, a cute DIY capacitance meter specially designed to deal with small capacitors like below 10 pF
The popularity of All Things Test & Measurement among Elektor readers got substantiated once again recently by Pico C, a cute DIY capacitance meter specially designed to deal with small capacitors like below 10 pF, much to the enjoyment of radio amateurs and leaving professional instruments well behind. One limitation of the instrument was noted though, its maximum value of about 2500 pF, triggering reader Jon Drury to write new software culminating in two new versions called Pico C-Plusand Pico C-Super. C+? No, assembly language was used to write the firmware!
Published in Elektor Magazine, no. 422, February 2012
Order from Elektor
PCB, bare, 110687-1
Preprogrammed microcontroller ATtiny2313-20PU, 110687-41
Preprogrammed microcontroller ATtiny2313-20PU, 110687-42
Kit of parts incl. display, Elektor Project Case, programmed microcontroller and PCB, 110687-71
Elektor’s ‘small-C’ meter upgraded in two ways
Editor’s note. The modifications and extensions described in this article are the result of reworking and do not imply corrections to the original design of Pico C (April 2011) [1], nor the associated PCB, microcontroller or kit supplied by Elektor (nos. 100823-1, 100823-41, 100823-71 respectively). The original publication and related products stand unaltered.
Two new versions were developed of the software for Pico C. Version Pico C-Plus will run on the board as published [1] and includes a signal generator function as well as capacitance measurement and a simple period measurement function based on the TLC555 oscillator. The second version, Pico C-Super, requires minor changes to the original PCB (two cuts and three wires) to allow an external signal to be measured. This version adds a frequency counter and implements the period counter properly. As an alternative to track cutting and wire soldering, a new board design was produced for Pico C-Super.
Pico C-Plus: look, no board modding!
When I read the original article in the April 2011 edition [1], it seemed to make little sense that a 24-bit counter should be limited to 2500 pF. The article states that a count of 680 is equivalent to 1 pF and as 24 bits gives a maximum count of 16,777,215, the range should extend to 16,777,215/680 = 24,672 pF. I decided to investigate by re-writing the software in pure assembler to keep control of the 24-bit arithmetic required and to stay close to the hardware.
A later study of the source code for the published software shows that compromises were made in order to work within the constraints of the Bascom arithmetic (see contributions). The assembler version uses a 24 x 24 bit multiply and 48 x 24 bit divide which I have derived from Atmel’s application note AVR200 and this avoids having to make any compromise in the arithmetic. I have also taken a different approach with the ISR (interrupt service routine) and use just one ISR to start and stop the count as well as controlling the number of periods that are averaged. Since Pico C is essentially a period measurement device, this was my first development target. I have retained the signal averaging of the original, but use multiples of 10 so that scaling becomes a simple matter of shifting the decimal point. Signal averaging is also of benefit in this application as there is some noise on the oscillator period. The new meter ranges and accuracies are shown in Table 1. As in the original software, calibration values are stored in EEPROM. When the board is used for the first time, the software will recognise that the EEPROM is blank and insist on calibration to be carried out. Calibration is then optional for further measurements, but can be performed at any time by selecting the ‘Calibrate’ function from the mode selection sequence. Please note that the new software carries out an ‘autozero’ operation automatically at the beginning of a measurement cycle and nothing should be connected to the input until after the autozero time.
Multiplier | Max. capacitance | Resolution |
---|---|---|
1 | 500 nF | 1 pF |
10 | 50 nF | 0.1 pF |
100 | 5 nF | 0.01 pF |
The new software includes a separate period measurement function with options to average 1, 10 or 100 periods. The maximum multiplier of 100 allows periods to be measured with a resolution of 1 ns. Since f = 1/P there is an opportunity to add high resolution, low frequency measurement (<100 Hz), but sadly there’s no room on the 2 x 16 LCD. The period function has a minimum measurable time of 1.5 μs, since this is the execution time of the ISR.
Multiplier | Maximum | Resolution |
---|---|---|
1 | 1.6 s | 1OO ns |
10 | 160 ms | 10 ns |
100 | 16 ms | 1 ns |
The period measurement function was then used to implement the logic of Pico C with improved results, see Table 2. The multiplier feature now acts to select the measurement range. The maximum range on each scale is determined by the maximum count before overflow occurs and I have chosen to generate overflow at 24 bits to keep the maths simple(!) although the two concatenated counters can give 26 bits (by using OC1A as well as OC0B). The other consideration is that the maximum measurement period is nearly a second (0.839 s) for 24 bits and longer times would start to feel slow. From preliminary calculations of maximum range as above, a range of about 8 nF was expected with the multiplier at 100, since this is about 3 times the figure used in the published software (the original Pico C included a multiplier of 32). However, I was only able to measure around 5.8 nF which is a bigger error than could be explained by component tolerances (5%). The published figure of 680 counts/pF may well be inconsistent with the published base frequency of 3.2 kHz (see contributions for calculation). In this extended version with the multiplier set to 100, capacitance can be resolved down to 0.01 pF but limited to 5 nF, whereas with a multiplier of 1 resolution drops to 1 pF but the range extends up to 500 nF using the published component values. The linearity of the meter was checked on all ranges by measuring individual capacitors and then measuring them in various combinations (see results). Although some slight deviation is noted at the top end, it is less than 0.1%.
Clearly, if the value of R1 is reduced the top limit can be extended. I prefer to use 470 kΩ which extends the top limit to a convenient 1 μF with no detriment to the bottom end. However, it would be interesting to test even lower values of R1 to see whether the meter could also be used to measure low value electrolytic capacitors.
With this much code written there was still room in the 2313 memory for more code, so it seemed logical to add frequency measurement and a signal generator to get the maximum use from the hardware. The signal generator turns out to have a very wide range from 0.8 Hz right up to 10 MHz (but with reduced resolution at the top end). It uses a table of 18 spot frequencies located in EEPROM to retain as much program space as possible. Users should tailor the frequencies in the table to suit their own application. The frequency counter (Table 3) uses a precise software delay routine as both counters are already in use. The delay times were checked using a version of the period measurement function.
Gate time | Max. frequency | Resolution |
---|---|---|
10 ms | 8 MHz | 100 Hz |
100 ms | 8 MHz | 10 Hz |
1 s | 8 MHz | 1 Hz |
ToDo for Pico C-Plus
- (Re)program the ATtiny2313 with PicoC-Plus.hex and PicoC-Plus.eep (EEPROM contains basic table for signal generation), or order a ready programmed microcontroller # 110687-41 from Elektor.
- Use pin 15 (OC1A) of the 2313 for signal output.
- Use short presses of the switch to move through the menus and a long press (>2 sec) to accept the displayed option or to exit from any mode.
Pico C-Super: minor surgery, or a new board
IF you want the little instrument originally called Pico C
(1) to have the extended capacitance range of Pico C-Plus;
(2) to have the signal generator of Pico C-Plus;
(3) to act as a frequency counter
(4) to act as a period meter
REMin other words, to make full use of the extended software version called Pico C-Super
THEN some pins of the pins of the 2313 need to be freed up!
ELSEstick to Pico C-Plus or even happily continue using the original Pico C!
Programming aside, this is because pin 8 of the 2313 (T0 input) is used as an output in the published version to control the TLC555. But in the extended software version Pico C-Super, this pin is used as an input for frequency measurement and the TLC555 Reset pin is connected permanently to 5 V. A change is also required to split pins 6 & 7 as the revised versions use INT1 for capacitance measurement and INT0 for external period. Without changes the period function shows the period of the 555 oscillator.
ToDo for Pico C-Super
To get the frequency counter and period measurement functions working requires two cuts and three wire links on the original Pico C board:
- cut track between IC2 pin 4 and IC3 pin 8. (Frees up T0 input)
- connect IC2 pin 4 to IC2 pin 8. (Leaves IC2 running permanently — RST tied to +5 V)
- connect IC3 pin 8 to input socket. (Input to T0)
- cut track between IC3 pins 6 & 7. (Frees up INT0 — used for external Period)
- connect IC3 pin 8 to IC3 pin 6. (External input to INT0)
The changes are reflected in the circuit diagram (below). Diodes have been added for input protection. The PCB incorporating the above changes carries item number 110687-1. For the convenience of readers new to the Pico C Saga the PCB silk screen is shown in the component list contribution; the PCB artwork file may be downloaded below and the ready-programmed controller for Pico C-Super is available as item # 110687-42.
What else? The parts list, of course, and the actual construction but that should not present problems as only through-hole components are involved and a single-side circuit board. One word of caution though: check and double check the pin numbering of the LCD you are using – the schematic shows a circuit symbol only, not the physical shape or actual pin arrangement.
Some results
First, a word of caution. The reworked meter is extremely sensitive on the 100x range and the presence of a hand is detectable at a range of about 5 cms (2 in.). So for best results I have activated the switch by using a pot trimmer during calibration to avoid errors from hand capacitance. For your amusement, a photo of my prototype with a 1.6–5.0 pF variable capacitor is shown in Figure 3. The capacitance will start to increase when a hand is placed about 5 cms away and rises to about 5 pF when the wire is gripped between two fingers. Note the wire is 10 cms (4 in.) long and attached to the ‘live’ pin of the input. Is it an aerial or a capacitor, what do you think? You will also see in the photo that a 4 x 20 LCD is being used, which has been invaluable in providing space for diagnostic messages during software development.
As mentioned above linearity checks were carried out as the TLC555 oscillator is expected to perform linearly over a 3-decade range of frequencies from 1 Hz to 3.2 kHz. The photo also shows one of the test fixtures made from a small piece of plain perforated board and a header strip. The fixture capacitance is measured as C0and then each individual capacitor as C1, C2etc. A variety of values are fitted so that sufficient capacitance can be selected to overload the meter on a given range. A spreadsheet was used to subtract the fixture capacitance from each individual reading in order to calculate its contribution. Then when capacitors get combined the theoretical reading is calculated from the sum of the fixture and the individual capacitors. The error is calculated first in pF and then as a percentage of the theoretical value. The agreement between measured and theory was found to be normally better than 0.1%.
The results of the accuracy measurements have been summarized in a table you can find in optional archive file 110687-W for the project (download below).
When measuring larger capacitors on x10 and x1 ranges some noise can be seen. For example, a 10 nF capacitor measured 10089.1 pF on x10, but on x1 the reading varies between 10085 and 10091 pF. Also, there appears to be a small amount of noise picked up at the input of the TLC555 where the input impedance is quite high. Much less noise is seen with measurements on x100 as a result of the signal averaging.
References
1. Pico C, Elektor April 2011.
Published in Elektor Magazine, no. 422, February 2012
Order from Elektor
PCB, bare, 110687-1
Preprogrammed microcontroller ATtiny2313-20PU, 110687-41
Preprogrammed microcontroller ATtiny2313-20PU, 110687-42
Kit of parts incl. display, Elektor Project Case, programmed microcontroller and PCB, 110687-71
Diskussion (3 Kommentare)