Point And Shunt Current Conversion Computer Science Essay

Published: Last Edited:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

In this process of design methodology, a brief and precise method of collecting data from the pipeline is discussed. In the previous chapter, some of most important points of monitoring an underground cathodic protected pipeline are listed and would be crucial in our design methodology.

In any monitoring system that is available in the market, data acquisition would be the primary role in the design methodology. It is important to understand what would be the parameters that are needed to be taken into consideration in order to achieve a better and more precise monitoring system. Overall the research is subdivided into two main categories which is the hardware and software implementation. A prototype of the remote monitoring system would be developed to be tested and analyzed with the GUI based server. The design flow of the overall development is shown in figure 3.1

Figure 3.1 Development Design Flow

3.2 Data Acquisition

3.2.1 Design Overview

In the design overview, we would be looking some methods of obtaining information from an existing underground cathodic protected gas pipeline system. We would be focusing on an electrical simulation model of a cathodic protected pipeline to find out the relationship between the voltage and the pipeline.

It is clear that the most important parameters that would require monitoring would be the between potential of the pipeline and the soil which is also known as the cusing on an electrical simulation modelthe anode to the cathode area which is also known as "Shunt Current". The two parameters mentioned play the most important role in the monitoring system. The "Drain Point" and "Shunt Current" should always stay below the threshold value in order for the pipeline to be cathodic protected.

It is also equally important that the environment of the cathodic protected pipeline to be monitored because the surrounding temperature and humidity of the pipeline might affect the readings of ings of nd humidity of the rrent" occasionally.

The design of a cathodic pretection monitoring system would require a microprocessor remote terminal unit system. When Designing a RTU board, it is important to choose the appropriate microcontroller/microprocessor as the main MCU. The easiest way to choose the correct MCU is to anticipate the amount of analog, digital inputs and outputs pins. Choosing the correct analog ADC bit is an important consideration because the higher ADC conversion bit will result in a higher resolution and accuracy.

The analog inputs used in the RTU board are Drain point, Shunt Current, Temperature and humidity. It is equally important to select the correct amplifiers such inverting, non inverting or differential type and the correct gain. It is important to what would be the backend of the device server whether is connected via LAN, WAN or serial communication. A MCU with a multiple UART is recommended because it can be connected to several other peripheral modules such as RS232, RS485, RS422 and network TCP communications.

The output of the RTU board commonly used is digital output whereby alarm leds, lcd display, GSM output, relays contact, server communication for data logging can be achieve. The complete RTU board design can be found in the appendix A.

3.2.2 CP Drain Point

In some practical cases, measuring the cathodic protected pipeline's "Drain Point" would be quite challenging as the value would differ as the pipeline is moving away from the anode. In other words, as pipeline is moving away from the anode, the cathodic protected pipeline "Drain Point" would be gradually reduced. Therefore, it is important to always use the test post as a reference point to obtain the "Drain Point". The easiest method to measure is by placing a voltmeter on the test post and the CU/SO4 reference cell.


Figure 3.2 Drain Point Measurement Circuit

3.2.3 CP Shunt Current

Shunt current is the flow of electrons in a closed circuitry which also can be seen from the cathodic protected pipeline system. The current flow means electrons are moving from the anode to the underground pipeline which makes a negative potential which reference to the reference electrode.

In a complete monitoring system, the current measurement indicates the severity of the cathodic protection system. In most common cases, the more vulnerable pipeline to corrosion would cause a higher rate of current flow. Therefore this would reflect a more accurate method to monitor the condition of an underground pipeline system.

3.3 Data Pre-processing

3.3.1 Drain Point and Shunt Current Conversion

In most industrial application, SCADA systems are designed in such of way to read voltage or current inputs. Voltage and Current transducer are a important components in order to obtain a proportional and accurate reading of the drain point and shunt current.

The most common type of output to the monitoring system is to read 4-20mA sensor values. The VTD DC voltage transducers would be suitable to obtain portant components in order to obtain a proportional and accurate reading of the drain point and shunt ipple and a fully isolated output which is susceptible to high DC voltage of 600V. For the shunt current sensor, a loop powered current transducer is used to obtain the 4-20mA. The loop powered current transducer can be used to convert current value up to 400A and would provide a highly accurate monitoring alternating current over long distances. The current output is would then be converted into 0-5V as the RTU inputs.

3.3.2 RTU Analog Inputs

The RTU analog inputs is used to measure the drain point, shunt current, TR voltage, humidity, and temperature value. The amplifier below uses a LM741 IC in differential mode. The input fed is from the voltage to current transducer.

Figure 3.3 Current to Voltage Conditioning Circuit

The current inputs from the transducer is from 4-20mA. When the current passes a 150 ohm R2 will generate a voltage across R2 which will be fed to RB1 and RF2. The amplifiers uses single source power, therefore the non inverting will require a reference voltage in between. The gain for the differential amplifier is 1 to 1. The main reason to implement a no gain differential amplifier is to convert the current to voltage source. The voltage source will then be connected to the analog pins of the MCU for ADC conversion.

Figure 3.4 Frequency response of Conditioning Circuit

A simulation was made to analyze the frequency response of the amplifier. The frequency response of the graph is from 10 Hz to 1 MHz the cutoff point of the response starts at 100 KHz. Although it is said that the voltage to current transducer frequency would varies between 10 to 100 Hz therefore the amplifier cutoff point would be in stable condition.

Figure 3.5 Distortion Analysis of Conditioning Circuit

The distortion analysis was simulated to test of the response of the noise against input frequency. The analysis showed that the distortion starts to increase gradually from 1 KHz with a maximum gain of 20dBat 1 MHz frequency.

3.3.3 RTU Humidity and Temperature Inputs

The RTU humidity and temperature SN-HMD is said to be recommended due to its voltage analog output that suits the application for data logging. The small and compact size increases practicality and compatibility with the MCU. The typical output voltage range is from 1V to 3v with the measurement accuracy of +/-5% RH.

Figure 3.6 SN-HMD Sensor Output Analysis Response

Figure 3.7 SN-HMD Sensor Pin Configuration

The sensor pin 1 is connected to 5 Volts and pin 4 to Gnd. The graphs showed the output voltage vs temperature and the output voltage vs. humidity. The output of the both graphs is quite linear with the temperature voltage is around 2.5Volts to 4.5Volts and humidity is from 0.8Volts to 3Volts. Both of the voltage signals is sent to MCU pin ADC conversion.

3.3.4 RTU LCD Display

The lcd has a pixel of 20x4 alphanumeric which has four rows and twenty columns. The MCU connect to the LCD ports via PortB. The LCD is used to display the measurement values of drain point, shunt current, Tr voltage, humidity and temperature readings.

Figure 3.8 4x20 character LCD display

Below is a list of the pin out functions for the LCD display.

Pin No








Voltage Supply






Register Select







11 - 14

D4, D5, D6, D7

Data bit 0, 1, 2, 3

Data bit 4, 5, 6, 7

Table 3.1 Pins function of LCD display

Table above is mention about the pin functions of LCD display. The totally pins of 4x20 character LCD is 16 pins. Pin 1 to pin 6 and pin 11 to pin 14 will be taken for the project designed. The pin 1 is connected to ground, pin 2 is voltage supply. Pin 3 is a control pin which is used to adjust the contrast of the display. The pin 4 is a register select (RS), it is use to set the command mode or display mode. Pin 5 is read or write line (R/W), this line is responsible to read the character data or writing the commands. Furthermore, pin 6 is an enable (E) line of LCD. It is responsible to send the character data or command. The pins from 7 to 14 are the eight bit data bus lines. This is used to transfer the character data. The LCD can be transfer data for single 8-bits byte or two 4-bits byte.

Figure 3.9 LCD Connections with MCU

The LCD connections selected is using 4 bit to reduce I/O pins. The PORTB has an internal pull up resistors which helps to reduce floating point of the LCD and increases stability when driving the LCD

3.3.5 RTU TCP/IP Socket

The RTU uses EG-SR-7150MJ gateway module to convert the serial data into TCP/IP data. The module allows the RTU to send the drain point, shunt current and Tr voltage, humidity and temperature data to the server using local area network (LAN). The module is mounted with a RJ-45 connector enable the module to be connected into such as router and access point to be connected to the wide area network (WAN).The module runs on UART and the communication with the MCU can be transfer serially.

Figure 3.10 Wiznet EG-SR-7150MJ Ethernet Gateway

The module has two modes which is the serial command mode and data mode. The module has a fully-hardwired TCP/IP stack with 10/100Mbps Ethernet interface. The protocol that the module supports includes TCP, UDP, IP, ARP, ICMP, MAC, IGMP, PPPoE. The maximum serial speed is around230Kbps. The TCP module will require setup IP address, IP Subnet and IP gateway. The local port, server IP and Server port is also needed to make network connection. The total power consumption is about150mA at 3.3V.

The TCP module can work with two ways which is TCP server mode or client mode. In our prototype we would use TCP server mode whereby the server would initiate the connection to the device. Once they are connected, data can be delivered as the handshaking process begins.

Figure 3.11 Wiznet EG-SR-7150MJ Hardware Connection

In order to setup the local IP and local port, the server is required to have configuration tools whereby setting up the device can be done seamlessly.

Figure 3.12 Wiznet EG-SR-7150MJ Configuration Tools

Step1: Press search and wait, if the device is found on the Ethernet, it would appear in the module list. Confirm the MAC address with the TCP module. If they match, we would proceed

Step2: The setting button is press to make settings on the module

Step3: Select if Static or Dynamic IP is used. Static IP is more favorable in this case. Enter the Local IP, Subnet, Gateway and port address with reference to the server domain address

Step4: Select TCP server, TCP client or UDP mode. TCP server is more favorable as TCP guarantees the delivery of data by requesting the recipient to send an acknowledgement to the sender.

Step5: The configurations tools would allow entering the command mode using hardwareor software trigger. The command would enable the device to change its settings andmode of behavior by sending the command code protocols.

Step6: The delimiter settings should be as default.

Step7: Setup inactivity time to close the port after no data transmission for a certain period of time.

The hardware pin configurations to MCU are as below








Low Active Reset




RS232 input, Data received from the input server



Clear to send



Clear to send


Not used


RS232 output, Data from the MCU to the server




Request to send


Not used

Factory Reset

Pull factory reset to low to make factory settings


Not Used

HW trigger

Pull hardware trigger to low to enter serial command




Pull the PSEN to low to enter bootloader for firmware upload


Not Used

Table 3.2 Wiznet EG-SR-7150MJ Pin Configuration

3.3.6 RTU GSM Modem

The GSM network can be divided into three broad parts which is the mobile station, base station subsystem and network substation. A GSM modem is a wireless modem that works with a GSM wireless network .The behavior of GSM modem is same with dial up modem. The main differences between them is that a dial up modem sends and receives data through a fixed telephone line while a wireless modem sends and receive data through radio waves. A GSM modem requires a SIM card in order to operate. The GSM modem available in 2 types:

PC card/PCMCIA card

Design for use with a laptop computers. The card is inserted in its particular card slot in laptop computers

External wireless modem

It is connected to the computer or other embedded system through a serial cable or USB cable. Therefore an interface circuit or system is needed for communication in between the system for certain process.

The GSM modem uses AT command to send instructions. . AT is abbreviation of Attention where every command line starts with t or system is needed for commcommand set is quite lengthy, we are only focusing in few instruction sets to initialize modem, send SMS, read SMS and delete SMS. Some of the main instructions include AT+CMGF, AT+CMGR, AT+CMGS, and AT+CMGD.

In this prototype, the GSM modem is designed to send short messaging system (SMS) to alert the user when a faulty is detected. The SMS is a fast and reliable method but somehow more costly than using push email system of alerting the user. Therefore, the GSM modem is designed as a fail backup system to send SMS whenever the internet connection is not available. The GSM modem is connected to the server software and alerts related to drain point, shunt current and Tr voltage would be sent to users.

3.3.7 RTU Microcontroller Selection

Microcontroller is the center control station of the system. The PIC18F452 has been selected for the project and some of detail on microcontroller as shown below has referred from the datasheet source [XX].

The high performance enhanced FLASH microcontroller with 10-bits A/D data sheet has be prepared for reference.

High performance RISC CPU.

16-bit wide instruction and 8-bit wide data path

Priority levels for interrupts

32K bytes of FLASH program memory, 1536 bytes of data memory (RAM) & 256 bytes of EEPROM data memory.

Watchdog Timer (WDT) with its own On-chip RC Oscillator for reliable operation.

Power on reset (POR), power up timer (PWRT) and oscillator start up timer (OST).

The wide operating voltage range is 2.0V to 5.5V.

High current sink/source 25mA/25mA

Pins diagram

Figure 3.13: Pins diagram for PIC18F452

Below is list of the ports of PIC18F452 which have been used for the project.



Drain Point Analog


Shunt Current Analog


TR Point Analog


Temperature Analog


Humidity Analog



D4 LCD pin


D5 LCD pin


D6 LCD pin


D7 LCD pin


RS LCD pin


EN LCD pin



Hardware Trigger Pin EG-7150MJ


Reset Pin EG-7150MJ


UART pin to TXD


UART pin to RXD



Master clear (reset) input.

VDD Pin 11 and Pin 32

Voltage supply

VSS Pin 12 and Pin 31



Oscillator crystal input.


Oscillator crystal output.

Table 3.3: Hardware Pin Configuration for PIC18F452 RTU embedded blocks

The RTU microcontroller PIC 18F452 requires an embedded C compiler in order to develop an embedded process. MikroC compiler is an advanced powerful IDE and ANSI Compliant is very effective in writing embedded program for PIC microcontrollers. The RTU embedded blocks are depicted in below:

Figure 3.14 RTU Embedded Blocks

Basically the PIC Microcontroller unit worked as data acquisition system that converts analog voltage into digital data. There were altogether seven embedded blocks in the main task. The main task would to use ta. There adc_read(char))har)har)d to use ta. There were altogether se into a 10 bit digital data. The converted values are stored in PIC internal memory and the values would then be converted from binary to strings using sfloattostring(float number, char *output)loat number, char *outputom binary to strings using stored in PIC internal memory and the values task used PORTB and initializes the LCD display to run on four bit system.

The main task displayed the converted results on each row using a 1 sec refresh rate in order to avoid flickering on the LCD. The main task utilized a 57600 bps to communicate with the TCP/IPsocket. The UART function uUsart_write(char))char)function unction The main task utilized socket. The protocol data function that was sent to the server was based on MODBUS Ascii method. The values that were sent include header, body and LRC for checksum usage. The testing and simulation results can be obtained in the chapter 4.




unsigned ADC_Read(unsigned shortchannel)

10-bit unsigned value read from the specified channel.

PIC's internal ADC module is initialized to work with RC clock. Time period is determined by the clock for performing AD conversion

The Parameter Channel represent which pin is converted

floattostring(float number, char*output)


A array of string is created out from the float values



Function transmits a byte via USART. The baud rate should be preinitialised

Table 3.4 RTU Main Task Description RTU Process Flow

The process flow of the main task in the RTU system can be illustrated in following diagram:

Figure 3.15: MCU Main Flowchart




Initialize microcontroller module I/O port

ADC setup to fosc/4, Uart Baudrate 57600 bps

Turn On timer0 to tick every at timer ratio 1:64

LCD setup 4 bit interface.See figure

Second tick

Wait for second flag expires and check Main Task

Main task

Call Analog to Digital conversion

float value is converted to string

Strings values is send to LCD driver and Modbus protocolsto TCP/IP module

Update Timer Tick

When timer0 expires, variable Msec is incremented and

second tick expires every 100msec.See figure

Table 3.5 Flowchart Functionality Process

Figure 3.16: MCU Initialization Flowchart

Figure 3.17: Main Loop Task

Modbus Protocol


Transmit Readings to Server

<[Header][Sensor Parameter][ADC Conversion][LRC]>


S : Server

R : Recipient

Number of Result Byte

A : Drain Point

B : TR Voltage

C : Shunt Current

D : Temperature

E : Humidity

ADC Conversion

Value in Ascii Decimal

Longitudinal Redundancy Check oLRC)R

Each Received Byte is added for error transmission check

Server Reply

<[Header][Reply Message][LRC]>


S : Server

R : Recipient

Reply Message

K : Data Received Successfully

X : Data Error

Table 3.6 Communication Protocol with Server

Figure 3.18: Main Interrupt Timer Tick


3.4 Data Processing

3.4.1 Server Software Design

The server is designed to capture raw data for processing and graphical display using Visual basic 2008. The server is run under windows platform used Winsock socket programming to communicate with the RTU device. The main server is the central system for the whole application. The programming component blocks are illustrated in figure 3.19

Figure 3.19: Main Server Components Block

The main server is divided into component blocks and the functionally is discussed in table



Main Server Form

Display District name and CP Station

Display Readings of Drain Point, Tr Voltage, Shunt Current, Humidity and Temperature

Connect Serial Comport

Connect Client IP address and Port

Connect Client SMS number

Login Form

Enter Username and Password

Username and Password is verified with database

Main form is loaded when authentication is correct

Register Form

Register User name and password

Registration is save in Microsoft Access Database

TCP/IP Socket

Winsock component is used

Connect to device IP and port

Graph Display Form

Graphical line representation of Drain Point, TR Voltage, Shunt Current, Humidity and Temperature

Serial Comm GSM

Mscomm component is used

Serial Communication of 9600 baud rate is initialized

AT command is used to communicate with GSM modem

CDO Push Email

SMTP is used to send email

Email is sent to alert the users in the event of malfunction

Data Export

Data is exported to excel application

Alarm Settings Form

Alarm setting is used to set the threshold value of Drain Point, TRvoltage , Shunt Current ,Humidity and Temperature Value

Min and Max value is set

Table 3.7: Main Server Components Functionality

3.4.2 Human Monitoring Interface (HMI)

Step1: Create Standard.Exe Project

Figure 3.20: Standard VB project Form

Step2: In the Project go to add references

Figure 3.21: VB references library panel

The references used and descriptions are discussed below