前几天在家看到我家的锂电吸尘器没电了,但是充满后用了一会就又没了,电量明明显示还有两格,心想这个东西太不靠谱了,于是就寻思如果能测试出电池的容量就好了,便自己动手做了一个锂电容量测试仪,
老规矩废话不多说,先上实物图
工作原理时:此设计是用万能板搭建,显示用12864字库屏,主板与屏幕分开,这个单片机电池容量测试仪对于锂电/镍氢程序实现自动识别。该设备会自动识别电池类型(锂电池还是镍氢电池)。
识别的方法:电压高于2.7就是锂电,低于2.7高于2V就是锂电低电压,会有提示;高于1低于2,就是镍氢电池。左下角放电测试时会显示截止电压。
本设计仅供参考如果设计有不合理之处请大神勿喷,再次仅仅起到学习和抛转引玉的效果。
本设计参考C语言源代码:
;-------------------------
; LCD12864.ASM
;
;12864液晶屏显示驱动程序
;-------------------------
SENDI:;------串行控制命令写入------------------------
; LCALL FD ;等忙时间
MOV RAM0,#15
DJNZ RAM0,$
;------------第一字节,11111000,从MCU到屏,控制字 ,rs,rw都为0
SETB RS ;片选为1
MOV R7,#5
SENDI1: SETB RW ;前四位都为1
NOP
NOP
CLR E
NOP
NOP
NOP
NOP
SETB E
DJNZ R7,SENDI1
MOV R7,#3
SENDI2: CLR RW
NOP
NOP
CLR E
NOP
NOP
NOP
NOP
SETB E
DJNZ R7,SENDI2
;-------第二三字节,8位的高四位------------------
MOV R6,#2
SENDI5: MOV R7,#4
SENDI3: RLC A
MOV RW,C
NOP
NOP
CLR E
NOP
NOP
NOP
NOP
SETB E
DJNZ R7,SENDI3
MOV R7,#4
CLR C
SENDI4: MOV RW,C ;后4位全为0
NOP
NOP
CLR E
NOP
NOP
NOP
NOP
SETB E
DJNZ R7,SENDI4
DJNZ R6,SENDI5
CLR RS
RET
;-----------------------------------------------
SENDD: ;------串行数据字节写入---------------------
; LCALL FD ;等忙时间
MOV RAM0,#15
DJNZ RAM0,$
;------------第一字节,11111000,从MCU到屏,控制字
SETB RS ;片选为1
MOV R7,#5
SENDD1: SETB RW ;前四位都为1
NOP
NOP
CLR E
NOP
NOP
NOP
NOP
SETB E
DJNZ R7,SENDD1
CLR RW ;第三位,从MCU到LCD,0
NOP
NOP
CLR E
NOP
NOP
NOP
NOP
SETB E
SETB RW ;第二位,数据,1
NOP
NOP
CLR E
NOP
NOP
NOP
NOP
SETB E
CLR RW ;第1位,0
NOP
NOP
CLR E
NOP
NOP
NOP
NOP
SETB E
;-------第二三字节,8位的高四位------------------
MOV R6,#2
SENDD5: MOV R7,#4
SENDD3: RLC A
MOV RW,C
NOP
NOP
CLR E
NOP
NOP
NOP
NOP
SETB E
DJNZ R7,SENDD3
MOV R7,#4
CLR C
SENDD4: MOV RW,C ;后4位全为0
NOP
NOP
CLR E
NOP
NOP
NOP
NOP
SETB E
DJNZ R7,SENDD4
DJNZ R6,SENDD5
CLR RS
RET
/从缓存取数据送显示/
LCDDS: MOV DPTR,#TAB1F ;
LCDDS1: MOV A,@R0 ;取列表
MOVC A,@A+DPTR
LCALL SENDD
INC R0
DJNZ DSDAT,LCDDS1 ;取完N个数
RET
LCDDS2: MOV DPTR,#TAB1F
LCDDS3: MOV A,R0
MOVC A,@A+DPTR
LCALL SENDD
INC R0
DJNZ DSDAT,LCDDS3
RET
TAB10: DB " 电池容量测试 " ;
TAB11: DB "V=0.00V I=0.00A "
TAB12: DB "0:00:00 0mAh "
TAB13: DB “SV2.70V SR0.00A”
; 0 10 141618 22 30
TAB1F: DB "0123456789: -.=VRLAmD 待机…SV已结束! ",0
/*
TAB1:
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,96,0,0,96,0,0,0,0;
DB 0,0,192,0,102,0,195,128,99,0,99,96,49,128,0,0;
DB 0,0,192,0,99,0,222,0,97,128,99,252,49,128,0,0;
DB 0,0,192,0,96,0,198,192,96,240,103,96,49,128,0,0;
DB 0,0,192,0,126,0,255,128,127,176,121,240,49,240,0,0;
DB 0,0,248,7,192,3,204,3,248,1,231,48,63,176,0,0;
DB 0,31,152,0,243,0,219,128,126,192,103,240,241,224,0,0;
DB 0,1,152,0,243,0,254,0,118,96,118,48,49,252,0,0;
DB 0,1,176,1,182,1,247,240,236,0,251,224,63,128,0,0;
DB 0,3,48,1,188,15,254,1,225,193,225,188,113,128,0,0;
DB 0,3,48,195,56,96,198,199,111,3,111,225,195,192,0,0;
DB 0,6,48,198,112,96,222,192,99,0,97,192,6,96,0,0;
DB 0,12,48,204,240,97,223,193,227,240,99,96,12,56,0,0;
DB 0,56,31,152,31,224,248,192,254,0,102,48,56,30,0,0;
DB 0,0,0,0,0,0,0,0,0,0,124,28,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,48,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,48,0,3,0,0,48,1,128,24,0,0,0,0;
DB 0,0,0,96,0,115,1,158,48,97,176,27,48,0,0,0;
DB 0,0,0,96,3,195,0,246,48,49,152,49,176,0,0,0;
DB 0,0,0,254,0,3,224,103,176,1,128,49,176,0,0,0;
DB 0,0,1,134,0,127,102,127,176,1,240,108,48,0,0,0;
DB 0,0,1,134,7,195,99,127,176,239,128,118,96,0,0,0;
DB 0,0,1,246,0,195,96,127,179,225,128,243,96,0,0,0;
DB 0,0,1,134,1,182,96,255,176,99,193,177,224,0,0,0;
DB 0,0,1,134,3,118,97,255,176,110,192,48,192,0,0,0;
DB 0,0,1,246,3,252,193,156,48,102,96,49,224,0,0,0;
DB 0,0,1,134,0,24,195,54,48,119,236,51,56,0,0,0;
DB 0,0,1,254,0,51,192,102,112,124,60,62,30,0,0,0;
DB 0,0,1,206,0,97,128,192,48,0,28,48,0,0,0,0;
DB 0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 7,156,243,224,12,32,15,128,0,0,0,0,13,136,0,192;
DB 8,136,74,64,18,96,10,128,0,0,0,0,5,24,1,32;
DB 8,8,72,143,130,35,226,0,0,0,0,0,5,8,1,32;
DB 8,8,72,128,12,32,2,0,0,0,0,0,5,8,1,32;
DB 8,8,73,0,2,32,2,0,0,0,0,0,5,8,1,32;
DB 8,136,73,32,18,32,2,0,0,0,0,0,2,8,1,32;
DB 7,8,243,224,12,112,7,0,0,0,0,0,2,28,64,192;
DB 0,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;“G:8951项目 9-27 九龙摇控器自动测试台开机画面.bmp”,0
/* (128 X 64 )*
TAB2:
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,24,0,0,0,0,0,0,0,0,0,0,192,0,0;
DB 0,0,28,0,0,0,0,0,1,192,56,0,48,112,0,0;
DB 0,0,28,0,0,222,0,0,1,192,24,0,48,96,0,0;
DB 0,0,62,0,0,254,3,128,1,192,24,0,112,96,0,0;
DB 0,0,119,0,0,206,31,192,3,224,24,0,112,96,0,0;
DB 0,0,115,128,0,207,249,128,3,123,24,0,224,126,0,0;
DB 0,0,225,192,0,206,219,128,7,61,152,0,195,240,0,0;
DB 0,1,192,224,0,254,219,128,14,13,152,1,192,96,0,0;
DB 0,3,128,112,0,254,219,0,12,1,152,3,192,96,0,0;
DB 0,3,15,252,0,206,223,128,24,225,152,3,192,127,128,0;
DB 0,6,126,63,128,206,240,0,63,241,152,6,195,240,0,0;
DB 0,12,0,31,192,254,192,0,110,97,152,12,206,224,0,0;
DB 0,56,0,0,0,238,192,0,198,97,152,24,192,96,0,0;
DB 0,96,1,128,1,204,192,24,7,225,152,0,192,96,0,0;
DB 0,0,31,192,1,140,192,24,6,225,152,0,192,252,0,0;
DB 0,3,241,224,1,140,192,56,6,192,24,0,195,224,0,0;
DB 0,1,129,192,3,140,224,120,6,12,24,0,192,96,0,0;
DB 0,1,193,128,3,60,127,248,6,28,24,0,192,96,0,0;
DB 0,0,193,128,6,28,31,192,7,252,24,0,192,127,192,0;
DB 0,0,255,128,6,28,0,0,1,240,248,1,255,240,0,0;
DB 0,0,224,0,0,24,0,0,0,0,120,0,192,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,56,0,192,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0;
DB 1,0,0,128,0,0,0,0,0,128,0,0,0,0,0,0;
DB 1,0,1,224,3,0,7,240,1,128,0,240,3,0,0,248;
DB 25,112,7,192,3,0,5,80,1,248,61,160,1,128,7,16;
DB 24,192,7,0,3,224,7,96,31,0,41,32,4,192,0,16;
DB 0,96,2,128,31,48,1,120,18,224,41,160,12,96,3,144;
DB 17,128,7,224,23,176,15,192,3,32,41,96,9,48,28,16;
DB 48,224,7,128,23,32,2,96,6,160,57,216,19,24,7,144;
DB 39,160,0,248,15,160,4,48,11,32,41,224,54,28,25,144;
DB 36,36,31,128,15,224,15,252,50,160,34,96,69,198,15,16;
DB 40,36,32,128,3,2,53,167,3,32,34,16,15,32,14,16;
DB 24,38,0,128,1,6,6,96,2,32,34,78,31,96,0,16;
DB 0,54,0,128,0,254,0,0,2,32,35,130,0,0,0,112;
DB 0,14,0,128,0,0,0,0,0,96,0,0,0,0,0,16;
DB 0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;“C:Documents and Settingsnew桌面22.bmp”,0
/**/
鉴于篇幅有限,只能写部分参考代码
上一篇:用单片机和LED灯阵制作的贪吃蛇趣味小游戏
下一篇:带自动喂鱼的鱼缸自动控制系统设计与制作
推荐阅读最新更新时间:2024-11-12 17:47
设计资源 培训 开发板 精华推荐
- 使用 LT1054IS8 双极电源倍增器的典型应用
- LT1172HVIQ 的典型应用,1.25A 外部电流限制
- OP484FSZ-REEL 缓冲网络补偿容性负载的典型应用
- 使用 ADG5409 模拟多路复用器的稳健、低功耗、电池监控电路前端
- 使用 ROHM Semiconductor 的 BD49L27G-TL 的参考设计
- 使用 Omron 的 S8VS-24024 的参考设计
- AD8548ARZ-R7反相运算放大器配置的典型应用电路
- ONMCU3V3R1GEVB:ONMCU DIL 3V3 控制板
- XRP7659 的典型应用,12 至 5V/1.5A DC 至 DC 非同步降压稳压器
- USB2.1_Hub