Browsed by
Category: How to use

How to implement an Arduino web server

How to implement an Arduino web server

In this blog is showed how to implement an Arduino web server on Arduino based PLC’s. 

The requirement for this example is just an Ardunio based PLC with Ethernet connection as   M-Duino.  

M-Duino require power supply to make work the Ethernet shield and Ethernet wire. 

You must select the IP and Mac direction. In this example are: IP = 192.168.1.219 and Mac = 0xDE, 0xAB, 0xBE, 0x15, 0x00, 0x01.

Read More Read More

How connect Arduino based PLC with Siemens PLC equipped with Ethernet port

How connect Arduino based PLC with Siemens PLC equipped with Ethernet port

On this post it is showed how to connect Industrial Shields Arduino based PLC (M-Duino‘s) with a Siemens PLC equipped with Ethernet port or communication processor. Any PLC is supported except for old S5 family. To do that we have to use Settimino. Settimino is an open source Ethernet library for interfacing Arduino with Siemens S7 PLC’s. CPU’s 1200/1500 LOGO 0BA7 and S7200 are also supported. Download Settimino from the link

Requirements of this example:

  • Arduino based PLC with Ethernet connection: M-Duino‘s 
  • Siemens PLC with Ethernet connection

Once we have all the requirements, we can proceed to explain how it works. The main class is S7Client object that is able to connect and transfer data between Arduino based PLC and Siements PLC. Ethernet W5100 chip support 4 clients and uses a one data buffer for the entire client because just one can be connected at the same time. This data buffer can contain just one PDU (see the Siemens communication to know what that means).

The PDU variable is global, this means that is visible from the sketch. See an example (consult the syntax of the S7Client to get a better understanding).

Read More Read More

How to program Arduino based PLC through Ethernet

How to program Arduino based PLC through Ethernet

This post it shows how to install Ariadne bootloader that allows to programming Arduino based PLC’s of Industrial Shields through Ethernet TFTP Client. Then it is also showed an example of how to program it.

The requirements for this example are:

M-Dunio needs the new Ariadne bootloader to be programmed through Ethernet. How to upload the new bootloader? 

Read More Read More

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

How to connect and configure a load cell using HX711 transmitter with Arduino based PLC

How to connect and configure a load cell using HX711 transmitter with Arduino based PLC

In this post is showed how to use a load cell transductor with our equipment’s for example an Ardbox analog. Load cell is a transductor that generate an electrical signal directly proportional to the measured force.

On market there are different transmitters that can convert this analog signal to digital. In this example is used the HX711 that is very used in industrial applications. HX711 get and convert the analog signal from the load cell to digital with his intern converter A/D of 24 bits.

How to connect the different devices?

Read More Read More

How to generate a different PWM’s signals with Arduino based PLC

How to generate a different PWM’s signals with Arduino based PLC

On this example is explained how to generate a PWM with M-DUINO  and ARDBOX 

In our equipment’s you can generate a PWM on Digital/Analog Ports. But most of these ports have a limitation of frequency (500 Hz approx.). PIN3 for ARDBOX and PIN3 and PIN2 for M-DUINO don’t have limitation and they can generate a PWM between 100Hz (even less) and 8MHz.

PIN3 for ARDBOX can work as an external output for the Timer/Counter0 Output Compare B (OC0B). And the same on M-DUINO: PIN3 can work as an external output for the Timer/Counter3 Output Compare C (OC3C) and PIN2 can work as an external output for the Timer/Counter3 Output Compare B (OC3B).

But how can we set up the frequency needed?

Read More Read More