Browsed by
Category: Panel PC

Panel PC blog information

PLC- HummTouch RS485/RS232

PLC- HummTouch RS485/RS232

In this post we are going to learn how to send data between Industrial Shields PLCs and HummTouch PanelPc. In order to apply or implement the functionalities and examples described, the PanelPC   HummTouch Linxu/Android 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.

HummTouch

The following chart shows the D37 connector  pinout for the  HummTouch (Android and Linux).  

Table 1. HummingBoard/HummTouch pinout  reference

Hummingboard GPIOS HummTouch D37 CONNECTOR pin
195 28
194 27
73 6
72 25
71 7
70 8
67 30
1 4

HummTouch Linux:

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

Table 2. RS232/RS485 pinout

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

 

RS485

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

  1. Open HummTouch console:
  2. User: hb
  3. Pass: hummingboard
  4. Write the following instructions
sudo su                                            //acquire superadmin rights

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

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

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

exit //

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 Steps to configure the 25 PIN as chip/control on HummTouch Linux. With the code and connections above, the RS485 protocol for HummTouch (Linux)  is set-up and configured to transmit state. In order to  test so, the communication between PLC and the PanelPC we are going to send some sentences through RS485 and RS232.

  1.  Open minicom on HummTouch (Linux).
  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 HummTouch console. The Arduino code to read messages on the RS48 Bus is here. Another example shows the  Arduino code to send data to the HummTouch Linux 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.

HummTouch Android

For the Android HummTouch  the conversion between TTL to RS232 and RS485 is carried out with USB-RS232 and USB-RS485 adaptors (cable and software).

  • USB-RS232

This connection is quite simple. First of all, an Android serial terminal   has to be installed in the HummTouch. This can be download from the following link. After that,  the USB-RS232 adaptor can be connected to the PLC and HummTouch.  Now the communication is configured, we just need to  read and write through the RS232 terminal.

  • USB-RS485 (soon to be released)

 Regarding communications with the USB-RS485 adaptor, no pin configurations is required, there is no need to specify the control pin nor its state (transmit, receive). The Arduino code to read and write thorugh  RS485 is the same file as for the RS232. Read and write. As for the I/Os on the HummingBoard, the GPIOS can be configured as input or outputs and its states toggeled: In this link there is an app to emulate a terminal console for Android which needs to be installed. The instructions to be typed on the console to configure the GPIOS are writen below.

su root

echo out>/sys/class/gpio/gpio72/direction // define GPIOS 72 (pin 25 D37) as output

echo 1 >/sys/class/gpio/gpio72/value         // set GPIOS 72  to HIGH  state

echo 0 >/sys/class/gpio/gpio72/value         // set GPIOS 72  to LOW  state

echo in>/sys/class/gpio/gpio72/direction // define GPIOS 72 (pin 25 D37) as input

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.

WORKING WITH GPIO USING HUMMTOUCH 10.1 – ANDROID

WORKING WITH GPIO USING HUMMTOUCH 10.1 – ANDROID

On the link below you can see how work with GPIOs using Android OS with Hummtouch 10.1 Android. http://android.serverbox.ch/?p=972 PanelPc

*ONLY WITH HUMMTOUCH 10.1 ANDROID

You can see I/Os pinout:

External D-Sub 36 female connector Pinout:

GPIO Function GPIO Function GPIO Function GPIO Function GPIO Function
01 3Vdc 09 GND 17 3Vdc 25 GND 33 NC
02 5Vdc 10 RXD0 18 SD3_CLK // SD3_CLK 26 ECSPI2_SS1 // SPI_CE1_N 34 NC
03 I2C3_SDA // SDA1 11 DISP1_DATA00 // GPIO_GEN0 19 ECSPI2_MOSI // SPI_MOSI 27 NC 35 NC
04 5Vdc 12 DISP1_DATA01 // GPIO_GEN1 20 GND 28 NC 36 NC
05 I2C3_SCL//SCL1 13 DISP1_DATA02 // GPIO_GEN2 21 ECSPI2_MISO // SPI_MISO 29 NC 37 NC
06 GND 14 GND 22 DISP1_DATA06 // GPIO_GEN6 30 NC
07 USB_OTG_ID // GPIO_GCLK 15 DISP1_DATA03 // GPIO_GEN3 23 ECSPI2_SCLK // SPI_SCLK 31 NC
08 TXD0 16 SD3_CMD // GPIO_GEN4 24 DISP1_DATA06 // SPI_CE0_N 32 NC

 

I2C Communication

I2C Communication

In order to communicate through I2C, we have to do two type of programs. We have to create some code for the Master device (PLC in our case), and another piece of code for the Slave devices, such as PLC, or any other device (RTC clock, ADC,…, that has an I2C available port).

Master Code:

#include <Wire.h>
void setup()
{
  Wire.begin();

  Serial.begin(9600); 
  delay(500);
}
void loop()
{
  Serial.println("Initial");

  Wire.requestFrom(2, 1);  // request 1 byte from device #2 
  while(Wire.available())  { 
    char c = Wire.read();
    Serial.println(c);
  } 
  delay(100) ;
}

Slave code:

#include <Wire.h>

void setup()
{
  Wire.begin(2);                // join i2c with the device #2
  Wire.onRequest(requestEvent);
}

void loop(){
  delay(100);
}

void requestEvent()
{
  Wire.write("k"); // respond with 1-byte-message
}                       

This is a minimum code to communicate through I2C. In this case we have a Master PLC that asks for a character. The Master asks Slave (#2). When Slave receives the request, respond with one “k” letter. We will see all of them through the RS232 console.

HVAC System activated through an SCADA

HVAC System activated through an SCADA

Introduction

As a continuation of the Air-conditioning system post, in today´s newsletter Opiron suggests to expand the HVAC system controlled through the Touchberry Pi Panel PC and Ardbox Relay from IndustrialShields. As the last post, the suggested SCADA that will run on the Touchberry Pi is the following: myscadatechnologies.com PanelPcSummarizing the previous post, we designed a system that was able to activate the air conditioning with a relay. In order to expand the system, we will include the following sensors to have a complete automatic HVAC system:

  • Inside temperature.
  • Outside temperature.
  • PID development in order to control the inside temperature (the relay will be controlled by the PID loop).

Additionally, the air conditioning system will be integrated into a complete home automation solution where the Scada will give us access to a light system control, open and close windows, and security cameras. Software and code: Inputs and outputs definition

What are inputs and outputs from the coding point of view? As inputs we will consider the inside and outside temperature. As output, the relay that activates the air conditioning that we already programmed in the last post. As mentioned in the last post, the SCADA is owned by myscadatechnologies.com. Its main advantages are that is Open Source based, and very easy to be used. We will use I2C to communicate the SCADA and the Ardbox PLC. The code to be uploaded is the next one: 2014111_arduino_code SCADA design: Control Screen

Once we have already defined PLC programming, it is time to define the screen we will make the interaction between man and machine (HMI). Designing SCADAs really forces us to simplify and decide what’s most important- what needs to stay on the screen. As we want to implement an easy to use temperature control screen, we will show a thermometer with the actual temperature inside, and 4 big windows to see the basic features of the system. The first window with the temperatures inside and outside, at right, the system status window to have an easy access to alarms and other parameters, and below the temperature PID´s,  one for the day and the other one for the night. At the left of the screen we will have a menu to access to the other parts of the system (lighting, temperatures, windows, cameras and service). image12 Key Benefits

The main benefits of the this suggested solution are:

  • Automatic temperature regulation: The relay is now controlled by the PID!
  • Scalable system: The purposed system permits to connect multiple devices to the Touchberry Pi.
  • Open Source based: This feature means big flexibility, big availability of resources on the internet in case of failures or change implementations, etc.
  • Remote control: Control climate conditions through an HMI panel.
Contact us!

Do you have a process to be automated? Contact Industrialshields to buy the proper hardware and Opiron to implement the entire solution.

Controlling temperature with a got exchanger through a modulating valve in chemical industry

Controlling temperature with a got exchanger through a modulating valve in chemical industry

Introduction

In industrial applications, the need to control temperature is usual. A typical element used and designed with this purpose is the hot exchanger, which interchanges two or more fluids with different temperatures.
Ardbox PID loopIn this post we are going to explain how to implement a temperature control through a modulating valve that will regulate the amount of steam that enters the hot exchanger, in order to heat the chemical process. To fulfill the specified requirements, Opiron electronics has developed a PID algorithm which will run on the Ardbox PLC from Industrialshields. Hot Exchanger Logic

Obviously, the main purpose of the aglorithm that we are going to make is a program to control the temperature of the pipe where the chemical process flows.  The element that will give us the chance to regulate the temperature is a modulating valve that has an analog input interface (0 / 10 Vdc) where we are going to send the setpoint from our PLC.

The modulating valve will control the amount of steam that flows to the pipe, and therefore the temperature (the more amount of steam we send, the more temperature there is in the pipe).

To control the temperature, we will use a PID algorithm and a temperature sensor as the input. However, there are other elementary elements to program:

  • valve open / close
  • pump on / off

These will be used from a process safety point of view: basically, if the temperature of the process is out of the limits (>80 ºC).

See below the developed code by Opiron:

2014111_arduino_code

 

// Industrial Shields by BOOT & WORK CORP.
// Powered by Opiron Electronics -www.opiron.com-
// Jan.2015 technical information for newsletter
// This sketch demonstrates how to use a PID with 
// an ARDBOX ANALOG PLC. The sketch is inspired in a
// real project of a chemical plant, where we have to 
// control the temperature of a pipe.
// PID explanation: The purpose of the pid is to 
// control a loop with a temperature sensor and
// a modulating valve. The modulating valve has 
// an analog input where we can send the setpoint
// Keywords: PID, industrial automation, modulating valve
/////////////////////////////////
//// PLC: ARDBOX ANALOG MODULE///
//// Number of Digital inputs: 2  
//// Number of Digital outputs: 3
//// Number of Analog inputs: 1
//// Number of Analog outputs: 1
//// you need to configurate the correctly switch position for running like digital / analog or PWM mode.
//////////////////////////////
//// Ardbox Pins Used:
//// Q0.9 --- PIN 0 --- Digital Output (24Vdc) --- Start / Stop pump
//// Q0.8 --- PIN 1 --- Digital Output (24Vdc) --- Open / Close feeding valve
//// Q0.7 --- PIN 7 --- Digital Output (24Vdc) --- Light alarm indicator
//// I0.3 --- PIN 4 --- Digital Input (24Vdc)  --- Pump runs confirmation 
//// I0.2 --- PIN 8 --- Digital Input (24Vdc)  --- Feed Valve Opened Ok
//// I0.9 --- PIN A0 --- Analog Input (0/10Vdc) --- Feeding Temperature signal
//// Q0.6 --- PIN A3 --- Analog Output (0/10Vdc) --- Setpoint to Modulating Valve

//libraries
#include 

//Pins defintion
#define Pump_Output 0        // Start / Stop pump
#define Valve_Output 1       // Open / Close feeding valve
#define Light  7             // 1 = Red (alarm) / 0 = false (Ok)
#define Pump_Input 4         // Pump Runs Ok
#define Valve_Input 8        // Feed Valve Opened Ok
#define Temperature A0       // Feed Temperature (after PID)
#define ModulatingValve A3   // Setpoint to Modulating Valve

// Other constants
#define HighTemp  80
#define LowTemp  40
#define intervalValve 10000
#define intervalPump 10000
#define intervalTemperature 60000

// Variables
unsigned long Valvetime;            // We use time to check if Valve opens when we have sent an Open Order
double Setpoint, Input, Output;     // PID Values
double kp = 2.5, ki = 30.3, kd = 5.1;         
unsigned long PIDwindowStartTime;   // Use it to compare PID Window Time
unsigned long PumpwindowStartTime;  // Use it to compare Valve Opening time
unsigned long ValvewindowStartTime; // Use it to compare Valve Opening time
unsigned long TemperaturewindowStartTime; // Use it to compare Temperature out of range
boolean valvefail;                  // 0 = Valve OK, 1 = Valve fails
boolean pumpfail;                   // 0 = Pump OK, 1 = Pump fails
boolean tempfail;                   // 0 = Temp OK, 1 = Temp fails

// Objects
PID TemperaturePID(&Input, &Output, &Setpoint,kp,ki,kd, DIRECT);

void setup() 
{ //Configuration is here:

  //Pin settings
  pinMode(Pump_Output, OUTPUT);
  pinMode(Valve_Output,OUTPUT);
  pinMode(Light,OUTPUT);
  pinMode(Pump_Input,INPUT);
  pinMode(Valve_Input,INPUT);

  // turn the PID on
  TemperaturePID.SetMode(AUTOMATIC);
  Setpoint=60;

  // Ini variables
  valvefail=0;
  pumpfail=0;
  tempfail=0;

} // End setup

void loop() {    // The code in loop() runs repeatedly:

if (tempfail)   // Alarms check I: tempfail
{
  digitalWrite(Pump_Output,LOW);
  digitalWrite(Valve_Output,LOW);
  digitalWrite(Light,HIGH);
}

else if (valvefail) // Alarms check II: Valve can't be opened
{
  digitalWrite(Pump_Output,LOW);
  digitalWrite(Valve_Output,LOW);
  digitalWrite(Light,HIGH);
}

else if (pumpfail) // Alarms check II: Pump doesn't start properly
{
  digitalWrite(Pump_Output,LOW);
  digitalWrite(Valve_Output,LOW);
  digitalWrite(Light,HIGH);
}

else 
  {
    digitalWrite(Pump_Output,HIGH);
    digitalWrite(Valve_Output,HIGH);
    digitalWrite(Light,LOW);
    Input = analogRead(Temperature);
    if (Input> HighTemp || Input < LowTemp)     {     if(millis() - TemperaturewindowStartTime>intervalTemperature)  //We count 1 minute             
    { 
      TemperaturewindowStartTime += intervalTemperature;
      tempfail=1;
    }
    }
    else
    {
      tempfail=0;
    }
    TemperaturePID.Compute();
    analogWrite(ModulatingValve, Output);
    if (Pump_Input==0)    //We wait for the Opened confirmation from the valve
    {
    if(millis() - PumpwindowStartTime>intervalPump)  //We count 10s until the Valve is Opened. If the Valve doesn't return the opened confirmation, we send an alarm                
    { 
      PumpwindowStartTime += intervalPump;
      pumpfail=1;
    }
   } // end If Pump_Input
   else if (Pump_Input==1)
   {
    pumpfail=0;  
   } // end Valve_Input==1
    if (Valve_Input==0)    //We wait for the Opened confirmation from the valve
    {
    if(millis() - ValvewindowStartTime>intervalValve)  //We count 10s until the Valve is Opened. If the Valve doesn't return the opened confirmation, we send an alarm                
    { 
      ValvewindowStartTime += intervalValve;
      valvefail=1;
    }
   } // end If Valve_Input
   else if (Valve_Input==1)
   {
    valvefail=0;  
   } // end Valve_Input==1

  } // end else, normal conditions
} // end loop
POWERED BY OPIRON ELECTRONICS