|
One of the smallest atmegas, the atmega8, was selected to do the job, as the IO and resource requirements are only limited. The power supply consists of a 9V battery linearly regulated to 5V using a 7805, to get a stable and quiet supply. The rather large 47 uF tantalum decoupling cap might be overkill, but was selected to further stabilize the power supply.
(原文件名:capmeter_schematic.png)
(原文件名:inside.jpg)
(原文件名:lcd_connector.png)
The measurement circuit needs a little explanation. The meter can be in three modes: low range measuring, high range measuring or discharging. These modes are defined by the states of PD5 and PD6. When discharging PD6 pulls low and the capacitor is discharged through R7 (220). At high range measuring PD5 pulls high, charging the capacitor through R8 (1.8K) and PD6 is high impedance to allow the analog comperator to watch the voltage. At low range measuring PD5 is also high impedance and only R6 (1.8Meg) charges the capacitor.
The LCD must be a standard HD44780 compatible 16x2 character display. The connector shown above is a 10 pin flat cable, with a pinout selected for ease of routing on a stripboard. The cable must connect to the LCD as follows:
The circuit was implemented on stripboard and built into a simple plastic case. The top of the case was cut to hold the button, the LED and the LCD, which was all hot-melt glued:
Software
Beside the capacitance measurement logic and configuring the mcu's timer and analog comperator, the following more general tasks are solved by the software:
Assembler optimized fixed point math multiplication
EEPROM read and write functions
Delay milliseconds function
Conversion of numbers to ascii with decimal and decade control (pF, nF, uF, mF)
Hold-down-single-button menu implementation
HD44780 compatible LCD char and string routines
The software can run on atmega8 and on atmega48/88/168 family mcu's. A single line of code dealing with timer setup must be changed according to what family of mcu is used. |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|