Busca en nuestro Blog. Encontrarás múltiples aplicaciones, soluciones, ejemplos de código. Navega utilizando la nube de etiquetas o busca utilizando criterios específicos
Librería Tools40, útil herramienta para usar nuestros equipos
Introducción
Tools40 es una biblioteca de Industrial Shields® para nuestros diferentes PLC . En esta entrada de blog, se presenta la biblioteca
Tools40 library incluyen la biblioteca SimpleComm, la biblioteca de filtros y la biblioteca de temporizadores.
Requisitos
Ethernet or 20 I/Os PLC: Ethernet PLC 20 I/Os PLC
Tools40 Library: Tools40 Github repository
Uso
Con la biblioteca SimpleComm library puede enviar datos a través de cualquier Arduino Stream: RS-485, RS-232 y Ethernet... Es lo suficientemente flexible para soportar diferentes tipos de tipo de comunicación: Ad-hoc, Master-Slave, Client-Server... Uso de una API fácil de usar.
La biblioteca de filtros incluye software de filtrado que le permite suavizar las entradas analógicas. Esto es realmente útil cuando tiene una señal analógica que es inestable.
Con la biblioteca de Timer puede crear 3 temporizadores diferentes como temporizadores estándar de escalera:
- PulseTimer : cuando hay un borde ascendente en el valor de entrada, PulseTimer active Output durante el tiempo seleccionado.
- OnDelayTimer: cuando Input está activo (HIGH) durante el tiempo definido, la salida relacionada estará activa. La salida se desactivará cuando la entrada esté inactiva.
- OffDelayTimer: Al igual que OnDelayTimer, pero cuando Input está inactivo (LOW) durante el tiempo definido, la salida relacionada estará activa. La salida se desactivará cuando la entrada esté activa.
A continuación se explica cómo utilizar la biblioteca de filtros y la biblioteca del temporizador:
Primero tienes que definir el temporizador o el filtro y darle un nombre. Después de eso, sólo tiene que crear una variable y relacionada con la entrada deseada. En temporizadores, el último paso es utilizar esta variable en la salida seleccionada. A continuación se muestra un ejemplo de cómo usarlo.
Biblioteca de filtros:
#include <Filter.h> // Create a filter // Number of samples: 10 // Sample period: 5ms (setting it to 0, samples are taken as fast as possible) AnalogFilter<10, 5> filter; //////////////////////////////////////////////////////////////////////////////////////////////////// void setup() { // Init Serial port Serial.begin(9600L); // Set pin as INPUT pin pinMode(pin, INPUT); } //////////////////////////////////////////////////////////////////////////////////////////////////// void loop() { // Read pin value int value = analogRead(pin); // Filter it int filtered = filter.update(value); // Print the filtered value Serial.println(filtered); }
Biblioteca del temporizador :
- PulseTimer:
#include <Timer.h> // Define a new OnDelayTimer with preset time of 3s OnDelayTimer timer(3000); int inputPin = I0_0; #if defined(ARDBOX_ANALOG) int outputPin = Q0_0; #elif defined(ARDBOX_RELAY) int outputPin = R3; #elif defined(MDUINO_19R) || defined(MDUINO_38R) || defined(MDUINO_57R) int outputPin = R0_1; #elif defined(MDUINO_21) || defined (MDUINO_42) || defined(MDUINO_58) int outputPin = Q0_0; #endif //////////////////////////////////////////////////////////////////////////////////////////////////// void setup() { // Configure inputPin as input pinMode(inputPin, INPUT); // Configure outputPin as output pinMode(outputPin, OUTPUT); digitalWrite(outputPin, LOW); } //////////////////////////////////////////////////////////////////////////////////////////////////// void loop() { // Read inputPin int input = digitalRead(inputPin); // Update timer using inputPin value and set outputPin associated variable value int output = timer.update(input); // Update outputPin with its associated variable value digitalWrite(outputPin, output); }
- OnDelayTimer:
#include <Timer.h> // Define a new PulseTimer with preset time of 3s PulseTimer timer(3000); int inputPin = I0_0; #if defined(ARDBOX_ANALOG) int outputPin = Q0_0; #elif defined(ARDBOX_RELAY) int outputPin = R3; #elif defined(MDUINO_19R) || defined(MDUINO_38R) || defined(MDUINO_57R) int outputPin = R0_1; #elif defined(MDUINO_21) || defined (MDUINO_42) || defined(MDUINO_58) int outputPin = Q0_0; #endif //////////////////////////////////////////////////////////////////////////////////////////////////// void setup() { // Configure inputPin as input pinMode(inputPin, INPUT); // Configure outputPin as output pinMode(outputPin, OUTPUT); digitalWrite(outputPin, LOW); } //////////////////////////////////////////////////////////////////////////////////////////////////// void loop() { // Read inputPin int input = digitalRead(inputPin); // Update timer using inputPin value and set outputPin associated variable value int output = timer.update(input); // Update outputPin with its associated variable value digitalWrite(outputPin, output); }
Cómo instalar la biblioteca Tools40 en Arduino IDE
- Descargue el Tools40 library desde el GitHub. Haga clic en: "Clonar o descargar". Después de eso, descargue el archivo zip en su escritorio.
- Después de elegir el arduino-Tools40-master.zip la biblioteca tiene que ser cargada. Para verificar que la biblioteca se agrega correctamente se puede ver la biblioteca en://File–>Examples–>Tools40
- Ahora su biblioteca está correctamente instalada y puede ver un ejemplo de cómo utilizar esa biblioteca en nuestros PLC.