ABB SD833(3BSC610066R1)
随着电子技术的飞速发展,单片机也步如一个新的时代,越来越多的功能各异的单片机为我们的设计提供了许多新的方法与思路。对于莫一些场合,比如:复杂的后台运算及通信与高实时性前台控制系统、软件资源消耗大的系统、功能强大的低消耗系统、加密系统等等。如果合理使用多种不同类型的单片机组合设计,可以得到极高灵活性与性能价格比,因此,多种异型单片机系统设计渐渐成为一种新的思路,但单片机之间的通信一直困扰种方法拓展的主要问题。本文将分析比较几种单片机之间的方式、难点,并提出一种解决方案。
1 几种常用单片机之间的通信方式
①采用硬件UART进行异步串行通信。这是一种占用口线少,有效、可靠的通信方式;但遗憾的是许多小型单片机没有硬件 UART,有些也只有1个UART,如果系统还要与上位机通信的话,硬件资源是不够的。这种方法一般用于单片机有应件UART且不需与外界进行串行通信或采用双UART单
片机的场合。
②采用片内SPI接口或2C总线模块串行通信形式。SPI/I2C接口具有硬件简单、软件编程容易等特点,但目前大多数单片机不具备硬件SPI/I2C模块。
③利用软件模拟SPI/I2C模式通信,这种方式很难模拟从机模式,通信双方对每一位要做出响应,通信速率与软件资源的开销会形成一个很大的矛盾,处理不好会导致系统整体性能急剧下降。这种方法只能用于通信量极少的场合。
④口对口并行通信,利用单片机的口线直接相连,加上1~2条握手信号线。这种方式的特点是通信速度快,1次可以传输4位或8位,甚至更多,但需要占用大量的口线,而且数据传递是准同步的。在一个单片机向另一个单片机传送1个字节以后,必须等到另一个单片机的接收响应信号后才能传送下一个数据。一般用于一些硬件口线比较富余的场合。
⑤利用双口RAM作为缓冲器通信。这种方式的最大特点就是通信速度快,两边都可以直接用读写存储器的指令直接操作;但这种方式需要大量的口线,而且双口RAM的价格很高,一般只用于一些对速度有特殊要求的场合。
从上面几种方案来看,各种方法对硬件都有很大的要求与限制,特别是难以在功能简单的单片机上实现,因此寻求一种简单、有效的,能在各种单片机之间通信的方法具有重要的意义。③、④方案中,双方单片机要传递的每一位或每一个字节做出响应,通信数据量较大时会耗费大量的软件资源,这在一些实时性要求高的地方是不允许的。针对这一问题,假设在单片机之间增加1个数据缓冲器,大批数据先写入缓冲区,然后再让对方去取,各个单片机对数据缓冲器都是主控模式,这样必然会大大提高通信效率。谈到数据缓冲,我们马上会想到并行RAM,但是并行RAM需要占用大量的口线(数据线+地址线+读写线+片选线+握手线),一般在16条以上。这是一个让望而生畏的数字,而且会大大增加PCB面积并给布线带来一定的困难,极少有人采用这种方式。串行接口的RAM在市场上很少见,不但难以买到而且价格很高。移位寄存器也可以做数据缓冲器,但目前容量最大的也只128位,因为是“先进先出”结构,所以不管传递数据多少,接收方必须移完整个寄存器,灵活性差而且大容量的移位寄存器也是少见难买的。一种被称为“铁电存储器”芯片的出现,给我们带来了解决方法。
2 利用铁电存储器作为数据缓冲器的通信方式
铁电存储器是美Ramtran公司刚刚推出的一种新型非易失性存储器件,简称FRAM。与普通EEPROM、Flash-ROM相比,它具有不需写入时间、读写次数无限,没有分布结构可以连续写放的优点,因此具有RAM与EEPROM的双得特性,而且价格相对较低。现在大多数的单片机系统配备串行EEPROM(如24CXX、93CXX等)用来存储数。如果用1片FRAM代替原有EEPROM,使它既能存储参数,又能作串行数据通信的缓冲器。2个(或多个)单片机与1片FRAM接成多主-从的I2C总线方式,增加几条握手线,即可得到简单高效的通信硬件电路。在软件方面,只要解决好I2C多主-从的控制冲突与通信协议问题,即可实现简单、高效、可靠的通信了。
3 实例(双单片机结构,多功能低功耗系统)
(1)硬件
W78LE52与EMC78P458组成一个电池供电、可远程通信的工业流量计。78P458采用32.768kHz晶振,工作电流低,不间断工作,实时采集传感器的脉冲及温度、压力等一些模拟量;W78LE52采11.0592MHz晶振,由于它的工作电流较大,采用间断工作,负责流量的非线性校正、参数输入、液晶显示、与上位机通信等功能,它的UART用于远程通信。通信接口部分线路如图1所示,2个单片机共用1片I2C接口的FRAM(FM24CL16)组成二主一从的I2C总线控制方式,W78LE52的P3.5、P3.2分别与78P458的P51、P50连接作握手信号线A与B。我们把握手线A(简称A线)定义为总线控制、指示线,主要用于获取总线控制权与判别总线是否“忙”;握手线B(简称B线)定义为
ABB Procontic模拟的输出模块(07 AA 60 R1)
ABB Procontic模拟输出模块 - 4-20MA(07 AA 61 R1)
ABB Procontic模拟的输出模块(07 AA 62 R1)
ABB Procontic模拟量输出模块(07 AA 63),
ABB Procontic模拟的输出模块(07 AA 65 R1)
ABB Procontic模拟量输出模块(07 AA 80),
ABB Procontic二进制输出模块 - 继电器(07 AB 200)
ABB Procontic数字输出模块(07 AB 60 R1)
ABB Procontic数字输出模块(07 AB 61 R1)
ABB Procontic继电器输出模块(07 AB 67 R1)
ABB Procontic数字输出模块(90 07 AB-S)
ABB Procontic I / O模块(07 AE 83)
ABB Procontic内存模块(07 82)
ABB Procontic空空白插槽外壳(07 BA 60 R1)
ABB Procontic机架6插槽(07 60 R1)
ABB Procontic有10个插槽扩展机架(07 62 R1),
ABB Procontic分散式I / O连接器(07 BR 60 R1)
ABB Procontic分散式I / O连接器(07 BR 61 R1)
ABB Procontic机架(07 BT 60 R1)
ABB Procontic基本模块机架插槽8个I / O(07 BT 62 R1)
ABB Procontic总线耦合器模块(07 BV 60 R1)
ABB Procontic现场总线耦合器模块(07 CS 61)
,ABB Procontic通讯模块(07 DS 85)
ABB Procontic模拟量输入模块(07 EA 200)
ABB Procontic模拟量输入模块(07 EA 60 R1)
ABB Procontic模拟输入模块4-20 MA(07 EA 61 R1)
ABB Procontic模拟量输入模块(07 EA 62 R1)
ABB Procontic模拟量输入模块(07 EA 65 R1)
ABB Procontic模拟量输入模块(07 EA 80)
ABB Procontic模拟输入模块(07 EA 90-S)
ABB Procontic二进制输入模块(EB 07 200)
ABB Procontic数字输入模块(07 EB 61 R1)
ABB Procontic快速的二进制输入模块(07 EB 62 R1)
ABB Procontic数字输入模块(07 EB 90-S)
ABB Procontic中断输入24V DC(07 EI 60)
ABB Procontic Cardfile中(07 ET 83à)
ABB Procontic Cardfile中(07 GS 40 R1)
ABB Procontic通信模块 - T200(07 KP 60 R101)
ABB Procontic通信处理器 - RS232(07 KP 62)
ABB Procontic通信处理器 - RS232 RCOM(07 KP 64),
,ABB Procontic紧凑型控制器(07 KR 228)
ABB Procontic控制器 - 基本配置220 VAC(07 KR 240 R1),
ABB Procontic基本的配置单位(KR 264dR1 07)
ABB Procontic基本的配置单位(07 KT 228)
ABB Procontic基本的配置单元(07 KT 240D R1)
ABB Procontic中央单位 - 30系列(KT 31日07)
ABB Procontic文字处理器模块(07 KT 60 R101)
ABB Procontic RS232通信模块(07 MK 62)
ABB Procontic电源(07 NG 60 R1)
ABB Procontic电源(07 NG 61 R1)
ABB Procontic电源(07 NG 61 R2)
ABB Procontic电源(07 NG 63 R1)
ABB Procontic电源(07 NG 63 R2)
ABB Procontic电源(07 NG 66 R1)
ABB Procontic电源(07 NG 66 R2)
ABB Procontic电源(07 NG 68 R1)
ABB Procontic电源(07 81)
ABB Procontic电源(07 82)
ABB Procontic复合模块(PA 85 07)
ABB Procontic的编程键盘(07 PG 200 R1)
ABB Procontic Procontic K200程序员(07 PG 201)
ABB Procontic编程模块(07 PG 85)
ABB Procontic程序存储器(EPROM模块)(07 PR 62 R1)
ABB Procontic程序存储器(EPROM模块)(07 PR 62 R2)
ABB Procontic程序存储器模块(07 PS 60 R1)
ABB Procontic程序存储器模块(07 PS 61 R1)
ABB Procontic程序存储器模块(07 PS 62 R1)
ABB Procontic程序存储器模块(07 PS 62 R2)
ABB Procontic程序存储器模块(07 PS 62 R3)
ABB Procontic程序存储器模块(07 PS 63 R2)
ABB Procontic程序存储器 - (CMOS-RAM)(07 PS 63 R3)
ABB Procontic复合模块的一部分(07 PS 85)
,ABB Procontic键盘(07 PT 40B)
ABB Procontic定位单元(07 SA 93)
,ABB Procontic线(07 SK 90 R1)
,ABB Procontic连接器电缆(07 SV 60 R1)
ABB Procontic定时器模块(07 TI 80)
ABB Procontic复合模块的一部分(07 TR 85)
ABB Procontic数字输入模块(07 XS 80)
ABB Procontic数字输出模块(YS 07 80)
ABB Procontic二进制输出模块(YS 07 81)
ABB Procontic继电器输出模块(YS 07 86)
ABB Procontic耦合器模块ABB现场总线ZB10(07 ZB 60),
ABB Procontic总线耦合卡(07 ZB 69 R1)
ABB Procontic光纤耦合器(07 ZB 69 R2)
ABB Procontic中央单位(07 ZE 60 R201)
ABB Procontic中央单位(07 ZE 60 R302)
ABB Procontic中央单位(07 ZE 61 R101)
ABB Procontic中央单位(07 ZE 61 R201)
ABB Procontic中央单位(07 ZE 61 R302)
ABB Procontic中央单位(07 ZE 62 R101)
ABB Procontic中央单位(07 ZE 62 R201)
ABB Procontic中央单位(07 ZE 62 R302)
ABB Procontic中央单位(07 ZE 63 R302)
,ABB Procontic CPU模块(07 ZE 82)
ABB Procontic处理器模块(07 ZE 85)
,ABB Procontic处理器模块(07 ZE 88)
ABB Procontic高的速度计数器模块(07 ZG 60 R1)
ABB Procontic B模块(07 ZW 80)
ABB Procontic机架9槽(07BE61R1),
ABB Procontic Cardfile中(07ET40R1)
ABB Procontic乙架(07ET83B)
ABB Procontic,RCOM通信模块(07KP90)
ABB Procontic结构紧凑(07KR220dR1),
ABB Procontic控制器基本配置24V直流(07KR240R2)
ABB Procontic中央处理单元-120吸尘器(07KR31的)
ABB Procontic中央处理器(07KR91)
ABB Procontic中央处理器(07KR91D)
ABB Procontic中央处理器(07KT92)
ABB Procontic中央处理器(07KT93)
ABB Procontic中央处理器(07KT93G)
ABB Procontic中央处理器(07KT94)
ABB Procontic部分复合模块(07PS85的)
ABB Procontic程序员(07PT40)
,ABB Procontic模块(07YS82)
ABB Procontic XE08B5模拟输入Expanison模块(1SBP260106R1001)
ABB Procontic ICMK14F1远程单位(1SBP260502R1001)
ABB Procontic SACE PR120 / B电源连接单元(1SDH000460R0508)
ABB Procontic,ECZ总线模块(ECZ)
ABB Procontic ICSO08Y1输出的单位(FPR3311101R0026)
ABB Procontic ICSO08Y1输出单位(FPR3311101R1022)
ABB Procontic ICSO08R1输出的单位(FPR3312101R0026)
ABB Procontic ICSO08R1输出的单位(FPR3312101R1022)
ABB Procontic I / O远程单位 - 数字输出(FPR3313101R1052),
ABB Procontic ICSI08D1输入的单位(FPR3315101R0014)
ABB Procontic ICSI08D1输入的单位(FPR3315101R0016)
ABB Procontic ICSI16D1输入的单位(FPR3315101R0034)
ABB Procontic ICSI16D1输入的单位(FPR3315101R0036)
ABB Procontic ICSI08D1输入的单位(FPR3315101R1012)
ABB Procontic ICSI16D1 I / O远程单位 - 24 VDC(FPR3315101R1032)
ABB Procontic ICSI08E1输入的单位(FPR3316101R0014)
ABB Procontic ICSI08E1输入的单位(FPR3316101R0016)
ABB Procontic ICSI16E1输入的单位(FPR3316101R0034)
ABB Procontic ICSI08E1输入的单位(FPR3316101R1012)
ABB Procontic ICSI16E1输入的单位(FPR3316101R1032)
ABB Procontic ICSI08E4输入单位 - 230 VAC(FPR3316401R0016)
ABB Procontic ICSC08L1 I / O单元 - 24 VDC(FPR3319101R0082)
ABB Procontic ICSC08L1 I / O单元 - 120吸尘器(FPR3319101R0084的)
ABB Procontic ICSC08L1 I / O单元 - 230吸尘器(FPR3319101R0086的)
ABB Procontic平板的I / O远程单位(FPR3319102R1162)
ABB Procontic ICSF08D1高速计数器(FPR3323101R1012的)
ABB Procontic ICSK20F1 I / O远程单位 - 120VAC(FPR3327101R0204)
ABB Procontic ICSK20F1远程I / O单元(FPR3327101R0206)
ABB Procontic远程I / O单位 - 24 VDC(FPR3327101R1202):
ABB Procontic模拟I / O远程单位(FPR3341501R1042)
ABB Procontic远程模拟量输入模块(FPR3345601R1012)
ABB Procontic ICSE08B5远程模拟单位 - 24 VDC(FPR3346501R1012)
ABB Procontic模拟I / O远程单位(FPR3350601R1062)
ABB Procontic 07 KR 31中央处理。54(FPR3600227R0204)
ABB Procontic 07 KR 31中央处理。54(FPR3600227R0206)
ABB Procontic 07 KR 31中央处理。54(FPR3600227R1202)
ABB Procontic ECZ总线模块(FPR3700001R0001)
ABB Procontic定位单元(GATS110058R0402)
ABB Procontic RS232通信模块(GATS110143R0002)
ABB Procontic 07 ET 40R1 Cardfile的(GJR5210000R1)
ABB Procontic数字量输入模块(GJR5212000R5)
ABB Procontic数字输出模块(GJR5212100)
ABB Procontic电源(GJR5213300R0006)
ABB Procontic电源(GJR5215100R3)
ABB Procontic 07 ZW 80 Procontic B模块(GJR5215300R2)
ABB Procontic继电器输出模块(GJR5215400R2)
ABB Procontic机架(GJR5217500R0002)
ABB Procontic 07 DS 85通信模块(GJR5219300R0001)
ABB Procontic 07 ZE 85处理器模块(GJR5219400R0001)
ABB Procontic部分复合模块(GJR5219500R0001的)
ABB Procontic 85 07 PG编程模块(GJR5219800R0001)
ABB Procontic 07 YS 82模块(GJR52211100R1有)
ABB Procontic二进制输出模块(GJR52221800R1)
ABB Procontic模拟量输出模块(GJR5230010R0001),
ABB Procontic模拟量输入模块(GJR52302)
ABB Procontic处理器模块(GJR5231800R101)
ABB Procontic耦合器模块为现场总线ZB10(GJR5240200R0001),
ABB Procontic 07 CS 61现场总线耦合器模块(GJR5240300R0202)
ABB Procontic 07 KP 62通信处理器 - RS232
(GJR5240400R105)
ABB Procontic通信处理器 - RS232 RCOM(GJR5240600R0101)
ABB Procontic中央处理器(GJR5250000R0101)
ABB Procontic 07 KR 91中央处理单元(GJR5250000R0202)
ABB Procontic中央处理器(GJR5250500R0101)
ABB Procontic中央处理器(GJR5250500R0202)
ABB Procontic中央处理器(GJR5250500R0262)
ABB Procontic 07 AB 90-S数字输出模块(GJR5250800R0101)
ABB Procontic 07 EB 90-S数字输入模块(GJR5250900R0101)
ABB Procontic 07 KP 90 RCOM通讯模块(GJR5251000R0202)
ABB Procontic 07 EA 90-S模拟量输入模块(GJR5251200R0101)
ABB Procontic 07 KT 93中央处理单元(GJR5251300R0101)
ABB Procontic 07 KT 93中央处理单元(GJR5251300R0161)
ABB Procontic 07 KT 93中央处理单元(GJR5251300R0171)
ABB Procontic ICDG 32 L1输入/输出单元(GJR5251400R0101)
ABB Procontic 07 KT 94中央处理单元(GJR5252100R0201)
ABB Procontic数字输出模块(R1 743 60 30 GJV)
ABB Procontic通信模块 - T200(743 6000 R101 GJV 30日)
ABB Procontic数字输出模块(R1 743 61 30 GJV)
ABB Procontic继电器输出模块(GJV 30 743 64 R1)
ABB Procontic 07 BV 60R1总线耦合器模块(R1 743 70 30 GJV)
ABB Procontic 07 KR 228紧凑型控制器(GJV3072401R1)
ABB Procontic 07 KR 240B控制器 - 基础配置220伏
(GJV3072402R1)
ABB Procontic基本的配置单位(GJV3072403R1)
ABB Procontic编程键盘(GJV3072408R1)
ABB Procontic Procontic K200程序员(GJV3072409R1)
ABB Procontic 07 EB 200二进制输入模块(GJV3072411R1)
ABB Procontic 07 AB 200二进制输出模块 - 继电器(GJV3072413R1的)
ABB Procontic 07 KR 220dR1结构紧凑(GJV3072415R1)
ABB Procontic基本的配置单位(GJV3072417R1)
ABB Procontic模拟量输入模块(GJV3072418R1)
ABB Procontic基本的配置单位(GJV3072419R1)
ABB Procontic 07 KR 220 R2结构紧凑(GJV3072428R2)
ABB Procontic模拟量输出模块(GJV30743),
ABB Procontic 07 BT 60R1机架(GJV3074301R1)
ABB Procontic 07 BT 61R1机架(GJV3074302R1)
ABB Procontic 07 62R1 BT基本模块机架8插槽的I / O
(GJV3074303R1)
ABB Procontic机架6插槽(GJV3074304R1)
ABB Procontic机架9槽(GJV3074305R1),
ABB Procontic 07 BE的62R1扩展机架有10个插槽(GJV3074306R1)
ABB Procontic电源(GJV3074310R1)
ABB Procontic电源(GJV3074311R1)
ABB Procontic电源(GJV3074313R1)
ABB Procontic电源(GJV3074313R2)
ABB Procontic电源(GJV3074315R1)
ABB Procontic电源(GJV3074315R2)
ABB Procontic电源(GJV3074317R1)
ABB Procontic中央单位(GJV3074320R201)
ABB Procontic 07 ZE 60中央单位(GJV3074320R302)
ABB Procontic中央单位(GJV3074321R101)
ABB Procontic中央单位(GJV3074321R201)
ABB Procontic中央单位(GJV3074321R302)
ABB Procontic中央单位(GJV3074322R101)
ABB Procontic中央单位(GJV3074322R201)
ABB Procontic中央单位(GJV3074322R302)
ABB Procontic中央单位(GJV3074323R302)
ABB Procontic程序存储器模块(GJV3074330R1)
ABB Procontic程序存储器模块(GJV3074331R1)
ABB Procontic程序存储器模块(GJV3074332R1)
ABB Procontic程序存储器模块(GJV3074332R2)
ABB Procontic程序存储器模块(GJV3074332R3)
ABB Procontic程序存储器模块(GJV3074333R2)
ABB Procontic程序存储器 - (CMOS-RAM)(GJV3074333R3)
ABB Procontic程序存储器(EPROM模块)(GJV3074336R1)
ABB Procontic程序存储器(EPROM模块)(GJV3074336R2)
ABB Procontic 07 EB 61R1数字输入模块(GJV3074341R1)
ABB Procontic快速的二进制输入模块(GJV3074342R1)
ABB Procontic模拟量输入模块(GJV3074350R1)
ABB Procontic 07 EA 61R1模拟输入模块4-20 MA(GJV3074351R1)
ABB Procontic模拟量输入模块(GJV3074352R1)
ABB Procontic高的速度计数器模块(GJV3074356R1)
ABB Procontic中断输入24V DC(GJV3074357R1)
ABB Procontic 07 EA 65R1模拟输入模块(GJV3074359R1)
ABB Procontic模拟量输出模块(GJV3074365R1),
ABB Procontic 07 AA 61R1模拟量输出模块 - -20MA(GJV3074366R1)
ABB Procontic模拟量输出模块(GJV3074368R1),
ABB Procontic分散式I / O连接器(GJV3074375R1)
ABB Procontic分散式I / O连接器(GJV3074376R1)
ABB Procontic总线耦合卡(GJV3074379R1)
ABB Procontic光纤耦合器(GJV3074379R2)
ABB Procontic文字处理器模块(GJV3074381R101)
ABB Procontic空套管空白槽(GJV3074397R1)的,
ABB Procontic输入/输出单元(ICDG32L1)
ABB Procontic平板的I / O远程单位(ICFC16L1)
ABB Procontic远程单位(ICMK14F1)
ABB Procontic模拟I / O远程单位(ICSA04B5)
ABB Procontic I / O单元 - 为120 Vac(ICSC08L1-120)
ABB Procontic I / O单元 - 230 VAC(ICSC08L1-230)
ABB Procontic I / O单元 - 24 VDC(ICSC08L1 24)
ABB Procontic远程模拟量输入模块(ICSE08A6)
ABB Procontic远程模拟单位 - 24 VDC(ICSE08B5-24.)
ABB Procontic高速计数器(ICSF08D1的),
ABB Procontic二进制输入单位(ICSI08D1-120)
ABB Procontic二进制输入单位(ICSI08D1-230)
ABB Procontic二进制输入单位(ICSI08D1-24)
ABB Procontic二进制输入单位(ICSI08E1-120)
ABB Procontic二进制输入单位(ICSI08E1-230)
ABB Procontic二进制输入单位(ICSI08E1-24)
ABB Procontic二进制输入模块 - 120 VAC(ICSI08E3)
ABB Procontic二进制输入单位 - 230 VAC(ICSI08E4-230)
ABB Procontic二进制输入单位(ICSI16D1-120)
ABB Procontic二进制输入单位(ICSI16D1-230)
ABB Procontic I / O远程单位 - 24 VDC(ICSI16D1 24)
ABB Procontic二进制输入单位(ICSI16E1 -120)
ABB Procontic二进制输入单位(ICSI16E1 -24)
ABB Procontic远程I / O单位 - 24 VDC(ICSK20F1):
ABB Procontic I / O远程单位 - 120VAC(ICSK20F1-120)
ABB Procontic I / O远程单位(ICSK20F1-230)
ABB Procontic模拟I / O远程单位(ICSM06A6)
ABB Procontic二进制输出单位230 VAC(ICSO08R1-230)
ABB Procontic输出单位(ICSO08R1-24)
ABB Procontic二进制输入模块 - 24 VDC(ICSO08Y1)
ABB Procontic二进制输出单位230 VAC(ICSO08Y1-230)
ABB Procontic二进制输出单元24 VDC(ICSO08Y1-24)
ABB Procontic I / O远程单位 - 数字输出(ICSO16N1),
ABB Procontic电源连接单元(SACE PR120 / B)
ABB Procontic的模拟输入Expanison模块(XE08B5)