Talking Electronics PIC Theory




Page1
Page3
Page4

"In Circuit"
ELECTROLYTIC
TESTER
Page 2:
CONSTRUCTION,
Burning the program into the chip,
and Using the Tester


 CONSTRUCTION
All the components fit on a small PC board with 4 leads going to a small plug that fits on the 5x7 display. The plug has 5 pins but the second pin from one end is not used. It is best not to connect a wire to this pin so you can see which way to connect the plug. At the other end of the ribbon cable, the lead does not solder to the board. 
Two leads are also needed to connect the electrolytic-under-test to the board. One lead has an alligator clip and the other is an E-Z clip. 
The two green LEDs serve as ON indicators as well as a zener reference voltage for the correct operation of the circuit.  The only other components are a transistor and 4 resistors. What more can we say about construction? Check the correct placement of the LEDs and transistor. Make sure your soldering is neat and don't overheat the parts. Connect the 4 wires (5-core ribbon cable) to the board and fit a plug to the other end. The 5-pin socket goes on the 5x7 Display. 


Electrolytic Tester PC board

ELECTROLYTIC
TESTER

PARTS LIST 
Cost $
7.75 plus $2.20 postage

1  -  220R    1/4 watt
1  -  1k            "
1  -  10k          "
1  -  22k          "
2  -  3mm green LEDs
1  -  BC 547 transistor or similar
1  -  black crocodile clip
1  -  red E-Z clip
1  -  5-pin header
1  -  5-pin header socket 
20cm  -  5-core Ribbon Cable
30cm  -  red hook-up wire
30cm  -  black hook-up wire
20cm  -  very fine solder
1  -  Electrolytic Tester PC board

PC Board only 
$2.50
plus $2.20 postage

Buy a kit

THE PROGRAM
The program needs a lot of discussion as it is one of the main reasons for the project.
There is a little more effort required to get this type of program running due to the external components having a delay value that is unknown. 
Of course you can sit down and mathematically work out how long it will take to discharge a 22u electrolytic from 3.8v to 0v via a 220R resistor but our Microcontroller Course is designed to get you through electronics without involving complex mathematics. 
You can do exactly the same by creating a delay routine (at LoopX and LoopY) and counting how many times the program executes this delay routine. The initial answer I got for 22u was 005. I decreased the delay values until I got 22. I then placed a 47u on the Tester and miraculously got 46! A 100u electrolytic produced a readout of 99. I checked a 10u on a professional capacitance meter and got a reading of 11.76u. The tester produced a reading of 12!  I expected a conversion table would be needed to take into account the non-linearity effects of charging the electro but the program did not require it. 
Electrolytic values are inherently non-accurate and could be as much as +20% or -20% of the stated value. However with the enormous accuracy of modern machinery, a batch of 100u electrolytics gave readings of 98, 99, and 100. Buy re-reading the electrolytics, I got the same values and proved the repeatability of the circuit.   

         Program for "In-Circuit" Electrolytic Tester
              (add-on for 5x7 Display)
     
                  
;PIC16F84 chip         
   

 Start   ORG 0x00
            BSF 03,5            ;Go to page1 for setting-up the ports 
            MOVLW 02h      ;Put 02 into W 
            MOVWF 05h      ;to make RA1 input, others output
            BCF 03,5            ;Go to page0 for programming
            GOTO Main

Table1     ADDWF 02h,1    ;Add W to Program Counter
               RETLW 3Eh        ;0
               RETLW 41h 
               RETLW 41h
               RETLW 41h
               RETLW 3Eh
               RETLW 00h         ;1
               RETLW 10h
               RETLW 20h
               RETLW 7Fh 
               RETLW 00h
               RETLW 27h         ;2
               RETLW 49h
               RETLW 49h
               RETLW 49h
               RETLW 31h
               RETLW 22h          ;3
               RETLW 41h
               RETLW 49h 
               RETLW 49h
               RETLW 36h
               RETLW 0Ch          ;4
               RETLW 14h
               RETLW 24h
               RETLW 7Fh
               RETLW 04h 
               RETLW 7Ah          ;5
               RETLW 49h
               RETLW 49h
               RETLW 49h
               RETLW 46h
               RETLW 3Eh           ;6
               RETLW 49h
               RETLW 49h 
               RETLW 49h 
               RETLW 26h
               RETLW 40h           ;7
               RETLW 47h
               RETLW 48h
               RETLW 50h
               RETLW 60h
               RETLW 36h           ;8
               RETLW 49h
               RETLW 49h
               RETLW 49h
               RETLW 36h
               RETLW 32h           ;9
               RETLW 49h
               RETLW 49h
               RETLW 49h 
               RETLW 3Eh
               RETLW 00h

        ;This routine charges the electro

 Charge   MOVLW 08h
                MOVWF 0Ch
                BSF 05,0
 Delay2    DECFSZ 0Dh,1
                GOTO Delay2
                DECFSZ 0Eh,1
                GOTO Delay2
                DECFSZ 0Ch,1
                GOTO Delay2
                GOTO Dis

            ;00 to 999 COUNTER

 Dis         CLRF 11h            ;11h is units file. Start=0
               CLRF 12h             ;12h is 10's file. Start=0
               CLRF 13h             ;13h is 100's file. Start=0 
               CLRF 26h             ;1's pointer in table1
               CLRF 27h             ;10's pointer in table1
               CLRF 28h             ;100,'s pointer in table1 
               BCF 05,0              ;Make line LOW to discharge electro
               NOP                      ;Give the circuit time to settle down 
               NOP                      ; and produce 000 readout if no
               NOP                       ; electrolytic is connected
               NOP
               NOP
               NOP
 Dis1       BTFSC 05,1 
               RETURN               ;Electro discharged
               MOVLW 08h
               MOVWF 1Bh
 LoopX    MOVLW 10h
               MOVWF 1A
 LoopY    DECFSZ 1Ah,1
               GOTO    LoopY
               DECFSZ 1Bh,1
               GOTO LoopX
               INCF 11h,1           ;Increment the 1's file
               INCF 26h,1
               INCF 26h,1
               INCF 26h,1
               INCF 26h,1
               INCF 26h,1 
               MOVLW 0A
               XORWF 11h,0
               BTFSS 03,2
               GOTO Dis1           ;File 11h is not 10! 
               CLRF 11h             ;Zero the digits file
               CLRF 26h             ;Zero the pointer for 1st digit 
               INCF 12h,1            ;Increment the 10's file
               INCF 27h,1
               INCF 27h,1
               INCF 27h,1 
               INCF 27h,1
               INCF 27h,1 
               MOVLW 0A
               XORWF 12h,0
               BTFSS 03,2
               GOTO Dis1           ;File 12h is not 10!
               CLRF 12h              ;Zero file 12h
               CLRF 27h              ;Zero the pointer for 2nd digit 
               INCF 28h,1
               INCF 28h,1
               INCF 28h,1 
               INCF 28h,1
               INCF 28h,1 
               GOTO Dis1

                  ;"Digit1" Moves 5 bytes of data from Table1
                  ; to output to produce a digit
                  ; It scans the Display ONCE
                  ;  - the Main program repeats with 60h loops

 Digit1     BSF 05,1            ;Reset 4017
               NOP
               BCF 05,1
               MOVF 28h,0      ;Copy 28h to W 
               MOVWF 23h      ;28h copied to 23h for temp incrementing
               MOVLW 05
               MOVWF 18h        ;5 cycles of Loading count file 18h
 Digit1A   MOVF 23h,0        ;Copy 23h to W
               CALL Table1
               MOVWF 06h        ;output the table value
               CALL Del
               INCF 23h,1
               DECFSZ 18h,1
               GOTO Digit1A 
               RETURN

 Digit2     BSF 05,1               ;Reset 4017
               NOP
               BCF 05,1
               MOVF 27h,0          ;Copy 27h to W 
               MOVWF 23h          ;27h copied to 23h for temp incrementing
               MOVLW 05
               MOVWF 18h           ;5 cycles of Loading count file 18h
 Digit2A   MOVF 23h,0           ;Copy 23h to W
               CALL Table1
               MOVWF 06h
               CALL Del
               INCF 23h,1
               DECFSZ 18h,1
               GOTO Digit2A 
               RETURN

 Digit3      BSF 05,1                 ;Reset 4017
               NOP
               BCF 05,1
               MOVF 26h,0             ;Copy 26h to W 
               MOVWF 23h             ;26h copied to 23h for temp incrementing
               MOVLW 05
               MOVWF 18h             ;5 cycles of Loading count file 18h
 Digit3A   MOVF 23h,0             ;Copy 23h to W
               CALL Table1
               MOVWF 06h
               CALL Del
               INCF 23h,1
               DECFSZ 18h,1
               GOTO Digit3A 
               RETURN

 Del         DECFSZ 1Bh,1
               GOTO Del
               MOVLW 00h
               MOVWF 06
               BCF 05,0         ;Clock the 4017 to the
               NOP                 ; next output
               BSF 05,0
               RETURN

 Delay     MOVLW 04
               MOVWF 1B
 Delay1   DECFSZ 1Ah,1        ;Delay for main program for scanning
               GOTO Delay1
               DECFSZ 1B,1
               GOTO Delay1 
               RETURN

             ;MAIN ROUTINE

 Main       CALL Dis
               BSF 03,5               ;Go to page1 for setting-up the ports 
               MOVLW 1Ch         ;Put 1C into W 
               MOVWF 05h          ;to make RA2,3,4 input 
               CLRF 06h               ;Make all output
               BCF 03,5                ;Go to page0 for program
 Main1    MOVLW 60h           ;60h loop delay to show 1st digit
               MOVWF 1Ch
 Main2    CALL Digit1 
               DECFSZ 1Ch,1
               GOTO Main2
               MOVLW 20h         ;Blanking after 1st digit is displayed
               MOVWF 1Ch
 Main3    CALL Delay 
               DECFSZ 1Ch,1
               GOTO Main3
               MOVLW 60h         ;Delay to show 2nd digit
               MOVWF 1Ch
 Main4    CALL Digit2 
               DECFSZ 1Ch,1
               GOTO Main4
               MOVLW 20h        ;Blanking after 2nd digit is displayed
               MOVWF 1Ch
 Main5     CALL Delay 
               DECFSZ 1Ch,1
               GOTO Main5 
               MOVLW 60h        ;Delay to show 3rd digit
               MOVWF 1Ch   
 Main6     CALL Digit3 
               DECFSZ 1Ch,1
               GOTO Main6
               MOVLW 70h        ;Blanking after 3rd digit is displayed
               MOVWF 1Ch
 Main7     CALL Delay 
               DECFSZ 1Ch,1
               GOTO Main7 
               BTFSS 05,2       ;Is button A pushed?
               GOTO Main1      ;No. Repeat routine
               GOTO Start         ;Yes

                END
 
The block of numbers below is the HEX file for Electro-1, for a PIC16F84c  Copy and paste it into a text program such as TEXTPAD or NOTEPAD and call it: Electro1.hex   
:100000008316023085008312B42882073E344134BF
:10001000413441343E340034103420347F340034D1
:100020002734493449344934313422344134493451
:10003000493436340C34143424347F3404347A3460
:1000400049344934493446343E34493449344934D6
:1000500026344034473448345034603436344934DC
:1000600049344934363432344934493449343E34DD
:10007000003408308C0005148D0B3C288E0B3C2876
:100080008C0B3C284328910192019301A601A70102
:10009000A8010510000000000000000000000000A2
:1000A0008518080008309B0010309A009A0B5628DB
:1000B0009B0B5428910AA60AA60AA60AA60AA60A13
:1000C0000A301106031D50289101A601920AA70AC1
:1000D000A70AA70AA70AA70A0A301206031D502872
:1000E0009201A701A80AA80AA80AA80AA80A5028E3
:1000F0008514000085102808A30005309800230807
:1001000005208600A520A30A980B7F2808008514E7
:10011000000085102708A30005309800230805205B
:100120008600A520A30A980B8E28080085140000DD
:1001300085102608A30005309800230805208600B6
:10014000A520A30A980B9D2808009B0BA52800302A
:100150008600051000000514080004309B009A0B6F
:10016000AF289B0BAF280800432083161C30850066
:100170008601831260309C0078209C0BBC282030C4
:100180009C00AD209C0BC12860309C0087209C0BFC
:10019000C62820309C00AD209C0BCB2860309C00F2
:1001A00096209C0BD02870309C00AD209C0BD5284D
:0601B000051DBA2800281D
:00000001FF

You will also need to download the  PIP-02 program to burn the chip
You should also go to the section "Burning a Chip." This section explains how to load the PIC chip with a .hex file. 

Go to: Electrolytic Tester "stand-alone" version using a PIC12c508A (page3)