A Microcontroller-Based Remote Embedded SCADA Control System With the Aid of a 32-Bit Microcontroller

: Supervisory control and data acquisition are well established control and visualization systems in industry. SCADA systems are DCS, PLC, soft PLC, industrial computer or microcontroller based. Some of those types of control are suitable for certain industries and are not for others. DCS is suitable in process control such as chemical, petrochemical, pharmaceutical industry and alike. PLCs are more suitable for food industry, beverages, car industry etc. Microcontrollers are emerging as a competitive option in small open SCADA system. All those types of control are based on data sharing using different types of networks such as Fieldbus, Profibus, Modbus and high speed ethernet. Those nets are interconnected using hard cabling which renders the communication distance very limited. One option is the use of public services such as internet but the risk is too high due to hacking, sabotage just to name few. This is demonstrated by the various conferences held over the world discussing protective ways against such practices. To overcome those problems including the cabling problem, one can call upon wireless communication with the aid of microcontroller and a SMART PHONE. This paper presents the design of a remote embedded SCADA system based on a 32 bit Microchip microcontroller. The controller has three main tasks to carry out. It controls a heat exchanger rig. It drives a multimedia graphic expansion board and it communicates with the SMARTPHONE using GSM where it interacts with the process either in normal mode or emergency mode. The proposed scheme has several advantages. It can communicate to any user independent of distance and time. It could be easily customized to allocate small and probably middle industry. On top of the cost effectiveness, the system could be expanded in local network to accommodate more complex applications.


Introduction
Automation control has become the collarbone of any control system especially in large scale industries, where distributed control system (DCS), programmable logic controllers (PLC) and industrial computers (IP) play a pivotal role either in controlling the process or visualizing it, either locally or remotely. This has many advantages. Good quality of the product, competitive cost, high level of safety and a very good turn over in the long run. Unfortunately, due to its complexity and high cost, this type of control would not be convenient to control small applications. With the tremendous technology development, a better way is to use a customized low-cost microcontroller based around which a SCADA system could be developed, with the use of public cell phone, where the microcontroller is used as a local controller and the cell phone as a remote supervisory system. Many good works in the area have been reported in literature. Das & Al. [1] proposed an authentication technique to safely control home appliances. Being authenticated, the cell-phone based system relays commands to a microcontroller, that takes over and performs pre-programmed tasks. Goel & Al. [2] developed an integrated wireless SCADA system for monitoring & accessing the performance of remotely situated device parameter such as temperature, pressure, humidity on System with the Aid of a 32-Bit Microcontroller real time basis, whereas Ali & AL. [3.] developed a humanmachine -Interface set up based on cellular phone to monitor temperature. Ali & Al. [3] developed an automated setup for the measurement of temperature of any industrial environment. They claim that the hardware requirements are significantly curtailed using the microcontroller's modern embedded features like A/D conversion, display interface, hardware and software interrupts, and communication protocols for interfacing cellular phones and GSM modules.
Li & AL. [4] described the design and realization of GSM short message for alarming system through AT command. Security office can deal with emergency cases through finding information displayed on the screen of the mobile cell. Mbaocka [5] proposed a design of a system that dictates the presence of GSM signal from unauthorized user in restricted areas and districts that user from service. Wale & Al. [6] proposed a monitoring SCADA system to diagnose and forecast strategy of the functioning state of power system. Rehna & Al. [7] presented the design & implementation of low cost Cell Phone Detection System with a "Denial of Service" technique jamming. Cheng & Al. [8] presented a study where they integrated mobile phones, wearable devices, temperature and human motion detectors as smart sensors for enabling smart air conditioning control. Smart sensors obtain feedback, especially occupants' information, from mobile phones and wearable devices placed on human body. Sairam [9] has designed an intelligent mobile vehicle checking system implementing the functions of video capturing, intelligent plate distinguishing GPS positioning and wireless transmission. Irannejad & Al. [10] presented a device for remote sending the cathodic protection in formation of oil and gas pipelines and applying it to SCADA system via GSM. Malikamber & Al. [11] presented a paper which focuses on developing IEEE C37.1 Standard comprising of a combination of hardware and software to monitor and control various parameters in industry. The scope of the project extends from providing a system status on a single machine (usually PC) to a distant place using IEEE 802.3 LAN protocol and Web based access. The system is also capable of controlling devices in the industry. Mascare & Al. [12] developed a project to remotely monitor burner processes using SCADA. The process was monitored either locally or remotely with the aid of GSM in case operator not present on site or otherwise. He should be kept aware of ongoing process, faults occurring, the air fuel ratio values etc. A GE Fanuc PLC was used in the control process. Joshi & Al. [13] proposed a system work at remote location for supervisory control and data acquisition with the help of appropriate Programmable Logic Controller (PLC). Main aim to design automatic system implemented using ABB 564 Ethernet PLC having control builder plus and panel builder tools. Keeli & AL. [14] developed a remote SCADA system to manifest this real-time situation, a temperature recording system for a remote plant set-up is developed by Visual Studio. Temperature sensors are interfaced to a microcontroller. Information collected from the sensors is continuously sent over 2.4GHz trans-receiver wirelessly to the microcontroller which is then received at the corresponding 2.4 GHz USB type trans-receiver connected to a PC / Laptop. In the computer "DAQ System" (software) is loaded which takes the collected data and presents them on PC / Laptop's front panel, and also logs them into the database. Shingre & Al. [15] developed a SCADA system to monitor and control several physical parameters based on cellular phone using GPRS or WAP to enhance the performance of the equipment. Ghadage & Al. [16] wrote a paper presenting an ANDROID phone as supervisory controller and PC used as base station to store data. Communication is set by blue tooth application protocol. Mc Connell & AL. [17] described and evaluated a telemetry system based on GSM mobile phone technology that may provide mark-recapture data for single year survivorship studies on gray seal on the costal area of Scotland. Ozdemir & AL [18] presented a paper on a Java-enabled mobile phone has been used as a client in a sample SCADA application in order to display and supervise the position of a sample prototype crane. The paper presents an actual implementation of the on-line controlling of the prototype crane via mobile phone. The wireless communication between the mobile phone and the SCADA server is performed by means of a base station via general packet radio service _GPRS_ and wireless application protocol _WAP_. This paper describes the design of a remote SCADA system to control a heat exchanger, where the control is done locally using a Microchip microcontroller PIC32, and at the same time, it is interfaced to a UBLOX Machine to Machine (M2M) card. A SMART card is inserted into The M2M so that communication could be established with any cell phone using Global System for Mobile communication (GSM). To display the SCADA dynamic graphs and trends as well as soft buttons, a clever little multimedia expansion board (MEB) is interfaced to the microcontroller. The mimics of the heat exchanger are generated using EDRAW-MAX. To convert those mimics to machine language for the microcontroller to execute, a tool known as Graphics Display Designer (GDD) integrated in the Microchip MPLAB IDE platform is called upon to convert the dynamic graphics into a C subroutine. Another important advantage, that any control scheme such as MPC, adaptive, fuzzy, neural network could be developed in Simulink then converted into C files which could easily be fired into the microcontroller online.

Heat Exchanger Process
The proposed system was tested using a lab heat exchanger. The exchanger consists of a closed circuit primary hot water system (the heating fluid), supplying heat to a secondary water system (the process fluid) fed from the mains. A plate type heat exchanger transfers the heat from the primary to the secondary system. The primary source of hot water is a 70 liters sump tank fitted with two 3kW immersion heaters controlled by a thermostat. Water is pumped from the tank through the valve and flow meter system, thence through the heat exchanger and back to the sump tank for reheating. Two flow meters of the Rota meter (variable area) type are fitted in the primary hot water system for monitoring the hot water flow. The Water circuit is shown in Figure 1. The hot water flowing into the exchanger is controlled by an electro-pneumatically operated control valve (V c ). A platinum resistance sensor of type resistance temperature dependent (RTD) measures the process fluid outlet temperature. This temperature is compared with the set point and the error is fed to a PID controller. The control variable is then converted to 4-20 mA which feeds the current to pressure converter (I to P) whose output pressure controls the valve which in turn controls the flow.
A rise in the outlet temperature will produce an increase in the value of the current signal, and hence an increase in the control air pressure supplied to the valve. The control valve will thus partially close, decreasing the primary hot water flow rate, thus reducing the heat supply to the exchanger. A fall in the outlet temperature will increase the valve opening, thus more hot water.

System Hardware Design
As shown in Figure 2, the system is based on a32bit PIC microcontroller from Microchip, mounted on a starter kit. The controller has three roles to play. The first one is to control the rig, when set to automatic mode from the cell phone, where it reads the temperature at the outlet of the secondary circuit of the heat exchanger, which is picked up by an RTD connected across a 4mA current generator to produce an output voltage proportional to temperature. This voltage is fed to the microcontroller through one of the 10bit dual slope analogue channels where it is compared with the set point to produce the error signal. The error is fed to the PID controller. Microcontrollers do not generally have any digital to analog converter which is required to drive the control valve. To overcome this problem, an external DAC is used. Two options are possible a parallel DAC or serial DAC. Parallel DAC is not good option because it requires two output ports. Those ports may be required for other applications. A better option is the use of serial DAC especially when high speed conversion is not required. The serial DAC is driven as a synchronous slave by the microcontroller which is configured as the master. In this mode, only three lines are required; a serial clock (SCL), a chip select ) and serial data pin (SDI). The analog output is converted into current using voltage to current converter (V to I) where a 0 to 5V produces 4 to 20 mA. This current is applied to I to P converter which produces the standard 3 to 15 PSI required to drive the control valve. The following equation governs the control signal: (1) Where C out is the control variable, K is the gain, error is the difference between the set point and the measured variable, ACCerror is the accumulated error, i τ is the integral time constant, d τ is the derivative time constant and errorold is the previous calculated error. This signal is outputted through an external 12bit serial converter which produces 0 to 5 volts. This voltage is then converted to a 4 to 20 mA current, which in turn drives a current to pressure converter which controls the control valve. The second role of the microcontroller is the communication with the cell phone through the M2M PICtail daughter board developed by U-BLOX for Microchip. This module is capable of sending short messages to any SMARTPHONE using different communication systems such as GPRS, GPS and GSM. For the application in hand, the latter was used to make calls or send short messages (SMS) in both ways. To ensure the security of the phone calls and SMS, GSM uses a Subscriber Information Modules (SIM) card inserted on the back slot of the PICtail board.
The third role is the SCADA which is based on the PIC32 microcontroller as a processing power interfaced to a Multi Media Expansion board. The Expansion board is used to display the dynamic mimics, the trends as well as the commands from the SMARTPHONE through soft buttons. The mimics are generated using EDRAW MAX. The heat exchanger mimic is shown in Figure 3. The mimic is then uploaded into MPLAB IDE, the PIC platform, using Graphic Display Designer (GDD) where it creates a PIC32 C language program which could be integrated into the main program, compiled and downloaded into the controller.

A Word on Edraw Max
Edraw max program is a software which has numerous applications. It is provided with a set of libraries which can be used according to the application needed, for example it contains library with certificates templates for creating certificates, it has flow chart main symbols to make it easier to make one, and most importantly for our application, it has a set of the process units and instruments so a mimic diagram of a process can be developed. As seen in figure3, most of process control and measurement components such as valves, pumps, motors, meters, annunciators, switches etc. are all available in the software's library.

Program Flow
The running program is developed in Microchip C, compiled under MPLAB platform to carry out a series of tasks [19]. To start with, the work space contains all the libraries containing the functions and loops used to set up and control the operations of the peripheral modules. It contains functions to control the M2M and the MEB, alongside with the PIC32. Those libraries are divided into a number of subroutines. Figure 4 shows all the C subroutines generated by the compiler, where Figure 4a presents the MPLAB project worshop, Figure 4b presents the header files called in the main whereas Figure 4c shows the GSM configuration. It also shows the header files required by the compiler to first configure the microcontroller PIC32MX795 The control parameters (heater, pump and alarm) were then declared as integer and set to initial value zero (figure 5a). Next the mobile phone number is inserted so the concerned person will be contacted. The soft buttons for tank level alarm, set point as well as pump and heater are created. Depending on the alarm acknowledgement by the operator through the smart phone, both the pump and heater are either controlled locally or remotely. If for some reason the operator does not consult his phone and does not acknowledge the alarm, the microcontroller takes action by turning them off locally (Figure 5b). The different control strategies are shown in Figure 5c. The SMS is sent out using instruction ubxSendGsmShortMessage (number, sms1) ( figure 6a). If the level in the tank is low, this will be indicated on the mimic as red led and at the same time, it sends out an SMS message using the stored phone number (Figure 6b). After receiving the alarm, and On acknowledgement (Figure 6c), the operator turns off the alarm remotely and turns back on both the pump and heater remotely (Figure 6d).

Results and Discussions
Two control schemes are implemented; normal mode and emergency mode. In emergency mode either the tank level is too low or the temperature is too high. In the case of tank level low, an emergency SMS is sent out saying "Low level". The user acknowledges it by sending back an "A" message. Then sends a "P" message. This toggles the pump operation between on and off. If the temperature is too high, the controller sends out an SMS message "High temperature". The user sends back an acknowledgement signal, and an "H" command to turn the heater off. In Normal mode, the control is either run automatically or manually. In the manual mode, an SMS message "M" (manual mode) is sent to the controller with the required valve opening ratio "Vxx" so that the valve opens accordingly. In automatic mode, the user sends a command "U" (automatic mode) together with the desired set point "S0000", then the microcontroller takes over using the PID to bring the temperature to the received set point. The scheme is shown in the flowchart below ( figure.7), and it was tested in the following sequence: The first step is to develop an HMI at both ends and connect several applications through a low level local network in a master slave topology; then establishing the wireless communication through the master. When the program was downloaded, the process graphics were on the MEB screen, along with three soft buttons, one for testing the alarming monitor system, which is the square button with the word (LEVEL) on, as well as the two red circles which are buttons to indicate if the device is on or off, and to be used for local control. The heater was locally turned on, the soft button for the heater was pressed, and to indicate that the heater is on, a small white circle appears in the middle of the red circle. The pump was also turned on locally by pressing the pump circle. Similarly for the heater, a white circle appears to indicate that the pump is working (figure.8 ). The (LEVEL) alarm soft button was then pressed; the local alarm indicator was turned on (LED5) and at the same time, the pump and heater were both turned off, where the circles turned red again indicating that the pump and heater are both off (Figure 9a) . At the same time, an SMS is received on the phone cell, through the number that was previously stored in the program to indicate the emergency initiated in the process (Figure 9b). To notify the system that the person concerned has read the alarming SMS, an acknowledgment message is sent out to the GSM modem. When the modem receives the SMS, it passes it through to the PIC. The latter decodes it, and since the message is an acknowledgement one, the microcontroller turns off the alarm and the local alarm indicator (LED is automatically turned off indicating alarm acknowledgement. After the acknowledgement SMS, it is possible to remotely open the pump and heater, by sending two separate messages, one with 'H' to open the heater, and another with 'P' to open pump as shown in figure10. To test the system even further, the alarm was again triggered, and an SMS was received on the cellphone; this time the alarm SMS was not acknowledged; but instead, an SMS for opening the heater was sent (figure 11a). The system received it, and the PIC decodes it, however no action was taken, and the system didn't react at all, instead as expected, the (LED5) was still on indicating the alarm, and the heater was still off and didn't open (figure 11b). The next step was to acknowledge the request again and test if the system will react to the sent message after the previous one and it did.     At the beginning of the test, the control scheme was in automatic mode and is indicated by the letter (A) on the blue tank ( Figure 12). After the phone cell receives this message, it turns the scheme to manual by sending the command "M" as shown on the right of Figure 13a, the command was followed by sending another SMS, "V25" to set the valve opening to 25%. The change immediately takes effect as shown in Figure 13b at the right, where it is indicated to the right of the pump.  To check the automatic mode, an SMS command "U" was sent to the microcontroller (figure 14a). This is indicated on the mimic by the letter "A" on the blue tank (figure 14b) and the new set point is set to the desired value, in this case, it is 25. To test the emergency mode, the temperature was allowed to rise until it reached 80 degrees Celsius, the microcontroller sent out an SMS message to the cell phone indicating "High temperature" (Figure 15a), also at the same time the local alarm LED5 turned ON (Figure 15b). The user acknowledges the alarm and turns off both the heater and the pump. A similar test was carried out for "Low level" and it worked as expected. This is demonstrated in Figure 16.

Conclusions
It could be concluded that for small and perhaps medium industries, a remotely microcontroller-based SCADA system could be more appropriate to implement. This will not only reduce the control system's cost significantly compared with classical ones such as PLC or DCS, but it is also simple to implement and more secure as well, due to the fact that it uses a subscriber Information Module which cannot be easily invaded by intruders. The system is also capable of handling any emergency cases when operators are not available. The system could be extended by implementing any control strategy available in Simulink where microchip has provided a set of device block sets which allow the control scheme to be converted into C files which could easily be programmed into the microcontroller and online.