PIC16C84 PICmicro Controlled Capacitance Meter Circuit

| July 16, 2023 Updated
PIC16C84 PICmicro Controlled Capacitance Meter Circuit

The Capacitance Meter has 4 ranges. In Manual Mode each range has an absolute minimum value and a maximum reading corresponding to a count range of 0 to 16,777,215. The endpoints are each range where the greatest error occurs, so in Auto Mode we limit the range to this part where we will achieve the highest accuracy. It can also be seen that the count range in Auto Mode has five special points. These points correspond to:

ZERO: The absolute lowest value that can be measured. In Auto Mode this ZERO value is only displayed in the lowest range. In manual mode, it is displayed in all ranges. When replacing capacitors, the unit automatically switches to Range 1.

DOWNRANGE: This corresponds to any number less than 4,096 in Ranges 1-3 and 32,768 in Ranges. December 4 . In Auto Mode, if the count falls below this value, the counter automatically moves to the next lowest range. If it is in the lowest range, the count is displayed.

INPUT RANGE: This corresponds to 5,242 counts at the current scale and 524,288 counts at the scale. previous scale This provides some hysteresis between a value that AutoRanging enters from a value. lower range and lower ranges revert to a lower range. If this hysteresis is not present then the circuit may oscillate at the point where AutoRanging is engaged.

UPRANGE: This corresponds to 524,288 numbers in the current range. In Auto Mode, the Circuit will initiate a transition to the next higher range when this number is reached or exceeded. If the current range is the highest range, then counting continues until the MAXCOUNT value.

MAXCOUNT: This corresponded to the Maximum Count value of 16,777,215. Maximum count value that can be obtained with 24-bit binary counters provided by the PIC.

Capacitance Meter Schematic

kapasite-metre-devresi-sema-150x150

RANGE 1: This range uses a precision 250k resistor and a division by 100 external prescaler, allowing the meter to measure from 0.00 pf to .00524288 uf (5,242.88 pf) in Auto Mode. Note that the digits behind the decimal point will often appear to vary from read to read. This is partly because the meter responds to small changes in the capacitor and for stray capacitance at the leads.

Approaching the leads can cause stray capacitance to vary by one or two picofarads. It is also enlarged due to the use of a leaked and divide-by-100 prescaler. However, I found it useful to have the extra two digits behind the decimal point. In Manual Mode, the range is from 0.00 pf to .16777216 uf (167,772.16 pf).

RANGE 2: Only a 250k precision resistor is used in this range and the Auto Mode range is 4,096 pf to .524288 microfarads (524,288 pf). In Manual Mode, the range is from 0.000000uf to 16.777216uf (16,777,216 pf).

RANGE 3: This range uses a clipable resistor rated 2.50k. I chose use a trimmer container to adjust the value so that the unit can be adjusted to compensate for several sources error due to the specs of the opamp I am using. The Auto Mode range is .4096. uf to 52.4288 uf. In Manual Mode, the range is from 0.0000uf to 1.677.7216uf.

RANGE 4: This range uses the same 2.50k clippable resistor used in Range 3, and a multiply by 10 circuit that allows us to extend this range to exactly ten times the Range 3. Ten circuits so we can set where the circuit has maximum accuracy can also be clipped. In general, it is useful to set it at 100uf for maximum accuracy. Auto Mode range is 32,768uf to 16,777,216uf. Always set Range 3 before setting range 4.
In Manual Mode, the range is from 0.000uf to 16,777,216uf.

The accuracy of the PIC Capacitance Meter is affected by several factors. Certain accuracy Resistors are critical to the accuracy of the circuit. I chose to use .1% precision resistors for the two resistors that make up the 250k resistor used in Range 1. I chose two 1% precision 10.0k resistors for the ratiometric comparator section as it is crucial to its fundamental accuracy circuitry in ALL ranges. Other resistors were chosen as 1% metal film resistors. trimmers are used to adjust accuracy in Range 3 and Range 4.

To test the accuracy of this meter I used a number of known value precision capacitors and here is what I found: In Ranges 1 and 2, the accuracy is about 0.1% when operated in Auto Mode. Over 1 million counts when operated in Manual Mode, accuracy drops to about 1%. In Range 3, accuracy is typically 1% when used in Auto Mode. In Counts over 1 million in Manual Mode, the accuracy drops to about 3%. Careful adjustment of the trimmer cup will result in accuracy for any desired point to be within 0.1%, but above and below that point, the accuracy will decrease as you move away from that point.

Accuracy in range 4 is limited by all the same factors discussed regarding range 3. in addition, this range uses an opamp multiplied by ten circuits. So accuracy is also affected by the accuracy of this multiplier and the multiplier also amplifies any noise present in the image. triangular wave fed into the comparison section. In general, this range gives you much more than 1% accuracy. This can drop to as much as 10% accuracy at extremely high ends of the range.

You can increase the fundamental accuracy of the circuit by choosing a better opamp. amplifier. I chose the TL084 because it’s pretty good, readily available and inexpensive.

Capacitance Meter PIC Assembly code

;                      CMETERA.ASM
;        Fr. Tom McGahee's PIC CAPACITANCE METER
;
;                   Fr. Thomas McGahee
;             Don Bosco Technical High School
;                    202 Union Ave
;               Paterson, NJ  07502  USA
;
;               [email protected]
;                    (973)595-6655
;
;        permission granted for individual use
;
;                Microchip MPASM format
;       Specifically designed for PIC16C84. Skeleton file.
;

; note: set assembler to case-insensitive, except within strings using /c- option
;

;OPERATIONAL DESCRIPTION OF PROJECT


;the mclear (reset) switch causes a reset and return to autorange.
;the other three switches cause an immediate move to manual mode.
;zeroswitch causes most recent displayed reading to be used as 
;a zero offset. this allows the user to compare two capacitors.
;a + or - sign is displayed to indicate relative value.
;hold key down until updating stops. upon release the
;current value will be displayed.

;first line of lcd displays a + or a blinking - sign in the first
;position. This indicates whether the current displayed value is
;higher or lower than the Comparison Value (normally 0). You may
;"zero-out" any value desired by pressing the ZERO button. This will
;cause the current value to be subtracted from all future readings.
;pressing the ZERO button also forces the unit into Manual Mode.
;you can return to Auto Mode by removing the capacitor and pressing
;the reset button, or by removing the capacitor and turning the
;power off and then on again.

;manual mode can also be entered by pressing either the UP or DOWN
;buttons. (hold button down until updating stops, then release).
;UP and DOWN are used to move from one range to another in Manual Mode.
;unit starts out in Auto Mode, and will automatically switch to the
;best (most accurate) range for any given capacitor. Auto Mode has
;built-in hysteresis to prevent the capmeter from constantly
;cycling between ranges. 

;the second position on the first line is sometimes occupied by a
;blinking letter "M". This indicates that you are in Manual Mode,
;and that the Auto Mode would have issued a command to go to a
;lower range. Obviously in Manual Mode you want to be able to
;change capacitances being measured, and at such a time the value
;being measured will temporarily go to zero, causing this feature
;to kick in.

;the rest of the first line is allocated to the display of the current
;count. internally a 24 bit counter allows the accumulation of counts
;up to 16,777,216. In Auto Mode the AutoRanging kicks in at around
;524,288 to range UP, and below 32,768 it shifts DOWN. There are 4
;ranges. In the lowest range it allows a display of from .00 pf to
;5,242.88 pf. range 2 ranges from 4,096 pf to 524,288 pf. range 3
;ranges from .4096 uf to 52.4288 uf. range 4 ranges from 32.768 uf
;to 16,777.216 uf.

;in Manual Mode you can generate counts from 0 to 16,777,216
;but the accuracy outside the above specified ranges can then
;have an error greater than 1%. use autoranging for maximum
;accuracy. use Manual Mode when using the Comparison feature
;or when you don't want the unit to AutoRange. AutoRanging to zero
;always causes the unit to go to range 1 for zero. then when you
;attach a new capacitor it may take a few seconds before AutoRanging
;detects an aout-of-range condition and responds. by the way, to
;speed up from such zero excursions I have implemented the UP Range
;portion of the AutoRange so that it always goes to range 4. I do
;this because it is always quicker to down range than it is to up
;range. there is method to my madness!

;values are displayed properly positioned over the value identifiers
;such as uf nf and pf. a space is provided between each set of 3
;digits to reflect standard engineering notation. partial number
;sets are padded with _ to the right. numbers have leading zeros
;suppressed up to the decimal point. commas are added where they are
;appropriate. 

;note that sometimes many more digits are displayed than the accuracy
;warrants. in general you can trust the first 3 digits to be right
;on. the 4th digit is normally accurate +/- 1 count. additional
;digits are displayed not for additional accuracy, but simply because
;they are useful for watching variations due to temperature, etc.,
;and they are useful in matching two or more capacitors.

;basic accuracy is 1% or better within the AutoRanging values
;up to about 100 uf. by the time you get a measurement like
;16,000.000 uf the time to collect such a measurement has risen to
;almost 24 seconds. this causes the accumulated error to rise
;to a few percent.

;the first position on the second line will display a number from
;1 to 4. this represents the current range, where 1 is the lowest
;range. the middle section of the second line contains the uf
;nf and pf indicators, positioned directly below the numeric groups
;that they refer to. I chose to display more than one set of
;indicators so you can easily read something like:
;
;+     12,000.___ 
;2 fd  nf  pf A**
;
;as either .012 uf   12.000 nf    or  12,000 pf.

;after the uf/nf/pf indicators there is either an "A" or an "M"
;displayed as an indicator of either Manual or Auto Mode being
;active. this is followed by two locations that display an
;animated (moving) black box to indicate that a new count is
;in progress. this is replaced by ** to indicate that the
;on-screen count has just been updated. These asterisks will
;remain on-screen until the circuitry detects edge synchronization.
;then the flashing black boxes appear. to speed up the
;synchronization process I have separate routines for handling
;rising and falling edges.

;occassionaly you will see a message such as "OVER-RANGE!" when
;in the manual mode. if the number is still displayed, then this is
;just a cautionary warning that the displayed value lies outside
;the range where it can be guaranteed to be 1% accurate.
;if the message is the *only* thing displayed on the screen,
;then you have exceeded the 16 million count limit and really
;need to switch to a higher range.
;
;during AutoRanging a quick flash of the word "AUTORANGING" will
;appear, and you may hear a click from the internal relays. some
;ranges switch without the click sound because they are using
;external counters to switch ranges.

;a note of caution when using Manual Mode: if you have set the
;device to operate in Comparison Mode by pressing the ZERO
;button, this zero comparison value will be retained *for the
;current numbered range* even if you move to another scale.
;before moving to another scale it is therefore a good idea
;to remove the cap being measured and press the ZERO button to
;re-zero the scale. if you don't do this, then the next time
;you return to that range the Comparison value will again
;be in effect. there is nothing wrong with bridging a comparison
;over two different ranges. if you want to do that, you
;have to press the ZERO button at *each* range you want to
;perform the comparison on.

;because the ZERO button automatically causes entry into the
;Manual Mode, you usually can't run Comparison Mode in 
;Auto Mode. however, *if* you hit the reset button and have 
;a capacitor attached, the reset auto-zero feature will
;cause the current cap value to be subtracted on *every* range.
;this works with values up to about 1 uf with no problem.
;larger values will cause overflow errors on the lower ranges
;and may therefore give erroneous readings. also note that the
;time required to perfom the auto-zero function increases
;with increasing external capacitance. if the cap value is more than
;a few uf then the auto-zero logic may cause the circuitry to
;cycle endlessly in an attempt to zero the lower ranges.
;if that happens, remove the capacitor and perform a reset.





;
; directives
;


;
; note: written in all lower case so case sensitivity doesn't matter.
; however: set assembler to case-insensitive, except within strings using /c- option
;

;
; directives
;



		list		p=pic16f84	;this directive must come first

; instead of using the [ include <16f84.inc> ] we have placed the contents of the
; microchip supplied include file below for documentation purposes.
;
; P16F84.INC  Standard Header File, Version 2.00    Microchip Technology, Inc.

; This header file defines configurations, registers, and other useful bits of
; information for the PIC16F84 microcontroller.  These names are taken to match 
; the data sheets as closely as possible.  

; Note that the processor must be selected before this file is 
; included.  The processor may be selected the following ways:

;       1. Command line switch:
;               C:\ MPASM MYFILE.ASM /PIC16F84
;       2. LIST directive in the source file
;               LIST   P=PIC16F84
;       3. Processor Type entry in the MPASM full-screen interface
;==========================================================================
;
;       Verify Processor
;
;==========================================================================

        IFNDEF __16F84
           MESSG "Processor-header file mismatch.  Verify selected processor."
        ENDIF

;==========================================================================
;
;       Register Definitions
;
;==========================================================================

W                            EQU     H'0000'
F                            EQU     H'0001'

;----- Register Files------------------------------------------------------

INDF                         EQU     H'0000'
TMR0                         EQU     H'0001'
PCL                          EQU     H'0002'
STATUS                       EQU     H'0003'
FSR                          EQU     H'0004'
PORTA                        EQU     H'0005'
PORTB                        EQU     H'0006'
EEDATA                       EQU     H'0008'
EEADR                        EQU     H'0009'
PCLATH                       EQU     H'000A'
INTCON                       EQU     H'000B'

OPTION_REG                   EQU     H'0081'
TRISA                        EQU     H'0085'
TRISB                        EQU     H'0086'
EECON1                       EQU     H'0088'
EECON2                       EQU     H'0089'

;----- STATUS Bits --------------------------------------------------------

IRP                          EQU     H'0007'
RP1                          EQU     H'0006'
RP0                          EQU     H'0005'
NOT_TO                       EQU     H'0004'
NOT_PD                       EQU     H'0003'
Z                            EQU     H'0002'
DC                           EQU     H'0001'
C                            EQU     H'0000'

;----- INTCON Bits --------------------------------------------------------

GIE                          EQU     H'0007'
EEIE                         EQU     H'0006'
T0IE                         EQU     H'0005'
INTE                         EQU     H'0004'
RBIE                         EQU     H'0003'
T0IF                         EQU     H'0002'
INTF                         EQU     H'0001'
RBIF                         EQU     H'0000'

;----- OPTION Bits --------------------------------------------------------

NOT_RBPU                     EQU     H'0007'
INTEDG                       EQU     H'0006'
T0CS                         EQU     H'0005'
T0SE                         EQU     H'0004'
PSA                          EQU     H'0003'
PS2                          EQU     H'0002'
PS1                          EQU     H'0001'
PS0                          EQU     H'0000'

;----- EECON1 Bits --------------------------------------------------------

EEIF                         EQU     H'0004'
WRERR                        EQU     H'0003'
WREN                         EQU     H'0002'
WR                           EQU     H'0001'
RD                           EQU     H'0000'

;==========================================================================
;
;       RAM Definition
;
;==========================================================================

        __MAXRAM H'CF'
        __BADRAM H'07', H'50'-H'7F', H'87'

;==========================================================================
;
;       Configuration Bits
;
;==========================================================================

_CP_ON                       EQU     H'000F'
_CP_OFF                      EQU     H'3FFF'
_PWRTE_ON                    EQU     H'3FF7'
_PWRTE_OFF                   EQU     H'3FFF'
_WDT_ON                      EQU     H'3FFF'
_WDT_OFF                     EQU     H'3FFB'
_LP_OSC                      EQU     H'3FFC'
_XT_OSC                      EQU     H'3FFD'
_HS_OSC                      EQU     H'3FFE'
_RC_OSC                      EQU     H'3FFF'


;end of  file stuff

;define stuff that microchip in their wisdom re-named.
; this is in case we use the identifiers in the original data sheets by accident

ind0		equ		h'00'		;file address. microchip calls it indf		
rtcc		equ		h'01'		;file address. microchip calls it tmr0
;
;<

PIC16C84 PICmicro Controlled Capacitance Meter Circuit schematic asm source code pcb files download:

PIC16C84 PICmicro Controlled Capacitance Meter Circuit

Password: 320volt.com

Published: 2009/02/02 Tags: , ,



1 Comment “PIC16C84 PICmicro Controlled Capacitance Meter Circuit

  1. Electronics CircuitsElectronics Circuits

    PIC16C74 NTC Thermometer Circuit

    A simple thermometer circuit display used to display the value of the temperature sensing for 10 k ntc also relay output the relay can be backed by sustained with the transistor has very little material can be accomplished with

    Thermometer Circuit

    REPLY

Leave a Reply

Your email address will not be published. Required fields are marked *