上海交通大学硕士学位论文基于RS485总线的智能家居系统的实现姓名:陶莉申请学位级别:硕士专业:电子与通信工程指导教师:黄佩伟20080111RS485-1-RS485ICRS485RS485RS485LinuxRS485-2-ABSTRACTREALIZATIONOFINTELLIGENTHOMESYSTEMBASEDONRS485BUSNetworktechnologyandthedevelopmentofdigitalinformationhaveprovidedstrongtechnicalsupportforrealizationofintelligenthome.Thedevelopmentofsensortechnologyofferstechnicalfoundationfortheexchangeofinformationbetweenfamilyequipmentandnetwork.Whilethedevelopmentofcomputertechnology,large-scaleICandembeddedtechnologyrealizemonitoring,controlandmanagementofequipmentaccesstohomenetwork.Onthebasisofabove,thisissueproposesalow-cost,low-powerhomesystemsolution.TheintelligenthomesystemsolutionbasingonRS485busraisedbythisthesisincludesthreeparts:terminalaccessmodule,relayandhomegateway.Singlechipservesascontrolcoreofaccessmodule.Forthefirsttime,thispaperproposesconceptofuniversalaccessmodulewhichusedtointegratevarioussensorsandswitchesintohomenetwork.Relayformsinter-familycommunicationnetworkwithvariousaccessmodulesusingRS485bus.Homegatewayandrelayconnectthroughinternetinordertoforminternalhomecommunicationnetwork.Andthissysteminteractinformationwithoutsidethroughhomegateway.ToensuredataRS485-3-transmissionwithoutconflictbetweenterminalaccessmoduleandrelay,thisdesignproposesperfectcommunicationprotocol.Atthesametimefocusingoncharacteristicsofoperatingsystemforembeddedsystem,thispaperproposesfunctionsofautomaticupdatingandprotectionofsoftware.Thispaperpresentshardwarecircuitandsoftwareflowchartofeachmodule,framestructureofcommunicationprotocol,anddifferentmeasuredscenetoshowcompletelifecycledetectionofaccessmodulesanduplinkanddownlinkdataframetransmissionfunctions.KEYWORDS:Communicationprotocol,RS485bus,relay,homegateway,Linux200811120081112008111RS485-1-1.11.1.1[1]1.1.2[2]1.HUB2.3.4.24RS485-2-5.6.7.8.9.1.1.31984X-10CEBus[3][4]HBS(HomeBusSystem)EIB(EuropeanInstallationBus)EHS(EuropeanHomeSystem)[5]e-Home1.2RS485-3-1.2.120RS485CANLIN[6][7]RS485CANBOSCHISOISO11898CANLINLIN1.2.21.2.2.1HomeRFHomeRFWLAN[8]HomeRF(FHSS)/(CSMA/CA)HomeRFTCP/IP48IPHomeRF2.4GHz1MHz2Mbps100HomeRF1.2.2.2IrDAIrDA,4Mbps,,IrDA12[9]RS485-4-1.2.2.3BlueTooth2.4GHZ1600/[10]1Mbps10m100m8[11][12]1.2.2.4ZigBeeZigBee[13][14]ZigBee20k250kbpsZigBee1.2.3“0”“1”()()“”RS485-5-1.3[15]MCUMCUMCURS485ARMPCRS485PCPC:RS485-6-2.1HomeGatewayHGWHGWHWGHWGHGWHGWAV1UPnPSIPEchonetHGWHGWHGW2-1Tab2-1Familyelectricalequipments・・・・・・・IF・・RS485-7-[15]()2.22-1Fig2-1SystemstructureinternetRS485-8-2.2.1SJ/T11313-2005100/10Base-T100/10Base-TGB/T15629.33(CSMA/CD)100/10Base-T8220.85V-0.85V“1”“0”100mADSLSJ/T11313-2005100/10Base-T100/10Base-TTCP/IPIPDHCP100/10Base-T2.2.2HGW1.RS485-9-2.3.4.5.2.2.3//1.2.3./1.2.3.1.2.RS485-10-3.4.2.2.43“”ADSLIEEE802.3/U10M/100MWiFi54MbpsIEEE802.11b/a/g5MbpsHomePlug1.058MbpsWiFiIEEE802.3/U10M/100M2—3WiFiPLCIEEE802.3/UWiFiRS485-11-2.3“”30/5V0∼5V2-22-2Fig2-2Demooffamilynetworkintelligentmanagementandservice2.4RS485-12-3(Relay)(Access)(HGW)(2-3)2-3Fig2-3FrameworkoffamilynetworkAccessRelayHGWAccessRelayHGWAccessRelayHGW2.51.RS485-13-2.RS4853.4.LINUXLIDS5.LINUXautomountRS485-14-MCU3-1Fig3-1StructureofterminalaccessmoduleMCUMCURS485RS485-15-3.1(a)(b)3-2(a)(b)Fig3-2Accessdetectioncircuit(a)Non-insert(b)inserted(SensorDetection)Vcc(5V)(SensorDetection)RPowerGND(0V)3-3Fig3-3Sensoraccesssignal3-33.2MCURS485-16-A/DMCU1/GH-7183V0V320∼5V1∼5V0∼10V0-5V30∼10mA0∼20mA4∼20mA4-20mA3.2.13-43-4Fig3-4Switchadaptationcircuit6N137[24]26MCU2R16.5∼15mA,10KΩRS485-17-8VCC4.5V∼5.5V0.1uF6R24.7KΩC210pFGH-7183.2.212//A/D34A/DAngilentHCNR2003.2.2.1HCNR200HCNR200HCNR200PD1PD2LEDIPD1/IPD2HCNR2000.01%100±5%8000VLEDPD1PD2PD2PD1RS485-18-3-5HCNR200Fig3-5HCNR200principlediagram3.2.2.2HTW-14-20mA4-20mA0-5V3-6/[16]3-6/Fig3-6Current/Voltageisolationandtransformationcircuit4-20mA5.1VLM158LEDPD1PD1R1R31313*/()PDLOOPIIRRR=+1PDI50uA:25*OUTPDVIR=RS485-19-213513/(/)**/()OUTLOOPPDPDVIIIRRRR=+21/PDPDII1R330Ω4-20mA1-5LM1583.2.2.305V010VSC000330K-200KΩ0-10V/HCNR2003-7Q1Q2R3R4LEDPD1PD1Q103-7/Fig3-7Voltage/voltageisolationandtransformationcircuitIFQ10R1PD1Q1011/PDINIVR=PD1LEDQ3Q4R2,22OUTPDVIR=⋅RS485-20-21/*(/)OUTINVVKRR=,12/PDPDKII=R1R21PDI≤50uAR4R6R3R5Q2Q4R7Q4Q2R1R21.1.5MHz2.3.4.3.3RS485()2RS232RS485RS485RS485SerialLinkMCURelayRS485RS232/485MCUMCURS485RS485RS4853-8Fig3-8NearbyaccessmodulecompositionRS485-21-MCUMCU3.3.2MCU3.3.2.1MicrochipPIC12mA1uA2220V,,32-6V420MHZ200ns5RISC(ReducedInstructionSetCPU)35678810A/DPIC16F877A3-9MCU-PIC16F877AFig3-9NearbyaccessmoduleMCU-PIC16F877ARS485-22-3.3.2.21MCLR131Vdd2VddMCLR/Vpp10KΩMCLR/Vpp13V310kΩPIC16F87X10kΩ10kΩPIC/XTHS4MHZLP32KHzRC/XTHSLPOSC1OSC2/Rs0Rs10K3-10MCUFig3-10MCUoscillatorycircuitHS11.0592MHz20pFA/D0.1uFVdd5Vss0.1uFRS485-23-3-11MCUFig3-11MCUpower,resetandclockcircuits3.3.3A/D05PIC16F877AADC“”8108ADC0x00-0xFF0x000xFFADC8A/D3AN13.3.4MCUUSARTPICRS485-24-1200bps19200bps11.0592MHz9600bps3-12Fig3-12AsynchronouscommunicationdatatransmissionPCPIC16F877ARS232RS232TTLCMOSMax232PCRS2323-13PICMAX232Fig3-13PICandMAX232communicationinterfaceRS-48532128RS485RS485-25-RS-485SN75176RS485[18]3-14Fig3-14Diagramofhardware