51单片机实现Modbus从机程序0

51单片机实现Modbus从机程序0

ID:47104233

大小:52.50 KB

页数:11页

时间:2019-08-03

51单片机实现Modbus从机程序0_第1页
51单片机实现Modbus从机程序0_第2页
51单片机实现Modbus从机程序0_第3页
51单片机实现Modbus从机程序0_第4页
51单片机实现Modbus从机程序0_第5页
资源描述:

《51单片机实现Modbus从机程序0》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、自己用单片机做的Modbus从机,可以使用STC89C52。实现了命令码为1、2、3、4、5、6的功能,程序中有些是我们部分其他功能的函数和数据,希望大家参考下编程的思想。uintSwitch=0xbc95;//开关状态ucharbdataCoil1=0xff,Coil2=0xbc;//16位线圈状态sbitCoil1_bit0=Coil1^0;sbitCoil1_bit1=Coil1^1;sbitCoil1_bit2=Coil1^2;sbitCoil1_bit3=Coil1^3;sbitCoil1_bit4=Coil1^4;sbitCoil1_bit5=Coil1^5;sbi

2、tCoil1_bit6=Coil1^6;sbitCoil1_bit7=Coil1^7;sbitCoil2_bit8=Coil2^0;sbitCoil2_bit9=Coil2^1;sbitCoil2_bit10=Coil2^2;sbitCoil2_bit11=Coil2^3;sbitCoil2_bit12=Coil2^4;sbitCoil2_bit13=Coil2^5;sbitCoil2_bit14=Coil2^6;sbitCoil2_bit15=Coil2^7;uintidataReOnlybuf[]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x

3、07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};uintidataReWrbuf[]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};//CRC校验查表码值constucharcodeauchCRCHi[]={0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x00,0xC1

4、,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0

5、x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x8

6、1,0x40,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x01,

7、0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x01,0xC0,0x8

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。