Browsed by
Category: Software

Software available to use Arduino Based PLC

Tools40 library, useful tool using our equipments

Tools40 library, useful tool using our equipments

This is Industrial Shields library for our different PLC’s 

Tools40 library include SimpleComm library, Filter library and Timer library.

With the SimpleComm library you can send data through any Arduino Stream: RS-485, RS-232, and Ethernet… It is enough flexible to support different kind of communication typologies: Ad-hoc, Master-Slave, Client-Server… Using an easy to use API.

Filter library includes filtering software that allow you to smooth analog inputs. This is really useful when you have an analog signal that is unstable.

With Timer library you can create 3 different timers like Ladder standard Timers:

  • PulseTimer : when there is a rising edge on input value, PulseTimer active Output during the selected time.
  • OnDelayTimer: when Input is active (HIGH) during the defined time, the related Output will be active. Output will be disabled when Input is inactive.
  • OffDelayTimer: As the same of OnDelayTimer, but when Input is inactive (LOW) during the defined time, the related Output will be active. Output will be disabled when Input is active.

Next it is explained how to use Filter library and the Timer library:

First you have to define the Timer or the Filter and give it a name. After that, you just have to create a variable and related with the wanted Input. On Timers the last step is to use this variable to selected Output. Next it is showed an example of how to use it.

Filter library:

#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;

#if defined(ARDBOX_ANALOG)
int pin = I0_1;
#elif defined(ARDBOX_RELAY)
int pin = I0_4;
#elif defined(MDUINO_19R) || defined(MDUINO_38R) || defined(MDUINO_57R)
int pin = I0_2;
#elif defined(MDUINO_21) || defined(MDUINO_42) || defined(MDUINO_58)
int pin = I0_7;
#endif

////////////////////////////////////////////////////////////////////////////////////////////////////
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);
}

 

Timer library:

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);
}

 

How to install Tools40 library to Arduino IDE.

  1. Download the Tools40 library from the GitHub. Click on: “Clone or download”. After that download the zip file on your desktop.
  2. Add the library on the Arduino IDE. Click on: Sketch–>Include library–>Add .ZIP library and choose “arduino-Tools40-master.zip”. After choose the arduino-Tools40-master.zip the library has to be charged. To verify the library is added correctly you can see the library on: //File–>Examples–>Tools40
  3. Now your library is correctly installed and you can see an example to how to use that library on our PLCs.

See also:

SIMPLECOMM LIBRARY

SimpleComm library to send data through any Arduino Stream

SimpleComm library to send data through any Arduino Stream

This is Industrial Shields library for different PLC’s 

With the SimpleComm library you can send data through any Arduino Stream: RS-485, RS-232, Ethernet… It is enough flexible to support different kind of communication typologies: Ad-hoc, Master-Slave, Client-Server… Using an easy to use API. The SimpleCoom library is included on Tools40 library.

Reference:

SimplePacket encapsulates the data into a packet and provides these functions:

setData(data)

Fill up the packet with the desired data to send or the received data from a remote device. It is possible to fill up the packet with different types of data: bool, char, unsigned char, int, unsigned int, long, unsigned long, double, const, const char, const void.

Read More Read More

How to create a web server to read a SD card with our PLC’s

How to create a web server to read a SD card with our PLC’s

This is an example it is explain how to read a SD card into the PLC through Ethernet connection. In this post we will see how create a server that when there is a request through a browser, you can see the directories and the files of the SD card in your browser.

The PLC has to be connected the Ethernet connection and the SD card correctly, check this post how to do it.

Read More Read More

Installing Industrial Shields equipment to the Arduino IDE

Installing Industrial Shields equipment to the Arduino IDE

In order to be able to program our equipment even more easily, it is possible to install to Arduino IDE. Once installed will not be necessary to know witch Arduino board that includes each equipment, neither to consult the mapping between the pins of Arduino board and INs and OUTs of the PLCs, not even will be necessary to use our libraries: now all this information will be included in the Arduino IDE. When you select one of our PLCs, INs and OUTs will be already available with their names, moreover as libraries that will facilitate the use of different communication ports (RS-232, RS-485, …).

Read More Read More

Using the original Arduino IDE

Using the original Arduino IDE

The Industrial Shields PLCs use original Arduino boards. Then the PLCs can be used as individually Arduino boards by The Arduino IDE. To use the original boards let the users to programm the PLCs by others programs which can program Arduino boards too. 

To start using this devices it is necessary:

  • Download the Arduino IDE from www.arduino.org

Arduino Ide let to use these devices as a individually Arduino boards. It is necessary to see the diferent technical details from each product user guide and see the pinout details about the pin configuration because each pin can be configurated as:

Read More Read More

Industrial Shields library in Arduino IDE.

Industrial Shields library in Arduino IDE.

There is two ways to include the Industrial Shields library in the Arduino IDE.

(1) Automatically: USING the Arduino IDE

Open The Arduino IDE.

Click on: Sketch – > Import library…  

Then Search Industrial Shields  on the Library Manager

gestordelibreria

and click on Install

To verify the installation you can go at: 

File -> Examples -> Industrial Shields

industrial_shields_library_link

 

(2) Manually:

How to use the Industrial Shields library in the Arduino IDE: (NOTE: This example also works for any other library you want to charge on the Arduino IDE).

1. Download the original IndustrialShields library from GitHub.

github_industrialshields 

Click on: “Clone or download”

Read More Read More