极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 24711|回复: 3

arduino PLC通讯库

[复制链接]
发表于 2013-8-10 09:18:44 | 显示全部楼层 |阅读模式
https://code.google.com/p/simple-modbus/


SimpleModbus是一家集Arduino的库,使您能够连续使用的Modicon Modbus RTU协议通信。双方SimpleModbusMaster SimpleModbusSlave实现3和16除了SimpleModbusMaster的功能实现功能1,2,4和15。支持广播是对主功能16和15这两个库。这两个库共享完全相同的API。有所需的功能modbus_update()和modbus_configure()。这两个库已经被广泛的测试,商用设备,如LS工业PLC,施耐德设备,ASCON设备,西门子PLC,SELCO报警面板和各种商业面板米和指标。在除了这SimpleModbusSlave也进行了测试,芒果LS InfoU SCADA系统M2M SCADA,FreeSCADA 2的Modbus投票,免费QModbus的的奴隶测试仪非常方便的Modbus从站测试仪,Mtester(http://www.plcs.net/,下载/的index.php?方向= 0&为了=目录=莫迪康)。

库是非常强大和非阻塞,所有的通信发生的背景,让你的代码运行没有任何延迟执行(也差不多)。的例子和库很好的注释,应该让你快速建立和运行。

库都写面向对象的方法,使用C和不使用C + +对象的构造。这使得它更容易移植到其他平台只支持C编译器。

库PIC18F26K80微控制器上使用Lupic18 C编译器进行了测试,但应该在任何单片机只要你用自己的硬件序列库支持库和编译器。具体有以下功能:

() -要检查,如果事情是接收缓冲
读取() -提取字节的缓冲区
写() -为了发送
开始了原始字节() -初始化串行程序
注意!

实现不完全符合采用Modbus串行线规范。具体框架和字符间定时不完全坚持到Modbus标准,但实现一个简单的方法,同时结合这些延迟和工作确实非常好。

帧和字符的时间可能是modbus的最重要的方面,因为这定义一帧的开始和结束字符间定时。为了正确地做到这一点,你将不得不使用一个定时器中断间字符传输时间,最有可能是您必须实现自己的序列库(或有),由于定时器中断必须清除接收标志串行接收硬件字符缓冲区。这是一个相当密集,在我的脑海里远离KISS主要情诗。

在海洋和工业电子工程的工作在我行,我已经测试库广泛的海洋和工业设备,我碰到过一个平常的日子一天的基础。我没有一次不管理连接到主机或从机由于框架和字符间的时间限制。

库已更新,以支持Arduino的V1.0及更高版本。
回复

使用道具 举报

发表于 2013-8-10 09:45:16 | 显示全部楼层
谷歌翻译????咋看不懂啊
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-8-13 23:03:44 | 显示全部楼层
MODBUS 通讯 软件例子都有
回复 支持 反对

使用道具 举报

发表于 2014-2-22 10:33:23 | 显示全部楼层
SimpleModbus is a collection of Arduino libraries that enables you to communicate serially using the Modicon Modbus RTU protocol. Both SimpleModbusMaster & SimpleModbusSlave implements function 3 and 16 in addition SimpleModbusMaster implements function 1, 2, 4 and 15. Broadcasting is supported on both libraries for function 16 and 15 on the master. Both libraries share the exact same API. There are only two required functions modbus_update() and modbus_configure(). Both libraries have been tested extensively on commercial equipment like LS Industrial PLC's, Schneider equipment, Ascon equipment, Siemens PLC's, Selco alarm panels and various commercial panel meters and indicators. In addition to this SimpleModbusSlave has also been tested on LS InfoU SCADA system, Mango M2M SCADA, FreeSCADA 2, Modbus Poll, the free QModbus slave tester and the very handy modbus slave tester, Mtester

The libraries are very robust and non blocking, all communication takes place in the background allowing your code to run without any delay in execution (well almost). The examples and libraries are well commented and should get you up and running quickly.

The libraries are written with an object orientated approach using C and does not make use of C++ object constructs. This makes it easier to port to other platforms which only supports a C compiler.

The libraries were also tested on a PIC18F26K80 microcontroller using the Lupic18 C compiler but should work on any microcontroller and compiler provided that you support the library with your own hardware serial library. Specifically the following functions:

available() - To check if something is in the receive buffer
read() - To extract the bytes from the buffer
write() - To transmit raw bytes out
begin() - To initialize the serial routine
Note!!

The implementations does not fully comply with the Modbus over serial line specification. Specifically the frame and inter character timing does not exactly adhere to the modbus standard but a simple method is implemented that combines both these delays and works very well indeed.

The frame and character timing is probably the most important aspect of modbus since this defines the start and end of a frame and inter character timing. In order to do this correctly you will have to use a timer interrupt set at the inter character transmission time and most likely you must implement your own serial library (or parts there of) since the timer interrupt must be cleared by the reception flag of the serial receive hardware character buffer. This is quite intensive and in my mind veers away from the KISS principal.

In my line of work in Marine and Industrial electronics engineering I have tested the libraries extensively with marine and industrial equipment I come across on a usual day to day basis. I did not once not manage to connect to a master or slave due to the frame and inter character timing limitations.

The libraries have been updated to support Arduino V1.05 and later versions.

Please check the "Issues" page for a description on updates and various other helpful information.

Check the arduino forum thread for allot of useful information.

Google has stopped the upload of new files. The latest libraries can be obtained here

Feedback is welcomed so I can make the libraries even more robust. Mail me at [email protected]
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-15 07:57 , Processed in 0.055010 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表