You are on page 1of 9

Design and implementation of a low cost MCU based current loop calibration device

Abdulkadir akr, Frat Ycel and Hakan al 10/26/2011 11:30 PM EDT

4-20 mA current loops are widely used for communication in industrial automation systems. This paper discusses the design and implementation of a low cost microcontroller based current loop calibration device to test and calibrate systems that communicate via 4-20 mA current loop standard. The aim of this work is to decrease the cost of these devices regarding commercial value. Designed device has 0.001 mA resolution on the current sourcing. It is also both capable of measuring and providing requested current between the range of 4 and 20 mA either automatically in the format of step or ramp based function or manually by entering current value via a numerical keypad. 4-20 mA current loop is a basic method for sending sensor information in industrial applications . Sensor is a device used for measuring physical parameters like temperature, pressure, speed and fluid flow. Most of the process automation sensors are standardized using the 4-20 mA current loop interface. This interface is generally used for sending sensor values over current loop to remote locations - see figure 1.
[1]

Fig 1: Overview of the current loop system. If voltage levels are used for sending process, there will be a decrease in voltage depending on the resistance of the carrier and distance increments. In order to prevent this negation, 4-20 mA current loop is standardized. There are lots of systems in industry working with 4-20 mA current loop standard. 4-20 mA current loop calibration devices are used in testing and calibrating those systems. 4-20 mA current loop is designed to be in the value of 4 mA when the sensor receives the minimum value and it becomes 20 mA when it reaches the [2, 3] maximum value . So, 4 mA is assumed as a starting point (0 percent reading) and 20 mA is seen as a full scale reading (100 percent). In this condition, 0 mA level is interpreted as a communication break. It means that 0 to 4 mA range is called as the zero or offset. The 4 to 20 mA range is called as the span of the transmitter.

Fig 2: Interface of the 4-20 mA current loop. A 4-20 current loop circuit is composed of 4 elements; sensor/converter, transmitter, receiver and current

source - see figure 2. Sensor or transducer measures physical magnitudes and converts to voltage. Transmitter converts the voltage information taken from sensor to the 4-20 mA current level. Receiver after taking the 4-20 mA current level converts it back to voltage and sends to the process controller or to an indicator. Current source provides the current loop as well. There is at least one receiver in each loop. It can be an indicator (a meter or a digital readout), a chart recorder, an input to an RTU or a PLC, a valve actuator, etc. The 4-20 mA current loop has some advantages. These are; less affected by noise, capable of sending signals to distant locations, signal being limited by only current source, and so inexistence of signal lost and ability to control broken line. Since the bottom level for current loop is at 4 mA level, the breaking of signal transmission line is interpreted to be 0 mA
[4]

We use current loop calibration devices to observe the system behavior according to the likely values that the sensor can have when designing and testing of industrial apparatus with sensors. Calibrators produce and also read current values in 4-20 mA intervals. For the system seen in figure 2, current loop calibration devices determine how the process controller behave for different process conditions (such as the temperature level in the 10 percent, 50 percent, and 77 percent ranges) of remote systems by taking the place of transmitter and receiver. In commercial area, there are many types of 4-20 mA current loop calibrators having different specification, and their cost is up to $2000. In this work, we aim to decrease the cost of these devices regarding commercial value. Most of the calibrator devices produced in the commercial area have the property of being adjusted in analog or step/ramp function based. By this work, we aim to develop a calibration device that can be adjusted to the desired current level, entered by keypad, in an adequately short period. Additionally, the developed device is considered to produce current value with adequate precision and for adjusting automatically or manually according to the step/ramp function based. In the scientific literature, there are some publications related to this work; a current adjusting system with 0-20 kA level
[5]

, a current source with 10 mA DC for high current/power converters


[8]

[6, 7]

, a general purpose CMOS

current source , but none of them are directly intended to the 4-20 mA current loop. Implemented device in this work has a high precision within the mentioned current loop standard. This device is also capable of performing many functions such as transmitter, receiver, source and measurement related to this standard. Additionally, depending on this standard at analog level, a digitally interfaced microcontroller based system is developed. The main reasons for this are stable operation of digital systems, being less affected from environmental conditions (noise, heat, etc.), and also easier to use. Specifications of calibration devices In the first place, we investigate the properties of the commercial calibration devices - see figure 3.

Fig 3 Samples of commercial current loop calibrator.

The general properties of these devices are as follows:

Current production and reading in the interval of 4-20 mA 0-20 V operating voltage 0,001 mA resolution of current sourcing 0.012 % accuracy of current reading 9 V alkaline battery 240 V AC tolerance Indication of current level as percentage (%) on the LCD indicator (products with bar graphics are also exist) Usage with two lined transmitter Design of current loop calibration device Designed system is composed of numerical keypad, encoder, microcontroller, digital/analog converter (DAC), current sources, analog/digital converter (ADC) and LCD indicator - see figure 4. We use a PIC16F877 microcontroller for controlling the system. PIC16F877 is a microcontroller with 40 pins and property of 8-bit CMOS Flash. The reasons for choosing this microcontroller are having adequate number of input ports for LCD, keypad, and digital/analog converter, existing of a serial peripheral interface (SPI), having an interrupt property for the keypad, and having an internal analog/digital converter (ADC), and lastly being low cost.

Fig 4: Block diagram of the system. For the current source, a microcontroller controlled DAC with a current output at the interval of the 4 and 20 mA is needed. For this purpose, we use a digitally programmable AD420 chip having the specifications of the architecture with 16 bits precision, current output property and SPI interface. We also use an analog/digital converter to measure current. The analog/digital converter inside the PIC16F877 has a resolution of 10 bits and can measure voltage values at the interval of 0 and 5 V. Current is passed over 0.47 resistance and it is amplified to the level of 0-5 V by means of non-inverting amplifier. In addition, 4x3 numerical keypad and the 16x2 sized indicator of GDM1602B with HD44780 interface are used. Designed device has two modes: First mode produces current at the level of user entered value, and the other one reads the current that sensed from the external current loop. In the current source mode, the current information entered from keypad is sent to the microcontroller by analyzing with decoder. The current information determined by microcontroller is transmitted to the DAC within the SPI protocol and desired current value at the interval of 4-20 mA is produced. In the measurement mode, value of the external current loop, connected to the input is displayed on LCD indicator. Designed embedded software We develop the embedded software on the microcontroller by using Code Composer Studio (CCS) in PIC C language. The developed software on the microcontroller takes the information whether the calibration device will work within the current source or current measurement modes selected by the user. The flowchart of the prepared main program is seen in figure 5.

Click on image to enlarge.

Fig 5: Flowchart of the main program As seen in the main flow diagram, # key implements the task of cancel or delete and repeats this task. Additionally, * key has a function of turning back to main options at any time. Current source mode In current source mode, the embedded program runs according to the flow diagram in Fig 6. As seen in the flow diagram, at first, the user enters a current value with two digits to the left of decimal point and three digits to the right of decimal point (at precision of 0.1 %). If a wrong value is entered during the input phase, the user can undo this value by pressing # key. If a step base proceeding is of concern, then the proceeding can be done over the five step values: 4 mA, 8 mA, 12 mA, 16 mA and 20 mA.

Click on image to enlarge.

Fig 6: Flowchart of the current source program. After the current value is entered, the data is transferred to AD420 integrated circuit using SPI protocol for current generation process. Not only during the entrance of current value but also after the generation of that current value, the functionalities loaded to * and # keys do not change, but proceed. These functionalities:

At any condition whenever the * key is pressed; system returns to mode selection menu (main menu). At any condition whenever the # key is pressed; a clean screen comes up for entrance of current value. Once the third digit to the right of decimal point of current value is entered, the current is generated automatically and a sign OK is shown near the current value on LCD when the process is successful. If the user enters a current value out of the range, less than 4 mA and above the 20 mA; a warning message as Output range is exceeded is seen. Current measurement mode In current measurement mode, the level resulting from voltage amplification layer is read by the analog/digital converter and the measured current value is displayed on screen - see flowchart in figure 7.

Fig 7: Flowchart of the program for the current measurement mode. Keypad interrupt In keypad interface, we use the change on-state interrupt property of the PIC16F877 for sensing of key pressed. By means of this property, when the state is changed on the B input ports of the microcontroller, an interrupt is started automatically. Thus, when the device is not in use, the microcontroller passes to sleeping mode to save power. Current source and measurement As shown in figure 8, the digital outputs of the microcontroller are connected to a digital/analog converter circuit (AD420) with 16 bits CMOS current output using the interface of SPI protocol [9].

Fig 8: DAC block diagram. By this circuit, a current output value in the level of 4-20 mA (according to range selection) is acquired. SPI is a serial interface protocol of microcontroller that sends and receives 8 bits data synchronously [10]. For the current measurement, we use the analog/digital converter module inside the microcontroller. The conversion process is achieved over the resolution of 10 bits. We measure the current by passing the current over the 0.47 ohm resistance and then sending it to ADC on microcontroller. Sensitivity of the designed device The digital/analog converter (DAC) used in this study is at 16-bit resolution and this resolution is used at 4-20 mA range. We can determine the acquired current source sensitivity (Ss) at equation 1:

(1)

We can say that the change of 1 LSB in data transmitted to DAC is caused by a difference of 244.14 nA at the output. But, due to the fact that current value only can be entered as 3-digit after comma, current sourcing resolution is 0.001 mA. We can adjust this precision value on embedded software. To achieve the current measurement, current is passed over a very low-value resistance, and then the voltage over this resistance must be measured. During the current measurement, the current measurement device is connected serially to the circuit. So, it is expected that the internal impedance of the device does not affect the circuit or that at least, the effect of that impedance is very low. In this work, for the current to voltage conversion, we use a resistance of Rx = 0.47 . As a result of using the low-value resistance, the acquired voltage level (Vacq) at the maximum current level (Imax = 20 mA) is to be very low (see equation 2).

(2) In order to increase this low voltage level to 0-5 V, we design a non-inverting amplifier circuit with LF351. The gain of this amplifier (G) is calculated by equation 3, and here V o defines output voltage, and Vi defines input voltage.

(3) As a result, the resolution resulted in to 10-bit during the implementation of current measurement, and we can calculate the measurement sensitivity (Sm) as seen in equation 4.

(4) This value corresponds to a high enough sensitivity value for 4-20 mA range. But, due to the characteristics of operational amplifier used and noise effects, this sensitivity ratio decreases. At the end of the digital/analog conversion process, a current with analog DC level is obtained. But, for this obtained current to drive the connected load and to keep the linearity; there exist some maximum limits. One of these limits is current loop voltage compliance. This terminology describes the maximum voltage projected over the load that can be connected to current output. During the first experiments, we have used DAC908. This integrated circuit has some features as fast speed, 8-bit resolution for output current. The output compliance limit for this integrated circuit is between -1.0 V and +1.25 V. This means a maximum of 1.25 V / 20 mA = 62.5 load resistances can be connected to current output. In this case, this value is too low for a process control system using voltage of 24 V for the current loop. Additionally, this integrated circuit is a fast speed DAC. Thus, due to this high operation frequency, it is hard to acquire this frequency levels. Because of all the mentioned reasons, instead of that integrated circuit, we decide to use AD420 which is another digital/analog converter. Basic properties of the designed device The internal parts of designed calibration device are seen at figure 9. The input and output range of the designed device is 4-20 mA. The current output error is 1 nA in the experiments done at the room temperature. The maximum load drive capacity is 600 for 12 V loop voltage. For the 4-20 mA current production range, 24 V operating voltage level is required. The externally applicable loop voltage is 32 V at maximum. Total cost of the implemented calibrator is about 50-100 USD. As a result, a considerable benefit is gained regarding to the cost of device.

Fig 9: An overview of designed calibration device. The designed device has only English language support for now. We can make the following improvements on the next stage; display with percentage mode, multiple language support, and input by a touchpad. The parameters of the developed device are summarized at Table 1.

Table 1: Parameters of designed device Conclusions In this study; we designed and implemented a low-cost current loop calibration device which has 0.001 mA resolution. This device is used to test and calibrate the systems communicating with 4-20 mA current standard. Current loop is an important factor for industrial control applications; because by this way, signals are transmitted to remote distances being less affected from noise. The developed device can be used to simulate the sensors for the setups in which 4-20 mA current loop is used. Although the commercial value of the calibration devices is up to $ 2000; as a result of this study, the designed device costs about $ 50-100. The designed device is based on microcontroller. It has a LCD display and a digitally controlled keypad, and it is capable of generating and measuring signals at the 4-20 mA standard for the systems that have two-wired connection. References

[1] S. Sams, and J. Lyday, Implementing a 4-mA to 20-mA Current Loop on TI DSPs, Application Report (SZZA045), Signal Processing Solutions/Semiconductor Group, Texas Instruments, USA, January 2004. [2] DATEL Inc., 420mA Current Loop Primer, Datel Application Note (DMS-AN20), USA, http://www.datel.com/data/meters/dms-an20.pdf, accessed August 2009. [3] D. Sheepard, Build Your Own AutoCal/Automatic Loop Calibrator, Shepard Engineering Concepts, 1999, http://home.att.net/~dennis.shepard, accessed: August 2009. [4] M. Moller, How They Work: The 420mA Current Loop, sensorland.com, http://www.sensorland.com/HowPage028.html, accessed: August 2009. [5] G. Fernqvist et al., A Novel Current Calibration System up to 20 kA, IEEE Transactions on Instrumentation and Measurement, 2003, 52, (2), pp. 445-448. [6] G. Fernqvist et al., Design and Evaluation of a 10-mA DC Current Reference Standard, IEEE Transactions on Instrumentation and Measurement, 2003, 52, (2), pp. 440-444. [7] P. N. Miljanic, Calibrator for Alternating Voltage, Current, and Power, IEEE Transactions on Instrumentation and Measurement, 1989, 38, (2), pp. 384-389. [8] O. Cerid et al., Novel CMOS Reference Current Generator, International Journal of Electronics, 1985, 78, (6), pp. 1362-3060. [9] Analog.com, AD420 Datasheet (Rev. G), Analog Devices, Inc., 2009. [10] Microchip.com, PIC16F877 Microcontroller Datasheet (DS30292C), Microchip Inc., 2001. Acknowledgement Authors thank to Sleyman Demirel University, Scientific Research Projects Coordination Center for the financial support of this work under the grant #1022-M-05. About the authors: Dr. Hakan ALI and Dr. Abdlkadir AKIR are professors in the Department of Electrical and Electronics Engineering at Sleyman Demirel University in Isparta, Turkey. Frat YCEL ( fyucel@akdeniz.edu.tr ) is a lecturer in the Department of Informatics at Akdeniz University in Antalya, Turkey. Also, he is a PhD student in Department of Electrical and Electronics Engineering at Pamukkale University in Denizli, Turkey. --------------------------------------------------------------If you found this article to be of interest, visit the Micocontroller Designlinewhere you will find links to relevant technical articles, blogs, new products and news. You can also get a weekly newsletter highlighting the latest developments in this sector - just Click Here to request this newsletter using the Manage Newsletters tab - if you aren't already a member you'll be asked to register.

You might also like