第一范文网 - 专业文章范例文档资料分享平台

单片机多机通信实现

来源:用户分享 时间:2025/6/26 15:27:23 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

单片机多机通信实现

摘要:目前,单片机在多机通信领域应用很广。但研究最多的是上位机与下位

机的通信及多单片机构成的主从式多机通信系统。本文重点研究了多单片机的平权式多机通信,使各单片机有相同的权限。

本文从平权式多机通信协议入手,首先设计了具体平权式多机通信协议;主机通信用按键控制,模拟实际应用中的触发信号输入。对于1号单片机,还可通过液晶实时显示工作状态,初始为主机。在不需置其他单片机为主机的情形下,本多机通信系统可以作为主从式多机通信系统。从机通信模式通过串口中断触发启动,通信结束即恢复之前的从机状态。通信过程中,主机先发送寻址的从机号,待从机响应后开始通信。通信结束后,主机发送自己的主机号,告知从机。然后从机发给主机校验字节数据,主机检验错误,检验无误后,作出响应,1号单片机液晶会显示,2号和3号单片机收发数据无误后会使LED指示灯亮起。其外,本文研究了可切换双向接口的实现方法。通过用单片机的一个引脚控制单片机的串口的连接方式,使其工作在主机模式或从机模式。

本研究已经仿真通过,真实可行。具有一定的检错能力,串行通信的比特率是9600bit/s,通信速度较快,且可靠性高。本研究通过硬件电路解决了通信过程中多单片机争用主机权的问题。

关键词:单片机;多机通信;平权;AT89S52

Realization of many SCM communication

Abstract:At present, the single chip multi-machine communication in a wide field

of applications. However, the most studied is the host computer and lower computer communications and multi-chip microprocessor master-slave multi-machine communication system. This paper focuses on a number of single chip multi-machine communication affirmative, so that the MCU has the same permissions.

The paper machine from the multi-level communication protocol of the right to start with, first, the specific communication protocol. Host Communication button control, the practical application of simulation in the trigger signal input. For the No. 1 microcontroller, but also through the LCD display working status, the initial for the host. No other single chip set in the case of the host, the multi-machine communication system can be used as master-slave multi-machine communication system. Communication mode from the machine through the serial port interrupt triggering, communication before the end of the recovery from the machine state. Communication process, the host sends the address number from the machine until the response from the plane after communications. After communication, the host sends its own host number, informed from the machines. And then distributed to the host from the machine check bytes of data, the host test error, test and proved correct response, 1 single chip LCD displays, 2 and 3, after the MCU will send and receive data correct LED light is on. Besides, this paper, bi-directional switch implementation of the interface methods. Through the use of microcomputer control of a

I

microcontroller pin serial port connection, to work in master mode or slave mode.

This study has been simulated by the real feasible. Have some error detection capability, the bit rate of serial communication 9600bit / s, communication speed, and reliability. In this study, the hardware circuit through the communication process to resolve the contention over the host microcontroller over the issue.

Key words::SCM;Multi-machine communication;Equal rights; AT89S52

目录

1 绪论....................................................................... 1 1.1 论文研究的背景与意义 ..................................................... 1 1.2 单片机多机通信领域的历史及国内外发展现状 ................................. 1 1.3 本论文的研究内容 ......................................................... 2 2 单片机多机通信理论及方案选择 ............................................... 3 2.1 单片机串口通信 ........................................................... 3 2.2 单片机多机通信方案选择 ................................................... 5 2.3 微处理器的选择 ........................................................... 5 2.4 液晶LCD1602介绍 ......................................................... 9 3 单片机多机通信协议设计 .................................................... 15 4 硬件电路设计 .............................................................. 16 4.1 单片机最小系统的设计 .................................................... 16 4.2 矩阵键盘电路设计 ........................................................ 17 4.3 液晶显示电路设计 ........................................................ 18 4.4 可切换接口电路设计 ...................................................... 19 4.5 2号与3号单片机按键电路设计 ........................................... 23 4.6 LED显示电路设计 ....................................................... 23 4.7 主机权分配电路设计 ..................................................... 24 4.8 电源电路设计 ........................................................... 28 5 软件设计 .................................................................. 29 5.1 多机通信协议的算法设计 ................................................. 29 5.2 键盘程序设计 ........................................................... 32 5.3 系统初始化程序设计 ..................................................... 35 6 结论...................................................................... 35 参考文献 .................................................................... 36 致谢........................................................................ 37

II

附录1:1号单片机电路原理图 ................................................. 38 附录2:2号单片机电路原理图 ................................................. 39 附录3:3号单片机电路原理图 ................................. 错误!未定义书签。 附录4:仿真电路图 .......................................................... 42 附录5:源程序: ............................................................ 43

I

搜索更多关于: 单片机多机通信实现 的文档
单片机多机通信实现.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c49qri9w8eh423gi8flz4_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top