《毕业论文(设计)基于82527 的CAN 总线智能传感器节点设计.doc》由会员分享,可在线阅读,更多相关《毕业论文(设计)基于82527 的CAN 总线智能传感器节点设计.doc(8页珍藏版)》请在三一办公上搜索。
1、基于82527的CAN总线智能传感器节点设计初宪武 汪玉凤 王 丽摘要:介绍一种以8051微控制器和82527独立CAN总线控制器为核心组成的CAN总线智能传感器节点的设计方法,并给出其硬件原理图和初始化程序。关键词:CAN总线;82527;单片机;数据采集;智能节点1 引言 CAN(Controller Area Network,控制局域网)属于工业现场总线,是德国Bosch公司20世纪80年代初作为解决现代汽车中众多的控制与测试仪器间的数据交换而开发的一种通信协议。1993年11月,ISO正式颁布了高速通信控制局域网(CAN)的国际标准(ISO11898)。CAN总线系统中现场数据的采集由
2、传感器完成,目前,带有CAN总线接口的传感器种类还不多,价格也较贵。本文给出一种由8051单片机和82527独立CAN总线控制器为核心构成的智能节点电路,在普通传感器基础上形成可接收8路模拟量输入和智能传感器节点。2 独立CAN总线控制器82527介绍82527是Intel公司生产的独立CAN总线控制器,可通过并行总线与Intel和Motrorola的控制器接口;支持CAN规程2.0B标准,具有接收和发送功能并可完成报文滤波。82527采用CHMOS 5V工艺制造,44脚PLCC封装,使用温度为-44+125,其引脚的排列和定义参见参考文献1。2.1 82527的时钟信号82527的运行由2种
3、时钟控制:系统时钟SCLK和寄存器时钟MCLK。SCLK由外部晶振获得,MCLK对SCLK分频获得。CAN总线的位定时依据SCLK的频率,而MCLK为寄存器操作提供时钟。SCLK频率可以等于外部晶振XTAL,也可以是其频率的1/2;MCLK的频率可以等于SCLK或是其频率的1/2。系统复位后的默认设置是SCLK=XTAL/2,MCLK=SCLK/2。2.2 82527的工作模式82527有5种工作模式:Intel方式8位分时复用模式;Intel方式16位分时复用模式;串行接口模式;非Intel方式8位分时复用模式;8位非分时复用模式。本文应用Intel方式8位分时复用模式,此时82527的30
4、和44脚接地。2.3 82527的寄存器结构282527的寄存器地址为00FFH.下面根据需要对寄存器给予介绍。控制寄存器(00H):765432100CCE00EIESIEIEINITCCE改变配置允许位,高电平有效。该位有效时允许CPU对配置寄存器1FH、2FH、3FH、4FH、9FH、AFH写操作。EIE错误中断允许位,高电平有效。该位一般置1,当总线上产生异常数量的错误时中断CPU。SIE状态改变中断允许位,高电平有效。该位一般置0。IE中断允许位,高电平有效。INIT软件初始化允许位,高电平有效。该位有效时,CAN停止收发报文,TX0和TX1为隐性电平1。在硬件复位和总线关闭时该位被
5、置位。CPU接口寄存器(02H):76543210RSTSTDSCDMCPWDSLEEPMUX0CENRSTST硬件复位状态位。该位由82527写入,为1时硬件复位激活,不允许对82527访问;为0时允许对82527访问。DSCSCLK分频位。该位为1,SCLK=XTAL/2;为0,SCLK=XTAL。DMCMCLK分频位。该位为1,MCLK=SCLK/2;为0,MCLK=SCLK。PWD掉电模式使能位,高电平有效。SLEEP睡眠模式使能位,高电平有效。MUX低速物理层复用标志位。该位为1,ISO低速物理层激活,PIN24=VCC/2,PIN11=INT#(表示取反);该位为0,PIN24=I
6、NT#,PIN11=P2.6。CEN时钟输出允许位,高电平有效。标准全局屏蔽寄存器(0607H)。该寄存器用于具有标准标识符的报文,或XTD置0的报文寄存器。该方式称为报文接收滤波。当某位为1时,报文标识符的相应位必须匹配;为0时,不必匹配。扩展全局屏蔽寄存器(080BH)。该寄存器用于扩展报文格式,或XTD置1的报文寄存器,其作用与相同。765432100COBYPOL0DCT10DCR1DCR0总线配置寄存器(2FH):COBY旁路输入比较器标志位,高电平有效。POL极性标志位。为1,如果旁路输入比较器,RX0的输入逻辑1为显性,逻辑0为隐性;为0,则反之。DCT1TX1输出切断控制位。为
7、1,TX1输出不被驱动,该模式用于1根总线的情况,2根差分导线短路;为0,TX1输出被驱动。DCR1RX1输入切断控制位。为1,RX1与输入比较器的反相端断开,接至VCC/2;为0,RX1接至输入比较器反相端。DCR0RX0输入切断控制位。作用与DCR1相同,此时RX0接至比较器同相端。76543210SJWBRP位定时寄存器0(3FH);SJW同步跳转宽度位场,编程值13。BRP波特率分频位场,编程值063。76543210SPLTSEG2TSEG1位定时寄存器1(4FH):SPL采样模式标志位。1表示每位采样3次;0表示每位采样1次。TSEG1时间段1位场,编程值215。TSEG1时间段2
8、位场,编程值17。波特率=XTAL/(DSC+1)*(BRP+1)*(3+TSEG1+TSEG2)报文寄存器(把每个寄存器的第1字节地址作为基址BASE)。76543210BASE+0MSGVALTXIERXIEINTPNDBASE+1RMTPNDTXRQSTMSGLST/CPUUPDNEWDAT控制寄存器0,1(BASE+0,BASET+1)MSGVAL报文寄存器有效标志位,高电平有效。10置位,01复位。TXIE发送中断允许标志位,高电平有效。10置位,01复位。RXIE接收中断允许标志位,高电平有效,10置位,01复位。INTPND中断申请标志位,高电平有效。10置位,01复位。RMTP
9、ND远程帧申请标志位,高电平有效。10置位,01复位。TXRQST请求发送标志位,高电平有效。10置位,01复位。MSGLST报文丢失标志位,只用于接收报文寄存器。10表示未读报文被新报文覆盖,01表示未覆盖。CPUUPDCPU更新标志位,只用于发送报文寄存器。10报文不被发送,01报文可发送。NEWDAT新数据标志位。10表示向寄存器写入了新数据,01表示无新数据写入。仲裁寄存器0,1,2,3(BASE+2-BASE+5)存储报文标识符。76543210DLCDIRXTD保留报文配置寄存器(BASE+6)DLC数据长度编码,编程值08。DIR方向标志位。1发送,0接收。XTD标准/扩展标识符
10、标志位。1扩展标识符,0标准标识符。数据寄存器(BASE+7-BASE+14)82527存储报文时,8个数据字节均被写入,未用到的字节数据是随机的。2 硬件电路设计智能节点的电路如图1所示(图中6264略去)。在硬件设计中,由ADC0809完成对8路模拟置的转换,与8051的信息交换采用查询方式,地址BFF8BFFFH,其时钟可由ALE二分频获得;82527完成与CAN总线的信息交换。本设计中,旁路了输入比较器,与8051的信息交换采用中断方式,地址7F007FFFH,可以用82527的P1口和P2口对开关量采集或对继电器进行控制。82C250提供82527和物理总线间的接口,提高接收和发送能
11、力。可根据需要扩展程序存储器。3 软件设计本设计软件采用MCS-51汇编语言编写,程序框图如图2所示。82527的初始化程序如下:INT:MOV DPTR,0FF02HMOV A,00HMOVX DPTR,A ;SCLK=XTAL;MCLK=SCLK,CLKOUT无效MOV DPTR,0FF00HMOV A,41HMOVX DPTR,A ;置位CCE,INITMOV DPTR,0FF2FHMOV A,48HMOVX DPTR,A ;旁路输入比较器设置1位隐性,0为显性,RX1无效MOV DPTR,0FF3FH;MOV A,43H;MOVX DPTR,A ;SJW=2,BRP=3MOV DPTR
12、,0FF4FHMOV A,0EAHMOVX DPTR,A ;SPL=1,TSEG1=7,TSEG2=6此时波特率为100KbpsMOV DPTR,#0FF00H;MOV A,01HMOVX DPTR,A ;禁止对配置寄存器的访问MOV DPTR,0FF10H;MOV A,55H;MOVX DPTR,A;INC DPTR;MOVX DPTR,A;MOV DPTR,0FFF0H;MOV A,55H;MOVX DPTR,AINC DPTR;MOVX DPTR,A ;报文寄存器控制位初始化MOV R0,06H;MOV DPTR,0FF06H;MOV A,0FFH;L1:MOVX DPTR,A ;报文标
13、识符需全部匹配INC DPTRDJNZ R0,L1;MOV DPTR,0FF16H;MOV A,8CH ;报文寄存器1可发送8个字节扩展报文MOVX DPTR,A;MOV DPTR,#0FF26H;MOV A,#84H;MOVX DPTR,A ;报文寄存器2可接收8个字节扩展报文MOV DPTR,0FF00H;MOV A,00H;MOVX DPTR,A ;初始化结束RET Editors note: Judson Jones is a meteorologist, journalist and photographer. He has freelanced with CNN for four
14、years, covering severe weather from tornadoes to typhoons. Follow him on Twitter: jnjonesjr (CNN) - I will always wonder what it was like to huddle around a shortwave radio and through the crackling static from space hear the faint beeps of the worlds first satellite - Sputnik. I also missed watchin
15、g Neil Armstrong step foot on the moon and the first space shuttle take off for the stars. Those events were way before my time.As a kid, I was fascinated with what goes on in the sky, and when NASA pulled the plug on the shuttle program I was heartbroken. Yet the privatized space race has renewed m
16、y childhood dreams to reach for the stars.As a meteorologist, Ive still seen many important weather and space events, but right now, if you were sitting next to me, youd hear my foot tapping rapidly under my desk. Im anxious for the next one: a space capsule hanging from a crane in the New Mexico de
17、sert.Its like the set for a George Lucas movie floating to the edge of space.You and I will have the chance to watch a man take a leap into an unimaginable free fall from the edge of space - live.The (lack of) air up there Watch man jump from 96,000 feet Tuesday, I sat at work glued to the live stre
18、am of the Red Bull Stratos Mission. I watched the balloons positioned at different altitudes in the sky to test the winds, knowing that if they would just line up in a vertical straight line we would be go for launch.I feel this mission was created for me because I am also a journalist and a photogr
19、apher, but above all I live for taking a leap of faith - the feeling of pushing the envelope into uncharted territory.The guy who is going to do this, Felix Baumgartner, must have that same feeling, at a level I will never reach. However, it did not stop me from feeling his pain when a gust of swirl
20、ing wind kicked up and twisted the partially filled balloon that would take him to the upper end of our atmosphere. As soon as the 40-acre balloon, with skin no thicker than a dry cleaning bag, scraped the ground I knew it was over.How claustrophobia almost grounded supersonic skydiverWith each twis
21、t, you could see the wrinkles of disappointment on the face of the current record holder and capcom (capsule communications), Col. Joe Kittinger. He hung his head low in mission control as he told Baumgartner the disappointing news: Mission aborted.The supersonic descent could happen as early as Sun
22、day.The weather plays an important role in this mission. Starting at the ground, conditions have to be very calm - winds less than 2 mph, with no precipitation or humidity and limited cloud cover. The balloon, with capsule attached, will move through the lower level of the atmosphere (the tropospher
23、e) where our day-to-day weather lives. It will climb higher than the tip of Mount Everest (5.5 miles/8.85 kilometers), drifting even higher than the cruising altitude of commercial airliners (5.6 miles/9.17 kilometers) and into the stratosphere. As he crosses the boundary layer (called the tropopaus
24、e), he can expect a lot of turbulence.The balloon will slowly drift to the edge of space at 120,000 feet (22.7 miles/36.53 kilometers). Here, Fearless Felix will unclip. He will roll back the door.Then, I would assume, he will slowly step out onto something resembling an Olympic diving platform.Belo
25、w, the Earth becomes the concrete bottom of a swimming pool that he wants to land on, but not too hard. Still, hell be traveling fast, so despite the distance, it will not be like diving into the deep end of a pool. It will be like he is diving into the shallow end.Skydiver preps for the big jumpWhe
26、n he jumps, he is expected to reach the speed of sound - 690 mph (1,110 kph) - in less than 40 seconds. Like hitting the top of the water, he will begin to slow as he approaches the more dense air closer to Earth. But this will not be enough to stop him completely.If he goes too fast or spins out of
27、 control, he has a stabilization parachute that can be deployed to slow him down. His team hopes its not needed. Instead, he plans to deploy his 270-square-foot (25-square-meter) main chute at an altitude of around 5,000 feet (1,524 meters).In order to deploy this chute successfully, he will have to
28、 slow to 172 mph (277 kph). He will have a reserve parachute that will open automatically if he loses consciousness at mach speeds.Even if everything goes as planned, it wont. Baumgartner still will free fall at a speed that would cause you and me to pass out, and no parachute is guaranteed to work
29、higher than 25,000 feet (7,620 meters).It might not be the moon, but Kittinger free fell from 102,800 feet in 1960 - at the dawn of an infamous space race that captured the hearts of many. Baumgartner will attempt to break that record, a feat that boggles the mind. This is one of those monumental moments I will always remember, because there is no way Id miss this.