Documentos de Académico
Documentos de Profesional
Documentos de Cultura
RESUMEN
En este artículo se implementará una comunicación de dos potenciómetro por medio del micro-controlador
arduino, empleando el OPC server para lograr la comunicación entre los software arduino y el Excel, con el
KEPserverEX5 se crean los grupos y ítems para la comunicación entre los dos software siguiendo los pasos
correspondientes y en la opción del software de Excel. Se empleó la opción programador en el que se va
hacer una subrutina de lengua Visual Basic en el cual se almacenará los datos en el Excel para así poder
graficarlos.
ABSTRACT
In this article a communication of two potentiometer will be implemented by means of the arduino
microcontroller, using the OPC server to achieve communication between the arduino software and the
Excel, with the KEPserverEX5 the groups and the items are created for the communication between the two
software by following the corresponding steps and in the Excel software option, the programmer option is
used in which a Visual Basic language subroutine will be made in which the data will be stored in the Excel in
order to be able to graph them.
1
1. INTRODUCCIÓN
2. MATERIALES Y METODOS
ArduinoMega
2 Potenciometros
Protoboard
Software Excel
Software arduino Seguidamente de darle click a “Save Configuration”
Software OPC-server nos dirigimos a la carpeta del ArduinoOPCserver
dándole al archivo de “register” ejecutar como
administrador para que nos registre el servidor
A continuación se presentara un breve paso a paso
del procedimiento que se empleó para la
comunicación.
PASO1:
2
Al agregar el nuevo canal agregamos un items” escogiendo la entrada/salida del
nombre adecuado al trabajo arduino a utilizar.
Seleccionamos en “Device driver” la opción
OPC DA client y chulando la opción
“enable diagnostics”.
PASO 4
Le
3
seleccionamos otro nombre al trabajo y el canal de Excel). En la opción de Input
siguiente hasta finalizar. que en este caso es arduino se seleccionan
Ahora en el campo derecho del programa los puertos que vamos a utilizar en la
se da “click” en “add static tag”. comunicación. Se realiza este paso dos
Se proporciona un nombre, y en la casilla veces para comunicar cada uno de los
address le definimos la dirección teniendo potenciómetros.
en cuenta primero el formato, en este caso
el Excel, seguido del número de la hoja
que vamos a utilizar y terminando con el
número de la fila y la columna como se
muestra a continuación en la imagen:
PASO 5:
4
Por último se muestra el resultado final de la Range("B5").Copy Range("J" & contador)
comunicación, en la imagen se observa los datos If contador > 200 Then
recopilados por cada sensor en cada instante de contador = 1
End If
tiempo tiempo y su respectivas curvas.
If segundos > 200 Then
Range("F3", "F11").Value = ""
segundos = 1
End If
Call entretiempo
End Sub
Sub iniciar()
ejecutando = True
4.CONCLUSION Range("B5").Value = 0
contador = 1
segundos = 0
Range("J2", "J201").Value = ""
Range("H2", "H201").Value = ""
3. REFERENCIAS BIBLIOGRÁFICAS Range("F2", "F201").Value = ""
Call entretiempo
End Sub
Sub detener()
ejecutando = False
ANEXO: Application.OnTime tiempo, "registro", , False
End Sub
Programación Excel en lenguaje visual basic
Programación arduino-opc
Dim tiempo As Variant /*
Dim contador As Long * A generic sketch for use with the Arduino OPC or
Dim ejecutando As Boolean Visual OPC Builder from www.st4makers.com
Dim segundos As Long */
#include <OPC.h>
#include <Bridge.h>
#include <Ethernet.h>
Sub entretiempo() #include <SPI.h>
tiempo = Now + TimeValue("00:00:01")
Application.OnTime tiempo, "registro", , True OPCSerial myArduinoMEGA;
End Sub
opcAccessRights digital_status_input[54],
Sub registro() analog_status_input[16];
contador = contador + 1
segundos = segundos + 1 bool readwrite_digital(const char *itemID, const
Range("B1").Copy Range("F" & contador) opcOperation opcOP, const bool value)
Range("B3").Copy Range("H" & contador) {
Range("B5").Value = Range("B5").Value + 1 byte port;
5
OPCItemType aOPCItem =
myArduinoMEGA.getOPCItem(itemID); if (opcOP == opc_opread) {
if ((aOPCItem.opcAccessRight == opc_read) ||
port = atoi(&itemID[1]); (aOPCItem.opcAccessRight == opc_readwrite)) {
digitalWrite(port,value); }
}
} void setup() {
Serial.begin(9600);
if (opcOP == opc_opread) {
if ((aOPCItem.opcAccessRight == opc_read) || myArduinoMEGA.setup();
(aOPCItem.opcAccessRight == opc_readwrite)) {
for (byte k=0;k<54;k++) digital_status_input[k] =
if (digital_status_input[port] != opc_read) { opc_undefined;
pinMode(port, INPUT); for (byte k=0;k<16;k++) analog_status_input[k] =
digital_status_input[port] = opc_read; opc_undefined;
}
myArduinoMEGA.setup();
return digitalRead(port);
} myArduinoMEGA.addItem("D2",opc_readwrite,
} opc_bool, readwrite_digital);
} myArduinoMEGA.addItem("D3",opc_readwrite,
opc_bool, readwrite_digital);
int readwrite_analog(const char *itemID, const myArduinoMEGA.addItem("D4",opc_readwrite,
opcOperation opcOP, const int value) opc_bool, readwrite_digital);
{ myArduinoMEGA.addItem("D5",opc_readwrite,
byte port; opc_bool, readwrite_digital);
myArduinoMEGA.addItem("D5",opc_readwrite,
OPCItemType aOPCItem = opc_bool, readwrite_digital);
myArduinoMEGA.getOPCItem(itemID); myArduinoMEGA.addItem("D6",opc_readwrite,
opc_bool, readwrite_digital);
port = atoi(&itemID[1]); myArduinoMEGA.addItem("D7",opc_readwrite,
opc_bool, readwrite_digital);
if (opcOP == opc_opwrite) { myArduinoMEGA.addItem("D8",opc_readwrite,
if ((aOPCItem.opcAccessRight == opc_write) || opc_bool, readwrite_digital);
(aOPCItem.opcAccessRight == opc_readwrite)) { myArduinoMEGA.addItem("D9",opc_readwrite,
opc_bool, readwrite_digital);
if (analog_status_input[port] != opc_write) { myArduinoMEGA.addItem("D10",opc_readwrite,
pinMode(port, OUTPUT); opc_bool, readwrite_digital);
analog_status_input[port] = opc_write; myArduinoMEGA.addItem("D11",opc_readwrite,
} opc_bool, readwrite_digital);
myArduinoMEGA.addItem("D12",opc_readwrite,
analogWrite(port,value); opc_bool, readwrite_digital);
}
} //builtin led
6
myArduinoMEGA.addItem("D13",opc_write, myArduinoMEGA.addItem("D47",opc_readwrite,
opc_bool, readwrite_digital); opc_bool, readwrite_digital);
myArduinoMEGA.addItem("D48",opc_readwrite,
myArduinoMEGA.addItem("D22",opc_readwrite, opc_bool, readwrite_digital);
opc_bool, readwrite_digital); myArduinoMEGA.addItem("D49",opc_readwrite,
myArduinoMEGA.addItem("D23",opc_readwrite, opc_bool, readwrite_digital);
opc_bool, readwrite_digital); myArduinoMEGA.addItem("D50",opc_readwrite,
myArduinoMEGA.addItem("D24",opc_readwrite, opc_bool, readwrite_digital);
opc_bool, readwrite_digital); myArduinoMEGA.addItem("D51",opc_readwrite,
myArduinoMEGA.addItem("D25",opc_readwrite, opc_bool, readwrite_digital);
opc_bool, readwrite_digital); myArduinoMEGA.addItem("D52",opc_readwrite,
myArduinoMEGA.addItem("D26",opc_readwrite, opc_bool, readwrite_digital);
opc_bool, readwrite_digital); myArduinoMEGA.addItem("D53",opc_readwrite,
myArduinoMEGA.addItem("D27",opc_readwrite, opc_bool, readwrite_digital);
opc_bool, readwrite_digital);
myArduinoMEGA.addItem("D28",opc_readwrite, myArduinoMEGA.addItem("A0",opc_readwrite,
opc_bool, readwrite_digital); opc_int, readwrite_analog);
myArduinoMEGA.addItem("D29",opc_readwrite, myArduinoMEGA.addItem("A1",opc_readwrite,
opc_bool, readwrite_digital); opc_int, readwrite_analog);
myArduinoMEGA.addItem("D30",opc_readwrite, myArduinoMEGA.addItem("A2",opc_readwrite,
opc_bool, readwrite_digital); opc_int, readwrite_analog);
myArduinoMEGA.addItem("D31",opc_readwrite, myArduinoMEGA.addItem("A3",opc_readwrite,
opc_bool, readwrite_digital); opc_int, readwrite_analog);
myArduinoMEGA.addItem("D32",opc_readwrite, myArduinoMEGA.addItem("A4",opc_readwrite,
opc_bool, readwrite_digital); opc_int, readwrite_analog);
myArduinoMEGA.addItem("D33",opc_readwrite, myArduinoMEGA.addItem("A5",opc_readwrite,
opc_bool, readwrite_digital); opc_int, readwrite_analog);
myArduinoMEGA.addItem("D34",opc_readwrite, myArduinoMEGA.addItem("A5",opc_readwrite,
opc_bool, readwrite_digital); opc_int, readwrite_analog);
myArduinoMEGA.addItem("D35",opc_readwrite, myArduinoMEGA.addItem("A6",opc_readwrite,
opc_bool, readwrite_digital); opc_int, readwrite_analog);
myArduinoMEGA.addItem("D36",opc_readwrite, myArduinoMEGA.addItem("A7",opc_readwrite,
opc_bool, readwrite_digital); opc_int, readwrite_analog);
myArduinoMEGA.addItem("D37",opc_readwrite, myArduinoMEGA.addItem("A8",opc_readwrite,
opc_bool, readwrite_digital); opc_int, readwrite_analog);
myArduinoMEGA.addItem("D38",opc_readwrite, myArduinoMEGA.addItem("A9",opc_readwrite,
opc_bool, readwrite_digital); opc_int, readwrite_analog);
myArduinoMEGA.addItem("D39",opc_readwrite, myArduinoMEGA.addItem("A10",opc_readwrite,
opc_bool, readwrite_digital); opc_int, readwrite_analog);
myArduinoMEGA.addItem("D40",opc_readwrite, myArduinoMEGA.addItem("A11",opc_readwrite,
opc_bool, readwrite_digital); opc_int, readwrite_analog);
myArduinoMEGA.addItem("D41",opc_readwrite, myArduinoMEGA.addItem("A12",opc_readwrite,
opc_bool, readwrite_digital); opc_int, readwrite_analog);
myArduinoMEGA.addItem("D42",opc_readwrite, myArduinoMEGA.addItem("A13",opc_readwrite,
opc_bool, readwrite_digital); opc_int, readwrite_analog);
myArduinoMEGA.addItem("D43",opc_readwrite, myArduinoMEGA.addItem("A14",opc_readwrite,
opc_bool, readwrite_digital); opc_int, readwrite_analog);
myArduinoMEGA.addItem("D44",opc_readwrite, myArduinoMEGA.addItem("A15",opc_readwrite,
opc_bool, readwrite_digital); opc_int, readwrite_analog);
myArduinoMEGA.addItem("D45",opc_readwrite, }
opc_bool, readwrite_digital);
myArduinoMEGA.addItem("D46",opc_readwrite, void loop() {
opc_bool, readwrite_digital); myArduinoMEGA.processOPCCommands();
}
7
8