基于PIC单片机SPI接口的数据采集模块设计基于PIC单片机SPI接口的数据采集模块设计摘要PIC单片机比MCS-51单片机功能更强大,因为其内部集成了A/D转换模块、USART通讯模块及MSSP端口;本文介绍一种基于PIC16F877A单片机的数据采集模块的设计。首先主机的A/D端口接电位器,实现模拟电压向数字信号的转换,然后对转换后得数据通过SPI接口传输给从机,从机通过显示控制芯片HD7279A,最后通过四位数码管把采集的模拟电压显示出来。系统需要两片单片机完成,分为主机和从机,主机完成数据的采集、A/D转换,转换结果的输出,从机主要完成数据的接受,工程量变换功能。程序采用C语言编写,在集成开发环境MPLAB-IDE下完成编译及程序下载,最终实现能通过调节电位器实现变化的电压显示。关键词PIC单片机数据采集A/D转换SPI接口DESIGNOFDATACOLLECTIONSYSTEMBASEDONI基于PIC单片机SPI接口的数据采集模块设计THESPIPORTofPICMICROCONTROLLERABSTRACTThefunctionofPICMCUismorepowerfulthanMCS-51,becauseitintegratealargenumberofon-chipperipheralssuchasADconvertermodule.USARTcommunicationmoduleandMSSPport,ThisarticleintroducedthedesignofdatacollectionsystembasedontheSPIportofPICMCU,firsttheADCconvertermoduleisconnectedwiththepotentiometer,sotheanalogvoltagecanbeconvertedtodigitalsignal,andthensendthemtothemastermicroprocessorbytheSPIport,Theslavedisplaytheanalogvoltagethroughmulti-pointcalibrationwhichiscontrolledbytheHD7279A.Itneedstwopiecesofmicrocontrollertodothejob,whichisdividedintothemasterandtheslave,theformercompletesdatacollection,A/Dconversion,theconversionresultsofoutput,andthelateracceptsthedatatransmissionaswellasthequantitychange.Clanguageisusedinprogramming,theMPLAB-IDEintegrateddevelopmentenvironmentcompletescompilinganddownloading.Andfinallytheanalogvoltageisdisplayed.KEYWORDSPICMCUDataCollectionADConversionSPIPortII基于PIC单片机SPI接口的数据采集模块设计目录摘要....................................................................................................................................................IABSTRACT.......................................................................................................................................II1绪论...................................................................................................................................................11.1课题背景及研究意义....................................................................................................11.2本设计方案介绍..............................................................................................................22硬件部分设计..............................................................................................................................32.1PIC单片机介绍..............................................................................................................32.1.1PIC单片机的优越之处............................................................................................32.1.2PIC16F877A最小系统图及主要性能..................................................................42.2PIC单片机片内ADC模块及接口实现............................................................52.2.1ADC模块结构和操作原理.....................................................................................52.2.2ADC模块相关的寄存器介绍................................................................................62.2.3A/D转换接口电路设计.............................................................................................