Twido PLC - How to use 0-20mA Analog card with 4-20mA device or sensor

Twido PLC - How to use 0-20mA Analog input card with 4-20mA sensors or devices


Description:
The following describes conversion using 0-20mA Twido analogue input modules with sensors or devices working in 4-20mA range.
ANY Hardware Twido controller supporting floating point data type:
TWDLMDA20DRT
TWDL●●● 40D●●
Analogue input modules:
TWDAMI8HT  8 Input Analog channels 10bit resolution
TWDAMI4LT  4 Input Analog channels 12bit resolution
Twidosoft & firmaware 3.5
Windows XP SP2

1. Line Theory - Conversion background
The conversion of input current to value is linear. Characteristics can be described using linear equation
f(x)=m*x+c. Where m=slope and c=y intercept (y intercept , where the line cross the y axis)
Conversion consists of changing the slope m, and y-intercept c.

Figure 1 Characteristics of 0-20mA and 4-20mA analog I/O modules with 10bit resolution

Conversion for 4-20mA device connected to 0-20mA input
TWDAMI8HT - 10bit, normal range and TWDAMI4LT – 12bit,

Where :
Value(scaled) = The rescaled value at 0-20mA 
Value(meas) = The measured value
RangeXmax = 1024 for TWDAMI8HT & 4096 for TWDAMI4LT
RangeXmin = 0

Twido Analog Configuration and Program :

We Select TWDLCAA40DRF CPU and the Analog module TWDAMI8HT










Figure 2 Twidosoft application - Conversion for 4-20mA device connected to 0-20mA input with 10bit resolution and error (Sensor Fault) check

In case %MW100 is negative, it’s set to 0. This prevents %MW100 from reaching negative value when the measured current is lower than 4mA.
If the wire to the 4-20mA device is broken, current drops to 0. This state is detected in the application. The threshold for detection of the error can be altered; value 100 is used as an example.

The above approach is not neccessary for Micro TSX37 Analog cards as they could be configured to be used as 4-20mA or 0-20mA inputs
(TSXAEZ802 - TSXAEZ414 - TSXAMZ600)

3. Summary

Using this algorithm will allow to connect devices with 4-20mA analogue output to TWDAMI8HT and TWDAMI4LT 0-20mA analogue inputs. However, it will lower effective resolution of analog input by 20% since only 4-20mA from 0-20mA range is used effectively. Maximum error caused by conversion from float to integer is lower than 0.1% from the full scale

NOTE : It's your rensponsibility to use this example properly in your applications