I made a capacitor checker using a 16F84A which works very well within limits. It uses the pot command. The code in PICBasic (not Pro) is:
' Capacitor Measurement
' Four digit common anode mulitplexed display
' Scan about 60/s (4ms pause)
' Driver 74HC4511
' Works for 2.0 uf (1K)- 100pf (20K)
' 8/20/06
' For 16F84A Chip
' Data output port A (Pin A5 NC)
' Pins 1 - 4 - Digit select for multiplex
' Pin5 - pot command
' Pin6 - Display Blanking signal (0 = blank)
' Pin7 - Range 1 = high value (1K resistor); 0 = low (20K)
' Digits 1 - 4; W1 - W4
' Measurement (Msr) W10
' Note that scan must be 60/s, and 1ms on + 3ms off shows no flicker, but
' leds are dim. 2ms on & 2ms off works well.
Settings:
Symbol Blank = pin6
Symbol Range = pin7
Symbol D1 = w1
Symbol D2 = w2
Symbol D3 = w3
Symbol D4 = w4
Symbol Msr = w10
Symbol PortA = 5
Poke $85, 0 ' Set port A to all outputs
Output 1 ' Digit 1 - MSD
Low 1 ' off
Output 2 ' Digit 2
Low 2
Output 3 ' Digit 3
Low 3
Output 4 ' Digit 4
Low 4
Output 6 ' Blanking
Low 6 ' Blank all segments
Start:
pause 750
Blank = 0
If range = 0 then testlow 'Check high or low state
'Testhigh:
pot 5,40,msr
Msr = Msr*10 'Raise results for 4 digit display
goto math
Testlow:
Pot 5,255, msr
Msr = Msr*100
Math: 'Set up digits in memory for display
D1 = Msr/1000
D4 = Msr//1000
D2 = D4/100
D4 = D4//100
D3 = D4/10
D4 = D4//10
Display:
poke porta, D1 'Send data
High 1 'Select Digit
Blank = 1 'Remove blanking
Pause 2 'Pause
Blank = 0 'Blank
Low 1 'Unselect digit
'Pause 2 'Pause again to save battery
poke porta, D2
High 2
Blank = 1
Pause 2
Blank = 0
Low 2
'Pause 2
poke porta, D3
High 3
Blank = 1
Pause 2
Blank = 0
Low 3
'Pause 2
poke porta, D4
High 4
Blank = 1
Pause 2
Blank = 0
Low 4
Pause 2
Goto display
end




Bookmarks