OPC-2.0.0

所属分类:串口编程
开发工具:C/C++
文件大小:21KB
下载次数:0
上传日期:2021-01-13 14:18:51
上 传 者Lelinh1291
说明:  Arduino library opc ethernet and serial

文件列表:
OPC-2.0.0\examples\EthernetShieldR3\EthernetShieldR3.ino (3521, 2019-05-01)
OPC-2.0.0\examples\EthernetShieldR3Led\EthernetShieldR3Led.ino (1404, 2019-05-01)
OPC-2.0.0\examples\EthernetShieldR3Random\EthernetShieldR3Random.ino (985, 2019-05-01)
OPC-2.0.0\examples\MEGA\MEGA.ino (6921, 2019-05-01)
OPC-2.0.0\examples\UNO\UNO.ino (3742, 2019-05-01)
OPC-2.0.0\examples\UNOBasic\UNOBasic.ino (309, 2019-05-01)
OPC-2.0.0\examples\UNOLed\UNOLed.ino (996, 2018-05-21)
OPC-2.0.0\examples\UNORandom\UNORandom.ino (604, 2019-05-01)
OPC-2.0.0\examples\UNOReadAnalog\UNOReadAnalog.ino (672, 2019-05-01)
OPC-2.0.0\examples\UNOServo\UNOServo.ino (1549, 2018-05-21)
OPC-2.0.0\examples\UNOStore\UNOStore.ino (648, 2019-05-01)
OPC-2.0.0\examples\UNOTypes\UNOTypes.ino (2380, 2019-05-01)
OPC-2.0.0\examples\UNOWriteDigital\UNOWriteDigital.ino (996, 2019-05-01)
OPC-2.0.0\examples\Yun\Yun.ino (3525, 2019-05-01)
OPC-2.0.0\examples\YunBasic\YunBasic.ino (283, 2019-05-01)
OPC-2.0.0\examples\YunLed\YunLed.ino (947, 2019-05-01)
OPC-2.0.0\examples\YunRandom\YunRandom.ino (555, 2019-05-01)
OPC-2.0.0\keywords.txt (0, 2018-05-21)
OPC-2.0.0\library.properties (344, 2019-05-01)
OPC-2.0.0\src\OPC.cpp (19802, 2019-05-01)
OPC-2.0.0\src\OPC.h (2774, 2019-05-01)
OPC-2.0.0 (0, 2019-05-01)
OPC-2.0.0\examples (0, 2019-05-01)
OPC-2.0.0\examples\Yun (0, 2019-05-01)
OPC-2.0.0\examples\UNOReadAnalog (0, 2019-05-01)
OPC-2.0.0\examples\UNOStore (0, 2019-05-01)
OPC-2.0.0\examples\UNOTypes (0, 2019-05-01)
OPC-2.0.0\examples\UNOWriteDigital (0, 2019-05-01)
OPC-2.0.0\examples\EthernetShieldR3 (0, 2019-05-01)
OPC-2.0.0\examples\UNO (0, 2019-05-01)
OPC-2.0.0\examples\UNORandom (0, 2019-05-01)
OPC-2.0.0\examples\UNOServo (0, 2018-05-21)
OPC-2.0.0\examples\EthernetShieldR3Led (0, 2019-05-01)
OPC-2.0.0\examples\UNOBasic (0, 2019-05-01)
OPC-2.0.0\examples\UNOLed (0, 2018-05-21)
OPC-2.0.0\examples\EthernetShieldR3Random (0, 2019-05-01)
OPC-2.0.0\examples\YunLed (0, 2019-05-01)
OPC-2.0.0\examples\YunRandom (0, 2019-05-01)
OPC-2.0.0\examples\MEGA (0, 2019-05-01)
... ...

OPC Library for Arduino ======================= OPC Library is an Arduino library that is used by the OPC Server for Arduino for sharing information but can be used alone. It provide to you with a easy way to interchange information between Arduino and Serial or Ethernet ports (Wifi or Wired) in a unified way. How to use it ------------- First of all you have to have in mind what do you want provide to the external world using Serial, Ethernet or even Wifi. At this moment you can publish your items using serial or http ways (wifi and wired). To do this you have some objects that you can use. Declare ``` OPCSerial aOPC; ``` for serial use or for http use: ``` OPCNet aOPC; ``` Declare your items ------------------ An item can be a real or virtual input/output pin of your Arduino. For example, you would want to publish your analog input A0 to the external world or a virtual value based in some operations made with your Arduino using real pins or calculations. You can declare your item this way: ``` aOPC.addItem("random",opc_read, opc_int, callback); ```` where the first param declares your item name second one tell to the library if is read, read/write or write only item (valid values are opc_read, opc_write, opc_readwrite) third is the type of the item you are declaring (opc_bool, opc_byte, opc_int, opc_float) last is the callback function. The callback will be executed when external client want to read/write a item so you can return or store the desired value. Here you can see a complete example ```` #include /* * Declaring the OPC object */ OPCSerial aOPCSerial; /* * We want to publish analogPin 3 to OPC Client */ int analogPin = 3; /* * create a callback function for the OPCItem */ int callback(const char *itemID, const opcOperation opcOP, const int value){ return analogRead(analogPin); } void setup() { Serial.begin(9600); /* * OPC Object initialization */ aOPCSerial.setup(); /* * A0 OPCItem declaration */ aOPCSerial.addItem("A0",opc_read, opc_int, callback); } void loop() { /* * OPC process commands */ aOPCSerial.processOPCCommands(); } ```` You can upload this code and open a terminal. If you send intro to your Arduino it will return all items declared, if you send the name of declared item you will get the value returned by the callback function. Here you could find more information and a videotutorial about this topic http://www.st4makers.com/arduino-opc-server/installation-guides/easy-testing-of-your-opc-sketch At this moment you can visit the project page at http://www.st4makers.com and download it. Here you can find the libraries and samples sketchs to start learning and get fun.

近期下载者

相关文件


收藏者