1 The Low Cost Embedded Control of the Industrial Hydraulic Pulse System Based on PLC and State Machine Design Juraj Pancik Department of Informatics and Quantitative Methods Bankovní institut vysoká škola, a.s. Prague, Czech Republic jpancik@bivs.cz Abstract – In the paper we describe the control electronics for the industrial test system based on the low cost PLC. Developed system was hydraulic pulse system and it generates series of high pressure hydraulic pulses (max. 200bar) and is based on the pneumatichydraulic circuits. We describe the requirements, the overall concept of the embedded control system, user interface, security features and network connectivity. In the description of the software solution we describe implemented hierarchical ordered program threads (multithreaded program) and main control state machine. At the conclusion, we describe the calibration method of the system and calibration curves, we present the schematic diagram and a photo of the functional prototype of the system. PLC programming, hydraulic pulse system, state machine, multithreaded program, ladder logic diagram I. INTRODUCTION Our embedded control system for the hydraulic pulse system is based on the use of modern, low cost programmable controller (PLC). The PLC allows to programming of the number of concurrently running separate programs (threads), which are represented as well-known ladder logic or flowchart diagrams. Each thread in our case implements specific activity (or task) and the individual threads cooperate with each other so that as the result they create the reactive main control state machine. II. REQUIREMENTS FOR CONTROL OF THE HYDRAULIC PULSE SYSTEM. HYDRAULIC PULSE TRAIN Our task was to create an embedded system for controlling of generation series of hydraulic pulses. Number of series pulses with particular parameters is up to four of which each series has an adjustable number of pulses (N), the maximum hydraulic pressure (p), hydraulic pulse duration (T1) and the duration of the pause (T0). Each series can be described as the wagons of the train with passengers (each WAGON has four ones: N, p, T1, T2, see Figure 1, wherein WAGONs build so called "hydraulic pulse train". Hydraulic pulse train can cyclically repeating its orbit circle by set number of times (TRAIN SESSION). The number of WAGONs can range from 1 to 4. Embedded control system shall allow to the user set the output hydraulic pressure in bar, set parameters of wagons, the number of wagons and sessions of train. It must allow systems calibration (the dependence of the output hydraulic pressure to the user's desired input hydraulic pressure) and it must ensure the generation of system and error messages. III. HARDWARE SOLUTION A. Pneumatic - hydraulic parts This section describes the diagram in Figure 4 and the photo on Figure 6 below. Input air pressure is regulated by the proportional pneumatic valve. Regulated air is then fed into pneumatic four - way valve circuit and it controls the two – position pneumatic pump. This pneumatic circuit controls the two-direction movement of the hydraulic cylinder with resulting amplified hydraulic pressure at its output. B. Embedded control system This section is described by the scheme in Figure 4. It was realized on the programmable logic controller (PLC) [1] and certain additional modules (analog input - output, user interface LCD display and keypad, USB, RS232 and Ethernet). Input and output logic of the digital signal has levels 0 and 24V, analog outputs are in the range 0-10V, and analog inputs are in the range 0-5V. The used PLC is built on the basis ARM 32 processor and its operating system offers running of several independent program threads simultaneously. The run of each thread is conditional on any particular value, e.g. by the value of the hardware input signal or by program controlled value of the internal program flag. So parallel programming in the PLC is based on the running separated threads, which can be also identified with the parallel implementation of separate running of independent (for PLC user familiar as) ladder logic or flowchart diagrams. C. User interface elements The user interface consists from keypad, LCD display (4 rows x 20 characters), the manual switch between two basic modes of equipment (MANUAL mode and AUTO mode), the potentiometer for manual adjustment of output hydraulic pressure, the button to start of series hydraulic pulsation (PULSE mode), button to stop of pulses (the RESET button), security (or emergency) button to turn off the power of the appliance (EMERGENCY). The required values for WAGON and TRAIN parameters and the choosing of other equipment modes (e.g. calibration of the system) are entered from the in PLC build keypad. D. Electrical parts of system Electrical parts of our system are formed by a 24V power supplies, safety relay, electrical and optical 2 relays, switches, terminals and wires and it well be seen in Figure 4 below. E. Safety features The basis of ensuring the safety operation of high pressure pneumatic - hydraulic system is the use of certified safety relay [2]. The safety relay can in the case of detecting of system errors switched off the power for the whole electrical power part of the equipment (but not for control PLC). Key safety sensors are connected in the series. In the case of detection of problems with any media (hw signals AIR or LIQUID) or detection of mechanical problems (hw signals DISTANCE ERROR or COVER EMERGENCY SWITCH), the series of connected contacts is interrupted, the safety relay responds, set the signal ERROR and witch off the power for hydraulic - pneumatic system in order to automatically reduce the output hydraulic pressure to minimum. F. Network connectivity Network connectivity of our control system is based on the PLC expansion module for connection to Ethernet LAN [3]. This communication module supports access to all program elements in the PLC multithreaded program (e.g. signals, flags, registers ...) via MODBUS protocol based on the TCP-IP protocol. As part of our PLC system we use also the MODBUS communication modules for both RS232 and USB. For our special purposes, we have developed the communication embedded server – the BUS and protocol converter between CAN bus (the proprietary testbench protocol) and RS232 (MODBUS protocol) (Figure 4). The CAN converter works on the hardware module OLIMEX occupied with 8 bit ATMEL AVRCAN microcontroller [4]. The developed by protocol and BUS converter allows us to manage and to monitor hydraulic pulses unit even through CAN bus. IV. SOFTWARE SOLUTION A. Basic functions Modern low cost PLC, which allows running of several program threads gives the possibility to program main control state machine without having to create one long and complicated PLC program (ladder logic diagram or flowchart diagram). Each independent program thread can be initiated by hardware signal(s) (the PLC use 24V logic at input) or by internal programming flag with boolean data type (it can be set by another program thread). B. List of PLC hardware inputs and outputs Table 1 lists all digital and analog inputs and outputs are used in the project. Signals from the hardware inputs ERROR, WAIT, MANUAL, AUTO, PULSE and RESET are processing in the PLC by individual program threads (see Table 2) grouped in the so called physical layer. Some hardware signal inputs are used for indicating cause of the error in the safety power shutdown of the pneumatic - hydraulic system. C. Physical layer threads Physical layer threads (Table 2) are initialized by the hardware input signals, it ensures their processing and as result it sets the outputs program flags. These outputs flags manage transitions between states in the master control state diagram (literally by start or by stop respective threads in the application layer). These programs threads also process of above mentioned inputs hardware signals and set of hardware output signals so as to permit the required settling time or another parameters for particular elements of pneumatic or hydraulic hardware (e.g. delay of relays, setting time of input valve etc.). D. Application layer threads The start of running of the application layer threads (Table 3) are initiated by changes of program flags received from the physical layer. Some threads from this layer create of individual states in the master control state diagram (Figure 5). In addition, these program threads enable the realization of sub states. For example, thread 2_State_Func ensures to call of sub state 6_State_Func. This thread ensures by manually set of parameters in the hydraulic pulse train. Next thread underpins subroutine for user input interaction such the 22_State_Func. It provides possibility manually input of calibration constants. E. Description of the master control state machine The main control state machine (Figure 5) is controlled by the program flags and is isolated from the hardware inputs signals. It is not implemented in one separate program thread. We met with reliable functions of high pressure hydraulic pulse system, with reliable answers to user (also confuse) inputs and to error status. We observed the reliable automatically generated ends of each pulsation cycle or hydraulic pulse train. F. Auxiliary functions Control of pulses sequence according parameters saved in the hydraulic pulse train ensures thread 7_State_Func which is called from the state PULSE (3_State_Func). The thread 6_State_Func ensures the users inputs for controlling of actual content of hydraulic pulse train and is called from AUTO STATE (2_State_Func). G. Input – output calibration of the system The thread 6_State_Func ensures manual input of calibration constants. Reason for calibration is simple: user works with bar units of pressure but PLC works with internal representation of pressure in ADU units. The user calibration process is actually implemented within the MANUAL STATE, in the static mode (no pulse condition, manually controlled output hydraulic pressure). User can obtain by measurements two calibration curves. The first calibration curve is adjustable characteristic between the output hydraulic pressure (measured with portable calibrated hand held hydraulic pressure measurement equipment from WIKA [5]) and the output voltage in ADU (measured via PLC itself) from the sensor output hydraulic pressure ATE PS60 (commercial produced hydraulic pressure sensor used in the cars, the manufacturer is ATE). In our case, we obtained a linear relationship, which leads to the linear equation (1) derived by regression analysis from the graph of the measured values (see Figure 2): 3 (1) the value of the constant is 0.1021 [bar / ADU] and the value of the constant is 4.8074 [bar]. The second dependence is the static transfer function of the entire pneumatic - hydraulic system and its dependency output hydraulic pressure (in bar, measured by the same equipment [5]) depending on the values of the input voltage (measured in ADU units via PLC itself) for proportional pneumatic valve. Measurement leads to the next linear equation: (2) where the value of the constant is 0.053 [bar/ADU] and the value of the constant is 0.0626 [bar] (see Figure 3). Both linear equations provide four calibration constants, user can enters this to the control system (thread 6_State_Func). The userentered value hydraulic pressure in bar input is thus obtained at the output as is required. V. CONCLUSION We have created an embedded control system as a control unit for high pressure hydraulic pulse system to able be calibrated, be accurate, be robust and be network connective. This hydraulic pulse unit is a part of the test machine, which can be deployed in the industry for the tests of hydraulic parts. In respect of software architecture, the control system is built on the base low cost PLC architecture and the set of concurrent program threads. Each thread can be identified with one ladder logic or flowchart diagram. The multithreaded PLC program is designed as not one large and opaque linear program, but as the group of mutually communicating PLC programs, which in the final they form one master control state diagram. Our possible contribution is in the introduction of collaborating layers (physical and application layers) at the low cost PLC platform (without need of high level language programming – also it can be our possible contribution to education). Also we see as important the implementation of the master control state machine with these two layers and own developing of the CAN-MODBUS converter. Price of described networked embedded control system with industrial standard 24V optoelectronic isolated interfaces does not exceed 300 Euro, all control system (PLC + certified safety relay + electrical parts) came to € 1,000. REFERENCES [1] Phoenix Contact.Standard logic modules. Phoenix Contact . [Online] [Cited: 3 9, 2015.] https://www.phoenixcontact.com/online/portal/us?1dmy&uril e=wcm%3apath%3a/usen/web/main/products/subcategory_pa ges/Standard_logic_modules_P-21-03-03/695490ea-64a3- 4b9d-82dd-265f086ee2f5. [2] —. Safety relays - PSR-SCP- 24UC/ESAM4/3X1/1X2/B - 2900509. [Online] [Cited: 3 9, 2015.] https://www.phoenixcontact.com/online/portal/us?uri=pxc- oc- itemdetail:pid=2900509&library=usen&pdfmode=direct&pdf language=en. [3] —. Communication module - NLC-COM-ENET-MB1 - 2701124. [Online] [Cited: 3 9, 2015.] https://www.phoenixcontact.com/online/portal/us?uri=pxc- oc-itemdetail:pid=2701124&library=usen&pcck=P-21-03-03- 01&tab=1. [4] OLIMEX. AVR-CAN development board based on AT90CAN128. [Online] [Cited: 3 9, 2015.] https://www.olimex.com/Products/AVR/Development/AVR- CAN/. [5] Wika Instruments . Hand-Held Pressure Indicator Model CPH 6200. [Online] [Cited: 3 9, 2015.] http://www.wika.us/upload/DS_HPCPH6200___CPH6200_S 2_en_us_17152.pdf. Figure 1. Hydraulic pulse train –the schematic of sequence pulse control for hydraulic pulse system represented as train’s cyclic sessions Figure 2. Measured transfer curve for hydraulic pressure sensor Figure 3. Measured static transfer curve W AGON No.1 Pressure 1,Count1 T0,T1 WAGON No.2 Pressure 2, Count 2 T0,T1 WAGON No.3 Pressure 3, Count 3 T0,T1 WAGONNo.4 Pressure4,Count4 T0,T1 TIME of PULSATION The actual status of hydraulic pulse : count, pressure, time of pulse (T0) and time of pause (T1) The hydrauic pulse train y = 0,1021x + 4,8074 R² = 1 0 50 100 150 200 0 500 1000 1500 2000 𝑃𝑊𝐼 𝐾𝐴 [𝑏𝑎𝑟] = 𝐴𝐴𝑇𝐸 𝑃𝑆60 × 𝑃𝐴𝑇𝐸 𝑃𝑆60 [𝐴𝐷𝑈]+ 𝐵𝐴𝑇𝐸 𝑃𝑆60 y = 0,053x - 0,0626 0 50 100 150 200 250 0 1000 2000 3000 4000 5000 4 TABLE I. THE LIST OF PLC HARDWARE INPUTS AND OUTPUTS TABLE II. THE LIST OF PHYSICAL LAYER THREADS TABLE III. THE LIST OF APPLICATION LAYER THREADS n. Name of hardware signal Signal Direction/ Digital / Analog Signal is processed in the independent thread Description of physical signal 1 ERROR I0-input Physical layer 4_ERROR From safety relay 2 MANUAL I1-input Physical layer 1_MANUAL User input, manual control 3 AUTO I2-input Physical layer 2_AUTO User input , pulse gen. 4 PULSE I3-input Physical layer 3_PULSE User input , start of pulsing 5 RESET I4-input Physical layer 5_RESET User input, stop of pulsing 6 AIR_ERROR I5-input Application layer 4_State_Func From pressure air tank switch 7 LIQUID_ERROR I6-input Application layer 4_State_Func From hydraulic tank switch 8 DISTANCE_ERROR I7-input Application layer 4_State_Func From distance contact switch 9 PNEU_PUMP Q0-output Application layer 1_State_Func and 3_State_Func For pneumatic pump control 10 PULSE_RELAY Q1-output Application layer 3_State_Func For pulse control generation 11 HYDR_PRES_SENSOR AI0-input All application layers From hydraulic pressure sensor 12 MANUAL_PRES_SET AI1-input Application layer 1_State_Func From user man. potentiometer 13 PNEUMATIC_VALVE AU0-output Application layer 1_State_Func and 3_State_Func For proportional valve control n. Name of thread Signal condition for perform of the thread Program switches the flag to ON Conditionally can set also Description of program thread 1 4_ERROR Signal ERROR = ON State_FLAGS_4_ERROR PNEU_PUMP(OFF) PULSE_RELAY(OFF) Safety relay output processing 2 0_WAIT Signal ERROR = ON State_FLAGS_0_WAIT Wait state 3 1_MANUAL Signal MANUAL = ON AND ERROR = OFF State_FLAGS_1_MAN State_FLAGS_0_WAIT User input, manual control mode 4 2_AUTO Signal AUTO = ON AND ERROR = OFF State_FLAGS_2_AUTO State_FLAGS_0_WAIT User input , pulse generation mode 5 3_PULSE Signal PULSE = ON AND ERROR = OFF State_FLAGS_3_PULSE State_FLAGS_0_WAIT User input , start of pulsing 6 5_RESET Signal RESET = ON AND ERROR = OFF State_FLAGS_2_AUTO START_BUTT_ON User input, stop of pulsing n. Name of thread Flag condition for perform of the thread Description of program thread, see Figure 5 master control state diagram for hydraulic pulse system 1 0_State_Func State_FLAGS_0_WAIT = ON AND ERROR = OFF WAIT STATE, Initialization of calibration constants , zeroing of the ATE pressure sensor 2 1_State_Func State_FLAGS_1_MANUAL = ON AND ERROR = OFF MANUAL STATE, manual control of output hydraulic pressure via manual potentiometer 3 2_State_Func State_FLAGS_2_AUTO = ON AND ERROR = OFF AUTO STATE, setting of parameters for hydraulic pulse train : WAGON parameters numbers of TRAIN WAGON and number of TRAIN SEASSON, manual calibration constants inputs (sub state: 22_State_Func) 4 3_State_Func State_FLAGS_3_PULSE = ON AND ERROR = OFF PULSE STATE, performing of hydraulic pulsation according of parameter settings, after finish of pulsing goes automatic to AUTO MODE ( FLAGS_2_AUTO = ON, FLAGS_3_PULSE = OFF) 5 4_State_Func State_FLAGS_4_ERROR ERROR STATE , Safety relay determined, determination of the error source 6 5_State_Func State_FLAGS_5 Sub state of PULSE STATE, measurement of the maximum of the hydraulic pulse peak during PULSE MODE (during the pause time and during the pulse time ) 7 6_State_Func State_FLAGS_21_QSET Sub state of AUTO STATE, user setting of parameters for four TRAIN (T0,T1, COUNT, PRESSURE) 8 7_State_Func State_FLAGS_7 Sub state of PULSE STATE, actual modification of parameters after one TRAIN SESSION 5 Figure 4. Schematic diagram of the developed hydraulic system and PLC based control system OLIMEX, uController module Atmel AVRCAN ) CAN bus PHOENIX Nanoline base unit controller, 24 V DC input power, 6 digital inputs,4 NPN transistor outputs PHOENIX Nanoline operator panel LCD display and keypad PHOENIX Nanoline I/O expansion module, 2 analog inputs, 2 analog outputs, PHOENIX Nanoline RS- 232 communication module, INPUT Pressure air source Hydraulictank Pneumatic pump OUTPUT Hydraulic flow Hydraulic pump Pneumatic proporcional valve Hydraulic pressure sensor ATE PS 60 Linear displacement sensor Cover equipment removing sensor USER control unit : SWITCH : AUTO-0-MANUAL BUTTON : START BUTTON: PULSE BUTTON : RESET BUTTON : EMERGENCY POTENTIOMETER : air pressure in manual control mode Opto relay interface modules Hydraulic pressure indicator (meter) WIKA Safety Relay Pneumatic and hydraulic unit PHOENIX Nanoline USB communication module, USB bus Customer programmingor USBcommunication overMODBUS protocol RS232 communication overMODBUS protocol PHOENIX Nanoline Ethernet module CAN communication with proprietary protocol ETHERNET communication overinternet protocolserver I1,DIGITALinput:MANUAL I2,DIGITALinput:AUTO I3,DIGITALinput:PULSE U1,ANALOGINPUT:ManualSet ANALOGOUTPUT: pneumaticvalve Air presence sensor Liquid presence sensor Q0,DIGITALOUTPUT: Optorelaypneumatic pump U0,ANALOGINPUT: Hydr.press.sensor(0..5V) Q1,DIGITALOUTPUT:PULSE Realy I4,DIGITALinput:RESET I5,DIGITALinput: AIR_ERR I6,DIGITALinput: LIQ_ERR I7,DIGITALinput: DIST_ERR I0,DIGITALinput: ERROR EMERGENCY BUTTON 6 Figure 5. The master control state diagram for hydraulic pulse system Figure 6. The photo of the functional prototype of the hydraulic pulse system 0_State_Func WAIT STATE 2_State_Func AUTO STATE Settings of input param. mode 1_State_Func MANUAL STATE Manual mode 3_State_Func PULSE STATE Hydraulic Pulse Generation Mode 4_State_Func ERROR STATE Safety Relay Processing PLC POWER ON PLC POWER OFF State_FLAGS_1_M ANUAL= OFF State_FLAGS_1_M ANUAL= ON State_FLAGS_4_ERROR = ON State_FLAGS_4_ERROR=OFF State_FLAGS_3_PULSE=ON State_FLAGS_3_PULSE=OFF State_FLAGS_2_AUTO = OFF State_FLAGS_2_AUTO = ON PULSE ON time T0 PULSE OFF time T1 State_FLAGS_4_ERROR=ON 5_State_Func Press. Meas. State 7_State_Func Hydr.Pulse Train Modif. State_FLAGS_7=OFF time T0 = 0 State_ FLAGS_7= ON time T1 = 0 6_State_Func User Input Train Param. 22_State_Func User Input CalibratParam. ERROR=ON ERROR=ON ERROR=ON ERROR=ON State_FLAG S_4_ERRO R =O N State_FLAGS_4_ERROR=ON