You will build a system for measuring the value of a capacitor. The value will
be read on a four-digit, seven-segment LCD display.
Procedure:
There are at least two different ways you could design a circuit/software to measure a capacitance:
$include(a:setup.inc)
;
rseg at 20H
period: dsw 1 ;HSO.0 pulse length
dt: dsw 1 ;time interval variable
;
cseg at 2080H
;
ld sp, #100h ;stack pointer
ld period, #2h ;pulse length
init: ldb ioc2, #80H ;clear HSO CAM
clrb ioc0 ;disable hsi
;init HSI by flushing the FIFO
flush: ld r0, hsi_time ;unload and discard fifo level
; skip r0 ;skip 8 cycles
; skip r0
jbs ios1,7, flush ;flush till empty
;
;setup HSI.0 neg transitions
ldb hsi_mode, #10b ;hsi neg transition mode
ldb ioc0, #1 ;enable hsi.0
;
;put out a pulse on HSO.0 when timer1=0 and end at time1=period
bbs ios1,5, $ ;wait for a timer1 overflow
ldb hso_command, #20H ; hso.0 set
ld hso_time, #0 ; at timer1=0
skip r0 ;wait 4 cycles (for hso load)
skip r0 ;wait 4 cycles
ldb hso_command, #0H ; hso.0 clear at
ld hso_time, period ;clear time
;
;wait for hsi.0 event then compute a time and capacitance
waitHSI:bbc ios1,7, waitHSI ;loop until fifo item avail
ld dt, hsi_time ;get the time
stb dt, port1 ;load it to port 1 for debugging
;
; -- you would put your capacitance calculation and
; display driver code here --
;
;go back and do it again
br init
;
end
Write a program which will repeatedly measure the value of a capacitor. You may assume that the capacitor will be in the range of .001 to .01 microfarad. The capacitance must be displayed numerically on 7 segment LCD displays. The value should be accurate to within a few percent. You may need to use a calibration capacitor during program design to get the accuracy down to 1%.
For extra credit, make the measurement auto-ranging so that a wide range of capacitances can be measured without either losing accuracy or overflowing a counter.
When you demonstrate the program to a staff member, you should show that measured capacitances are correct and be able to explain how you are sure of this.
Your written lab report should include: