《基于LPC2136的车载油量监控系统(共23页).doc》由会员分享,可在线阅读,更多相关《基于LPC2136的车载油量监控系统(共23页).doc(23页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、精选优质文档-倾情为你奉上深 圳 大 学本 科 毕 业 论 文(设计)题目: 基于LPC2136的车载油量监控系统 姓名: tlx 专业: 软件工程 学院: 成教学院 学号: 指导教师: 朱映映 职称: 副教授 2011年 11 月 24 日深圳大学本科毕业论文(设计)诚信声明本人郑重声明:所呈交的毕业论文(设计),题目基于LPC2136的车载油量监控系统是本人在指导教师的指导下,独立进行研究工作所取得的成果。对本文的研究做出重要贡献的个人和集体,均已在文中以明确方式注明。除此之外,本论文不包含任何其他个人或集体已经发表或撰写过的作品成果。本人完全意识到本声明的法律结果。 毕业论文(设计)作者
2、签名:tlx 日期: 2011 年 11 月 24 日目录3.1 总体设计框架63.2 ISPFLASH在线程序下载63.3断油断电电路73.4主控电路8基于LPC2136的车载油量监控系统唐良兴学号: 【摘要】 基于嵌入式实时操作系统的车载油量监控系统,它集机械、电子检测技术、智能控制和无线通信于一体,结合服务器后台软件平台,是一个综合的车载油量监控系统。本文以LPC2136芯片的ARM7处理器为控制核心,扩展了应用任务,移植了嵌入式实时操作系统uCOSII,设计了一个车载油量监控终端系统。 【关键词】ARM7; uCOSII;无线通信;1.引言1.1研究背景及意义车载油量监控终端具有体积小
3、巧、安装方便、稳定可靠、性价比高、功耗低等优点,可外接紧急求救按键、断油触发开关、监听麦克风、通话手柄、警示灯,特别适合物流业、长途客运、载重汽车等行业应用。1.2本课题主要工作A,ARM Core工控级芯片LPC2136,内嵌uCOSII 操作系统,确保系统稳定高效运行。B,程运行,多任务管理,系统响应及时。C,最新的双频无线通讯模块(SIM900A)。D,高精度油量传感器,检测油量精确(静止状态误差=1%,车辆行驶稳定状态终端:#,RCOV (短信内容)终端-手机:The Currently Oil Value is 88(L)说明:是密码,RCOV是编码(区分大小写);手机读取油量流程:
4、void TASK_OIL_DO(void * lpParam) uint16 OilSamVal; uint16 OIL_3MIN_REC6; uint16 OIL_3MIN_AVG = 0x00; uint16 OIL_AD_Diff,OIL_L_Diff,OIL_AD_TEMP; uint16 Oil_High = 0; uint16 OIL_L = 0; / oil value uint16 OIL_AD = 0; / sample value uint8 Oil_Shape; uint8 Low,High,Middle; uint8 OIL_CNT; uint8 OIL_3MIN_C
5、NT = 0; uint8 i;/拷贝油量校准参数 memset(Tp.Buffer, 0, sizeof(Tp.Buffer); memset(OIL_3MIN_REC, 0, sizeof(OIL_3MIN_REC); Oil_Shape = g_stSystemConfig.OilBoxShape; / OIL_CNT = g_stSystemConfig.ScalingPoints; memcpy(Tp.Buf16B, g_stSystemConfig.OilScalingBuf, OIL_CNT * 4); while (TRUE) /找到靠近的采样点 if (!ExtOilScal
6、lingFlag) DEBUG_PRINT(LOG_LEVEL_INFO, !SamMod!rn); OIL_AD = OIL_GetAdValue(); OIL_L = OIL_AD; DEBUG_PRINT(LOG_LEVEL_INFO, OilBoxShape:%d, ScallingPoint:%d,OIL_AD:%d, g_stSystemConfig.OilDescTh:%d ,Oil_Shape, OIL_CNT, OIL_AD, g_stSystemConfig.OilDescTh); if(Oil_Shape=0) if(OIL_AD=Tp.Buf16BOIL_CNT*2-1
7、)/ sample value more than the last scaling point value OIL_L=Tp.Buf16BOIL_CNT*2-2; / max oil value else if(OIL_CNT) / middle value Low=1; High=OIL_CNT-1; i=0; while(Low=High) Middle=(Low+High)/2; if(OIL_AD15) break; OIL_AD_Diff=Tp.Buf16BLow*2+1-Tp.Buf16BLow*2-1; OIL_L_Diff=Tp.Buf16BLow*2-Tp.Buf16BLo
8、w*2-2; OIL_AD_TEMP=OIL_AD-Tp.Buf16BLow*2-1; OIL_L=Tp.Buf16BLow*2-2+OIL_L_Diff*OIL_AD_TEMP/OIL_AD_Diff; else / err OIL_L=999; /做平均值运算 OIL_3MIN_RECOIL_3MIN_CNT=OIL_L; OIL_3MIN_CNT+; OIL_3MIN_AVG=OIL_3MIN_REC0+OIL_3MIN_REC1+OIL_3MIN_REC2+OIL_3MIN_REC3+OIL_3MIN_REC4+OIL_3MIN_REC5; OIL_3MIN_AVG/=OIL_3MIN
9、_CNT; OIL_3MIN_AVG = EndianLittleToBig_short(OIL_3MIN_AVG); / if(OIL_3MIN_CNT=6) memset(OIL_3MIN_REC, 0, sizeof(OIL_3MIN_REC); OIL_REC_FLAG = 0; OIL_CNT_G = 0; OIL_3MIN_CNT=0; UpGPSOil.UpOil = OIL_3MIN_AVG; / update UpGPSOil.UpOil |= (uint16 )BIT6;/3分钟上传一次油量数据 if (!OIL_REC_FLAG) OIL_REC_FLAG = 1; Up
10、GPSOil.UpOil |= (uint16 )BIT7; / 3min flag H L bytes revise DBG_Print(LOG_LEVEL_WARN, _3Min_frn); _3MinOilStatus(); DEBUG_PRINT(LOG_LEVEL_INFO, !Uploading Oil:0x%x,EndianLittleToBig_short(UpGPSOil.UpOil); OIL_3MIN_AVG = EndianLittleToBig_short(OIL_3MIN_AVG); / TimeDlyms(30000); / 30 sec else /做采样标定
11、if ( (GPRSConnectStatus() = CONN_OK) & (SIM_GetSignal() 9) memset(uint8* )&NowUpOilInfo, 0, sizeof(NowUpOilInfo); /OilSamVal = (uint16 )ADC4Read(4); OilSamVal = OIL_GetAdValue(); NowUpOilInfo.Oil = EndianLittleToBig_short(OilSamVal); NowUpOilInfo.Year = SysTime0; NowUpOilInfo.Month = SysTime1; NowUp
12、OilInfo.Day = SysTime2; NowUpOilInfo.Hour = SysTime3; NowUpOilInfo.Min = SysTime4; NowUpOilInfo.Other1 = SysTime5; SendToPlatform(TERMINAL_SCA_OIL_END_ACK_CMD, SCAL_DATA_LEN, (uint8 *)&NowUpOilInfo); DBG_Print(LOG_LEVEL_INFO, rn!ScaMod!); TimeDlyms(2000); 4.2偷油报警当检测到有偷油报警警情时,终端会立即以短信(The license pla
13、te number:YB12345,status:Warning!Warning!,Oil Alarm!,Please check!)形式发出报警信息到设定的手机号码,会发送两次,当检测到有持续在偷油时,会继续发送报警短信。报警流程:/当前油量值与上一次油量值比较,差值如果大于设定的报警值范围判断发生偷油if (OIL_3MIN_AVG - OIL_L) & (OIL_3MIN_AVG - OIL_L g_stSystemConfig.OilDescTh)if(g_ulBootSecTime 180) DEBUG_PRINT(LOG_LEVEL_INFO, Alarm desc oil. la
14、st oil = %dL, Cur Oil = %dLrn,OIL_3MIN_AVG, OIL_L);_smsContentSend = (char *) OSMemGetEx(ptrSmallMEM,200);snprintf(_smsContentSend,200,The license plate number:%s,status:Warning!Warning!,Oil Alarm!,Please check!,g_stSystemConfig.license_plate_number);if (GET_SYSALARM_TYPE() != ALARMROB) DEBUG_PRINT(
15、LOG_LEVEL_INFO, rn -Set Alarm Flag-rn);SET_SYSALARM_TYPE(ALARMDECOIL);SET_ALARM_FLAG();SendSMS(const char *)_smsContentSend, (char *)g_stSystemConfig.usUserPhoneNum);/发送报警短信memset(OIL_3MIN_REC, 0, sizeof(OIL_3MIN_REC);OIL_REC_FLAG = 0;OIL_CNT_G = 0;OIL_3MIN_CNT = 0;TimeDlyms(2000);SendSMS(const char
16、 *)_smsContentSend, (char *)g_stSystemConfig.usUserPhoneNum);/发送报警短信OSMemPut(ptrSmallMEM, _smsContentSend);else/如果没发生偷油报警,清报警标志,防止异常误报if (GET_SYSALARM_TYPE() = ALARMDECOIL)CLR_SYSALARM_TYPE();4.3加油提示当检测到车辆正在加油时,车辆会发出加油提示短信(The license plate number:YB12345,status:add oil for shape.)到设定的手机号。加油检测提示流程:/
17、 当前的油量减前一次的油量,如果大于设定的值判断为加油if(OIL_L - OIL_3MIN_AVG ) & (OIL_L - OIL_3MIN_AVG g_stSystemConfig.OilDescTh)if(g_ulBootSecTime 180)if(g_ulBootSecTime - add_oil_interval_time 300)add_oil_interval_time = g_ulBootSecTime;_smsContentSend = (char *) OSMemGetEx(ptrSmallMEM,200);snprintf(_smsContentSend,200,Th
18、e license plate number:%s,status:add oil for shape.,g_stSystemConfig.license_plate_number);SendSMS(const char *)_smsContentSend, (char *)g_stSystemConfig.usUserPhoneNum);/发送加油提示短信OSMemPut(ptrSmallMEM, _smsContentSend);memset(OIL_3MIN_REC, 0, sizeof(OIL_3MIN_REC);OIL_REC_FLAG = 0;OIL_CNT_G = 0;OIL_3M
19、IN_CNT = 0;4.4 通话监听当检测到是监听号码的来电时,终端会自动接听监控号码的来电,通过麦克风监听周围的声音,直到监听号码主动挂断;其他号码来电,不做接听的动作。监听流程:/有电话进来 while (ucDealPhone) MDM_WaitRecvDone(); DEBUG_PRINT(LOG_LEVEL_DEBUG,MDM_WaitRecvDone!rn); DEBUG_PRINT(LOG_LEVEL_INFO,g_szGprsRecvBuf,g_ulGprsRecvLen); if (!ucPhoneGetFlag) ulPhoneLen = PhoneNumberScan(
20、char*)g_szComePhoneNUM); if (ulPhoneLen) DEBUG_PRINT(LOG_LEVEL_INFO,Phone(%d):%srn, ulPhoneLen, g_szComePhoneNUM); ucPhoneGetFlag = 1; if(0=memcmp(char*)g_szComePhoneNUM, (char*)g_stSystemConfig.stCenterPhone.CenterResetPhone, ulPhoneLen) ConnectCall();/如果是中心号码,接听来电 if(memcmp(char*)g_szComePhoneNUM,
21、 (char*)g_stSystemConfig.stCenterPhone.MonitorPhone, ulPhoneLen) ConnectCall();/如果是监听号码,接听来电 else ShutUpCall();/如果是其他号码,挂断来电 if (GPRS_ScanStr(NO CARRIER) break;/如果对方提前挂断,就退出 MDM_ClrRecvBuf(); TimeDlyms(1000); 4.5断电报警当检测到主电源被劫匪剪断或电源无法供电时,终端会立即发出断电报警短信。断电报警流程:/检测外部电源是否被断开if (switchstatus & MAIN_P_TURN
22、_OFF) if (2 Power_OFF_Times) wer_ON_Times = 0;CLR_MAIN_POWER_ON_FLAG();if (ALARMROB != GET_SYSALARM_TYPE()if (ALARMGPS != GET_SYSALARM_TYPE()SET_SYSALARM_TYPE(ALARMGPS);SET_ALARM_FLAG();Main_Power_Flag = 1;DEBUG_PRINT(LOG_LEVEL_WARN, rnWarning:Main Power Off!);#if BAT_ADC_ENABLEBAT_PowerDownProcess(
23、);/发生外部电源断开时,切换到电池供电模式#endifelsePower_OFF_Times+;elseif (2 Power_ON_Times) Power_OFF_Times = 0;SET_MAIN_POWER_ON_FLAG();if (ALARMGPS = GET_SYSALARM_TYPE()CLR_SYSALARM_TYPE();CLR_ALARM_FLAG();Main_Power_Flag = 0;DEBUG_PRINT(LOG_LEVEL_WARN, rnWarning:Main Power On!);#if BAT_ADC_ENABLE AT_PowerOnProces
24、s();/切换到外部供电模式#endif elsePower_ON_Times+;5.开发环境5.1硬件开发环境原理图设计PCB设计5.2软件开发环境使用source insight进行软件开发设计;5.3 最终产品图专心-专注-专业6结束语本文设计开发了基于LPC2136芯片的车载油量监控终端系统,也是基于嵌入式实时操作系统C/OS-,对各个功能执行元件进行协调控制,为嵌入式系统在车载油量监控控制方面的应用和扩展搭建了良好的技术平台。【参考文献】1 Philips Corporation roduct data sheet LPC2131/32/34/36/38 Rev. 04 16 Oct
25、ober 2007 2桑楠. 嵌入式系统原理及应用开发技术M . 北京:北京航空航天大学出版社,20023Kirk Zurell 嵌入式系统的C程序设计M,艾克武等翻译,北京;机械工业出版社,2001;4魏忠,蔡勇,雷红卫. 嵌入式开发详解M . 北京:电子工业出版社,2003致谢首先衷心地感谢朱映映老师。在我大学生涯里,给予了很多指导与帮助。本次毕业设计,从选题到论文撰写,给予我很多宝贵的意见。朱映映渊博的学识、严谨的治学态度及认真负责的工作态度都使我受到鼓舞和熏陶。在此向朱映映老师表示崇高的敬意和衷心的感谢。感谢三年以来老师们的辛勤授课,丰富了我们的知识,拓宽了我们的视野,提高了我们发现问题、解决问题的能力,使我的思想产生了质的飞跃。感谢开源社区,提供了很多开放源码与类库,为我提供了庞大的优秀代码资源,使我在程序开发过程中得到很多启发。感谢一直关心我、支持我的父母和朋友们。 由于本人水平有限,加之时间仓促,文中难免会有疏漏和错误,敬请老师批评指正。谢谢大家!tlx2011-11-24