Browsed by
Tag: ardbox

Ardbox: Water treatment plant – Control tank level

Ardbox: Water treatment plant – Control tank level

This posts presents an application developed with Industrial Shields Ardbox Relay 7.0. In the facilities of a water treatment plant, retrofitting of the existing automated system was required.

The control system is responsible to maintain the tank level of water within defined limits. The level can be forced to increase/decrease operating  an available outflow pump.

Industrial Shields Ardbox Relay was adopted as the central unit of the control system and it has been running flawlessly for several months, providing a flexible, customizable and pricewise solution.

Some of the components integrating the whole system are:

CapturaWaterTreatmentSystem_03

(1) /(3) Light tower beacon

The main function of the tower beacon is to visually alert if the level alarmis triggered. Code example.

(2) Pump

Some of the  software structures and fucntions required for the operation of the pump are:

Encoder

Timer examples and ISTimer library

Control of stepper motor

Captura2

Contact us at industrialshields@industrialshields.com if you have any questions or  want more information of the application.

Interrupt Inputs Ardbox / MDuino

Interrupt Inputs Ardbox / MDuino

This post shows how to use the interrup inputs that  Industrial Shields PLCs have available. For information and description on what are interrupt inputs and how these work see this link. The interrupt inputs for Industrial Shields PLCs are listed in the pinout section of the datasheet. 

 

In this example the interrupt input I0.0  is used to caught  the pulse of an encoder (for proper connection and wiring  check this post). Every time that interrupt I00 a RISING edge, the ‘encoder’ function will be triggered and count value increased by one unit. The  count value is printed on the serial monitor.

int I00 = 2; // Ardbox Analog I0.0 interrupt input. This pin will vary depending on the interrupt input or the Industrial Shields PLC.
int count=0;

void setup() {
    pinMode(pin, OUTPUT);
    attachInterrupt(digitalPinToInterrupt(I00),encoder, RISING);

Serial.begin(9600);
}

void loop() {
    Serial.println (count);
}

void encoder() {
    count=count+1;
}

The triggering event of the interrupt function can be configured as RISING, FALLING, LOW or CHANGE (see link).

 

Isolated Inputs Ardbox/M-Duino

Isolated Inputs Ardbox/M-Duino

In this post it is described how to use the galvanically isolated inputs in Idustrial Shields PLCs (Ardbox and M-Duino).

As shown in the Figure below, isolated inputs always have two available connections and both of these connections need to be wired for a proper performance of the inputs. The configuration if the inputs is PNP. All isolated inputs are DIGITAL,  not ANALOG.

Isolated inputs

Ix.x    –> Signal. Voltage up to 24V

(-) Ix.x –> reference or COM of the input signal.  

IMPORTANT: BOTH connections are required for the Inputs to work properly.

Ioslated_inputs_v1

The next peice of code shows how to read one isolated input. The example is based on M-Duino Relay, for other PLCs  the pin 2 should be replaced according to the PLC pinout.

int I00 = 2 // modify pin 2 accordingly to PLC pinout;

void setup() {

  pinMode(I00, INPUT);
  
  Serial.begin(9600); 	// Set up serial communication. It will allow to monitor the analog input value.
}

void loop() {

  Serial.println(digitalRead(I00));
  delay(2000); //wait 2 seconds
}
Ardbox – MDuino Arduino pin

Ardbox – MDuino Arduino pin

This post describes how to gain direct access to Arduino board pins  inside the  Ardbox and MDuino PLCs. This allows to work with the PLCs in the same way as using an Arduino, in other words,  pins at 5V and configurable as input or outpts.

Also, this  enables usage of  sensors  working at lower voltages than industrial standards 10V dc/24Vdc.  NOTE:Make sure the voltage DOES NOT EXCEED 5VDC!!!!!!!!

Following are listed the connections with direct access to the Arduino board  pins.

Ardbox: DE-D7  // RE-D4 // SDA-PIN2  // SCL-PIN3

MDuino: SCL // SDA // RX0 // TX0 // RX1 // TX1 // Pin3 // Pin2

In order to enable the direct connection to Arduino pins, the configuration switches for these connections must be set to OFF position.

PLC- Touchberry PI RS485/RS232

PLC- Touchberry PI RS485/RS232

In this post we are going to learn how to send data between Industrial Shields PLCs and TouchBerry PI PanelPc. In order to apply or implement the functionalities and examples described, the TouchBerry PI is assumed to include the suitable preloaded image. All PanelPC acquired as of 21-08-2015 will include the required image. For those PanelPC  acquired before 21-08-2015 the procedure to install the new compatible image will be provided via email.

Touchberry  PI

Touchberry PI supports TTL (5V-0V) serial communication through the D37 connector. MAX485 and  MAX232 components are required to adapt to RS232/RS485 protocols.

Table 1.

Pin D37 Function Protocol
22 GND RS2323/485
23 TX RS2323/485
34 RX RS2323/485
Any GPIOS (for the example 25) Control/chip Rs485

Table 2. Raspberry PI 2B  GPIOS –> ToucBerry PI D37 Connctor

GPIOS D37 CONNECTOR pin
24 28
23 27
17 6
18 25
27 7
22 8
25 30
14 4

RS485

Industrial Shields PLCs provide the A B connection for RS485 protocol. Raspberry PI 2B requires to configure the control/chip pin (any GPIOS) to connect to the MAX485 component. For this example we take pin 25 from the TouchBerry PI D37 connector (GPIOS 18)  as chip/control pin. Steps to configure the 25 PIN as chip/control on Raspberry Pi.

  1. Open Touchberry PI console:
  2. User:pi
  3. Pass:raspberry
  4.  Write the following instructions
sudo su                                            //acquire superadmin rights

echo “18” >/sys/class/gpio/export

echo out>/sys/class/gpio/gpio18/direction // define GPIOS18 (pin 25 D37) as control/chip

echo 1 >/sys/class/gpio/gpio18/value         // set control/chip pin to transmit state (HIGH) 1

exit //

With the code above the Raspberry PI RS485  protocol is set-up and configured to transmit state.

Table 3. Touchberry PI to MAX485 connection reference

D37 connector   MAX485
22 (GND) –> RE
23 (TX) –> DI
24  (RX) –> RO
25  (CS) –> DE

*TX and RX cables connection is not cross between D37 to MAX485 Now to test that the communication between PLC and Rasberrry PI is enabled we are going to send some sentences through RS485 and RS232.

  1. Open minicom on Touchberry PI.
  2. Type the following:
 sudo minicom -D /dev/ttyAMA0 -b 4800

Any code written on the console should be send  through RS485 to the PLC. With the Serial Monitor on the PLC we  can see the code typed on the Touchberry PI console. The Arduino code to read messages on the RS48 Bus is here. Another example shows the  Arduino code to send data to the Touchberry PI through the RS485 bus.

RS232

For RS232 there is no control pin, compared to RS485, so  no configuration instructions are required.  To connect the PanelPC to the  MAX232 the pins 22 (GND), 23 (TX), 24 (RX) (Table 4) are to be linked to to the  MAX232 pins GND, TX, RX Table.4

D37 connector   MAX232
22 (GND) –> GND
23(TX) –> TX
24(RX) –> RX

*TX and RX cables connection is not cross between D37 to MAX232.

Write Relay Outputs Ardbox/MDuino Relay

Write Relay Outputs Ardbox/MDuino Relay

Ardbox Relay relay outputs (220V / 5A): 

  • R1, R2, R3, R4, R5, R6, R7, R8

MDuino Relay relay outputs (220V/ 8A):

  • R0.1, R0.2, R0.3, R0.4, R0.5, R0.6, R0.7 (MDuino 19R)
  • R0.1, R0.2, R0.3, R0.4, R0.5, R0.6, R0.7, R0.8,  R1.1, R1.2, R1.3, R1.4, R1.5, R1.6, R1.7, R1.8 (Mduino 38R)
  • R0.1, R0.2, R0.3, R0.4, R0.5, R0.6, R0.7, R0.8,  R1.1, R1.2, R1.3, R1.4, R1.5, R1.6, R1.7, R1.8, R2.1, R2.2, R2.3, R2.4, R2.5 (NC), R2.6, R2.7, R2.8 (Mduino 57R)

 

In this post we are going to learn how to define the state of the relay outputs. In this example relay output R1 (Ardbox Relay)  is switched ON (switch closed) and switched OFF (switch opened).

relay_schematic

 

int R1 = 4;   

void setup() {   
pinMode(R1, OUTPUT);   

}   
void loop() { 
  
digitalWrite(R1,HIGH); // close the relay switch
delay(500);  // wait 500ms
digitalWrite(R1,LOW); // opens the relay switch
delay(500);
 }

The digital outputs pinout can be checked on the User Guides for each PLC. Otherwise,  Arduino IDE start files contain all I/O already declared and with the suitable pinMode defined. To reproduce the same code for the other outputs the pin number should be replaced by the corresponding Arduino pin matching the new Output.
i.e. (Ardbox Analog):

int R2 = 7;

void setup(){
pinMode(R2, OUTPUT);

}

 

Write Digital Outputs Ardbox/MDuino

Write Digital Outputs Ardbox/MDuino

Digital  Ouputs (0-24Vdc): Ardbox

  • Analog: Q0.0, Q0.1, Q0.2 (Digital); Q0.3, Q0.4, Q0.5, Q0.6, Q0.7, Q0.8, Q0.9 (configurable Digital)
  • Relay:  –

M-Duino

  • M-Duino 21: Q0.0, Q0.1, Q0.2, Q0.3, Q0.4 (Digital); Q0.5, Q0.6  Q0.7  (configurable Digital).
  • M-Duino 42:  Q0.0, Q0.1, Q0.2, Q0.3, Q0.4, Q1.0, Q1.1, Q1.2, Q1.3, Q1.4 (Digital); Q0.5, Q0.6  Q0.7, Q1.5, Q1.6  Q1.7 (configurable Digital).
  • M-Duino 58: Q0.0, Q0.1, Q0.2, Q0.3, Q0.4, Q1.0, Q1.1, Q1.2, Q1.3, Q1.4, Q2.0, Q2.1, Q2.2, Q2.3, Q2.4(NC) (Digital); Q0.5, Q0.6  Q0.7, Q1.5, Q1.6  Q1.7, Q2.5, Q2.6  Q2.7 (NC) (configurable Digital).
  • M-Duino 19R: Q0.0, Q0.1, Q0.2 (configurable Digital).
  • M-Duino 38R: Q0.0, Q0.1, Q0.2, Q1.0, Q1.1, Q1.2 (configurable Digital).
  • M-Duino 57R: Q0.0, Q0.1, Q0.2, Q1.0, Q1.1, Q1.2, Q2.0 (NC), Q2.1, Q2.2 (configurable Digital).

In this post we are going to learn how to define the state of the digital outputs. In this example digital output Q0.0 (Ardbox Analog) is set to HIGH state and after some time again to LOW state. When  Q0.0 is HIGH the Q0.0 PLC  connection will  provide 24Vdc, conversly when Q0.0 is set to LOW Q0.0 PLC connection will provide 0V.   This code could be used to make a LED blink.  The same code could be reproduced for any other digital output.

int Q00 = 13;

void setup() {

pinMode(Q00, OUTPUT);
}

void loop() {

digitalWrite(Q00,HIGH); // output Q00 set to HIGH state (on).
delay(500);             // wait 500 ms
digitalWrite(Q00,LOW);  // output Q00 set to LOW state (off).
delay(500);             // wait 500ms
}

The digital outputs pinout can be checked on the User Guides for each PLC. Otherwise,  Arduino IDE start files contain all I/O already declared and with the suitable pinMode defined. To reproduce the same code for the other outputs the pin number should be replaced by the corresponding Arduino pin matching the new Output. i.e. (Ardbox Analog):

int Q01 = 11;   
void setup(){ 

pinMode(Q01, OUTPUT);   
}
Read Digital Inputs Ardbox/MDuino

Read Digital Inputs Ardbox/MDuino

Digital  Inputs (0-24Vdc):

Ardbox

  • Analog: I0.0 (Digital); I0.1, I0.2, I0.3, I0.4, I0.5, I0.6, I0.7, I0.8, I0.9 (configurable Digital).
  • Relay:  I0.0, I0.1, I0.2, I0.3, I0.4 (Digital); I0.5, I0.6, I0.7, I0.8, I0.9 (configurable Digital).

M-Duino

  • M-Duino 21: I0.0, I0.1, I0.2, I0.3, I0.4, I0.5, I0.6 (Digital); I0.7, I0.8, I0.9, I0.10, I0.11, I0.12 (configurable Digital).
  • M-Duino 42:  I0.0, I0.1, I0.2, I0.3, I0.4, I0.5, I0.6, I1.0, I1.1, I1.2, I1.3, I1.4, I1.5, I1.6 (Digital); I0.7, I0.8, I0.9, I0.10, I0.11, I0.12, I1.7, I1.8, I1.9, I1.10, I1.11, I1.12  (configurable Digital).
  • M-Duino 58: I0.0, I0.1, I0.2, I0.3, I0.4, I0.5, I0.6, I1.0, I1.1, I1.2, I1.3, I1.4, I1.5, I1.6, I2.0, I121, I2.2, I2.3, I12.4 (NC), I2.5, I2.6  (Digital); I0.7, I0.8, I0.9, I0.10, I0.11, I0.12, I1.7, I1.8, I1.9, I1.10, I1.11, I1.12, I2.7, I2.8, I2.9, I2.10, I2.11 (NC), I2.12 (NC)  (configurable Digital).
  • M-Duino 19R: I0.0, I0.1 (Digital); I0.2, I0.3, I0.4, I0.5 (configurable Digital).
  • M-Duino 38R: I0.0, I0.1 , I1.0, I1.1 (Digital); I0.2, I0.3, I0.4, I0.5 , I1.2, I1.3, I1.4, I1.5 (configurable Digital).
  • M-Duino 57R: I0.0, I0.1 , I1.0, I1.1, I2.0, I2.1 (Digital); I0.2, I0.3, I0.4, I0.5 , I1.2, I1.3, I1.4, I1.5, I2.2, I2.3, I2.4, I2.5 (configurable Digital).

In this post we are going to learn how to read digital inputs. The example shows how to obtain the  value for the digital input I0.0 (Ardbox Analog)  and print it  on the serial monitor every 2 seconds.

int I00 = 2;
int value_I00;
void setup() {

  pinMode(I00, INPUT);
  
  Serial.begin(9600); 	// Set up serial communication. It will allow to monitor the analog input value.
}

void loop() {

  value_I01 = digitalRead(I00);
  Serial.println(value_I00);   //print value on serial Monitor
  delay(2000); //wait 2 seconds
}

Digital inpus operate at 0 or 24Vdc. The read value digitalRead() will be 0  for 0Vcd signal or 1 for ~ 24Vdc signal. In order to monitor the digital input values the Serial Monitor is used.  It can be appreciated that the read value is either 0 or 1, depending  on the attached sensor state. In the event of no sensor attached, the value will be constant to 0.

AB_Analogread_serial_monitor     AB_digread_serial_monitor

The digital outputs pinout can be checked on the User Guides for each PLC. Otherwise,  Arduino IDE start files contain all I/O already declared and with the suitable pinMode defined. To reproduce the same code for the other inputs the pin number should be replaced by the pin matching the new digital input . i.e. (for Ardbox Analog):

int I01 = 12;

void setup(){
pinMode(I01, INPUT);

}
Read Analog Input Ardbox/MDuino

Read Analog Input Ardbox/MDuino

Analog  Inputs (0-10V / 10  bits):

Ardbox

  • Analog: I0.1, I0.2, I0.3, I0.4, I0.5, I0.6, I0.7, I0.8, I0.9 (configurable Analog).
  • Relay: I0.4, I0.5, I0.6, I0.7, I0.8, I0.9 (configurable Analog).

MDuino

  • M-Duino 21:  I0.7, I0.8, I0.9, I0.10, I0.11, I0.12 (configurable Analog).
  • M-Duino 42:  I0.7, I0.8, I0.9, I0.10, I0.11, I0.12, I1.7, I1.8, I1.9, I1.10, I1.11, I1.12  (configurable Analog).
  • M-Duino 58: I0.7, I0.8, I0.9, I0.10, I0.11, I0.12, I1.7, I1.8, I1.9, I1.10, I1.11, I1.12, I2.7, I2.8, I2.9, I2.10, I2.11 (NC), I2.12 (NC)  (configurable Analog).
  • M-Duino 19R: I0.2, I0.3, I0.4, I0.5 (configurable Analog).
  • M-Duino 38R: I0.2, I0.3, I0.4, I0.5 , I1.2, I1.3, I1.4, I1.5 (configurable Analog).
  • M-Duino 57R:  I0.2, I0.3, I0.4, I0.5 , I1.2, I1.3, I1.4, I1.5, I2.2, I2.3, I2.4, I2.5 (configurable Analog).

In this post we are going to learn how to read analog inputs. The example shows how to obtain the  value for analog input I0.1 (ardbox Analog)  and print it  on the serial monitor every 2 seconds.

int I01 = 12;
int value_I01;
void setup() {

  pinMode(I01, INPUT);
  
  Serial.begin(9600); 	// Set up serial communication. It will allow to monitor the analog input value.
}

void loop() {

  value_I01 = analogRead(I01);
  Serial.println(value_I01);
  delay(2000); //wait 2 seconds
}

The values for the analog inputs (10 bits)  range is 0 – 1023 (see graph below).  If the value of sensor is (3V), the analogRead value is 3*1023/10 = 307.

AB_analogread

In order to monitor the analog Input values the Serial Monitor is used.  It can be appreciated that the read value is a random number, this is because the input connector is floating since there is no sensor attached. To prove that we can ground I0.1 iput (connect it to GND)  and it should show a value close to zero.

AB_Analogread_serial_monitorAB_Analogread_serial_monitor

The digital outputs pinout can be checked on the User Guides for each PLC. Otherwise,  Arduino IDE start files contain all I/O already declared and with the suitable pinMode defined. To reproduce the same code for the other outputs the pin number should be replaced by the corresponding Arduino pin matching the new Output.
i.e. (Ardbox Relay):

int I02 = 8;

void setup(){
pinMode(I02, INPUT);

}
Write Analog Outputs Ardbox/MDuino

Write Analog Outputs Ardbox/MDuino

Analog Outputs (0-10Vdc / 8 bits): 

Ardbox

  • Analog: Q0.3, Q0.4, Q0.5, Q0.6, Q0.7, Q0.8, Q0.9 (configurable Analog)
  • Relay:  Q0.0, Q0.1 (Analog).

M-Duino

  • M-Duino 21: Q0.5, Q0.6  Q0.7  (configurable Analog).
  • M-Duino 42: Q0.5, Q0.6  Q0.7, Q1.5, Q1.6  Q1.7 (configurable Analog).
  • M-Duino 58: Q0.5, Q0.6  Q0.7, Q1.5, Q1.6  Q1.7, Q2.5, Q2.6  Q2.7 (NC) (configurable Analog).
  • M-Duino 19R: Q0.0, Q0.1, Q0.2 (configurable Analog).
  • M-Duino 38R: Q0.0, Q0.1, Q0.2, Q1.0, Q1.1, Q1.2 (configurable Analog).
  • M-Duino 57R: Q0.0, Q0.1, Q0.2, Q1.0, Q1.1, Q1.2, Q2.0 (NC), Q2.1, Q2.2 (configurable Analog).

In this post we are going to learn how to define the state of the anlog outputs. In this example analog output Q0.3 (Ardbox Analog)  is set to different voltage values within its operation range 0-10V.

int Q03 = 9;   

void setup() {   
pinMode(Q03, OUTPUT);   

}   
void loop() { 
  
analogWrite(Q03,25); 
delay(500);  // wait 500ms 
analogWrite(Q03,75); 
delay(500); // wait 500ms 
analogWrite(Q03,125); 
delay(500); // wait 500ms 
analogWrite(Q03,175); 
delay(500); // wait 500ms 
analogWrite(Q03,225); 
delay(500); // wait 500ms 
analogWrite(Q03,250); 
delay(500); // wait 500ms   
}

As seen on the code, the analogWrite command  requires two inputs; the output reference (Q03) and the output value.   The Analog Output range is 0-10V 8 bits, so the  output values range on Arduino IDE is 0-255. i.e.:  for a 5V output the analogWrite value is   5*255/10 ≈127

AB_analogWrite

The digital outputs pinout can be checked on the User Guides for each PLC. Otherwise,  Arduino IDE start files contain all I/O already declared and with the suitable pinMode defined. To reproduce the same code for the other outputs the pin number should be replaced by the corresponding Arduino pin matching the new Output.
i.e. (Ardbox Analog):

int Q01 = 11;

void setup(){
pinMode(Q01, OUTPUT);

}