## Getting in the loop – simple math for good analog values

Imagine this: You have your analog flow meter all set up. Confidently, you flip the switch – but the readings are off. So you tinker with it – a lot. But they’re still off. Now, you’ve done everything you know to do. You need to get this thing working so you can get your process running.

What do you do? Who do you call for help? Why did this even happen?

Many times, customers ask how to get accurate readings for analog output devices. Often, these customers need to know the basics of analog current loops and how they integrate into their particular processes.

So today, we’ll go over this protocol step by step to dispel the confusion and get you going.

### How do you determine flow rate?

Sometimes we need to find the flow rate (or temperature or pressure) without looking at the meter’s display. You can do this with:

• RS-232 serial commands
• Modbus, HART, or other supported digital protocols
• Analog support within the meter

### What is a 4-20mA loop?

A 4-20mA loop is a means to pass a value, like flow, using an established electrical current (the loop) as the carrier of this data.

A loop has five parts:

1. Sensor – provides the value

2. Transmitter – converts the value into a meaningful analog value

3. Power source – provides the direct current that the transmitter uses

4. Loop – sends the value on its way, usually through wires

Generally, four milliamps (mA) represents the minimum or low value. And 20 mA represents the maximum or high value, sometimes called full scale, of the value the sensor sends.

### How do you map the loop to the flow rate?

Many people overthink the math for finding this value,  treating it like calculus. The math is pretty simple, once you understand the values in the equation.

For our example, four mA represents zero flow, and 20 mA represents full flow. So, if our setup has a range of zero to 1000 standard liters per hour, the four means zero, and the 20 means 1000. With me so far?

### The variables in the equation

We can represent the flow range using the following notations:

mALow = 4  mA

mAValueLow = 0 (value that represents “low” or no flow)

mAHigh = 20 mA

mAValueHigh = 1000 (value that represents “high” or full flow)

Now if we have 500 flowing, we write it like this:

currentValue = 500

Because we know that the value we want on the loop is really a ratio of mALow to mAHigh, we apply this formula to find the correct mA we need:

((20 – 4) * ((500 – 0) / (1000 – 0))) + 4((mAHigh – mALow) * ((currentValue – mAValueLow) / (mAValueHigh – mAValueLow))) + mALow

((20 – 4) * (500 / 1000)) + 4

((16) * (0.5)) + 4

(8) + 4

mA_Value = 12

So, in our example, with 500 flowing, we get 12 mA on the loop. If we had zero flow (currentValue = 0), we would calculate it as:

((mAHigh – mALow) * ((currentValue – mAValueLow) / (mAValueHigh – mAValueLow))) + mALow

((20 – 4) * ((0 – 0) / (1000 – 0))) + 4

((20 – 4) * (0 / 1000)) + 4

((16) * (0)) + 4

(0) + 4

mA_Value = 4

If we had full flow (currentValue=1000), then we would calculate:

((mAHigh – mALow) * ((currentValue – mAValueLow) / (mAValueHigh – mAValueLow))) + mALow

((20 – 4) * ((1000 – 0) / (1000 – 0))) + 4

((20 – 4) * (1000 / 1000)) + 4

((16) * (1)) + 4

(16) + 4

mA_Value = 20

### How would you calculate a 0-20mA loop instead of a 4-20mA loop?

If we wanted to scale from zero to 20 instead of four to 20, all we do is change the value of mALow to zero instead of four! The same formula works. Remember that. Nothing changes except the values of the variables.

mALow = 0 mA

mAValueLow = 0 (value that represents “low” or no flow)

mAHigh = 20 mA

mAValueHigh = 1000 (value that represents “high” or full flow)

So, at 500 (currentValue = 500) on a 0-20mA loop, we set the loop to:

((mAHigh – mALow) * ((currentValue – mAValueLow) / (mAValueHigh – mAValueLow))) + mALow

((20 – 0) * ((500 – 0) / (1000 – 0))) + 0

((20 – 0) * (500 / 1000)) + 0

((20) * (0.5)) + 0

(10) + 0

mA_Value = 10

### How would we scale something that doesn’t have a low value of zero?

When we deal with temperature in Fahrenheit, we generally start at 32 instead of zero. So just adjust the mAValueLow to the new low value. Again, that’s it! Let’s assume we have our range from 32 to 132 degrees:

mALow = 4 (4mA)

mAValueLow = 32 (value that represents “low” or no flow)

mAHigh = 20 (20mA)

mAValueHigh = 132 (value that represents “high” or full flow)

Now we apply the same formula. So if we have 82 degrees (currentValue = 82), go through the following to find your value:

((mAHigh – mALow) * ((currentValue – mAValueLow) / (mAValueHigh – mAValueLow))) + mALow

((20 – 4) * ((82 – 32) / (132 – 32))) + 4

((20 – 4) * (50 / 100)) + 4

((16) * (0.5)) + 4

(8) + 4

mA_Value = 12

### Bringing it all together

Okay, time for a wrap-up! To summarize, use the following formula to determine the values for a 4-20 mA system:

mALow = 4 (4mA)

mAValueLow = 0 (value that represents “low” or no flow)

mAHigh = 20 (20mA)

mAValueHigh = 1000 (value that represents “high” or full flow)

currentValue = 500 (the value we want to send to the loop)

mA_Value = ((mAHigh – mALow) * ((currentValue – mAValueLow) / (mAValueHigh – mAValueLow))) + mALow

### Fine tuning the signal

At this point, we can find the correct value for an analog signal. But what happens if we have no flow and the output should say four, but the receiver say 3.90 mA? Then we need to tune the low value higher to reach four. So we would need to change the default digital-to-analog converter (DAC) value.

### DACs and their place in the loop

If we want a transmitter to send an analog signal, then it needs to know exactly how much to send. Thus, you can think of the DAC as a virtual valve that can go from totally closed to totally open or anything in between.

The range from closed to fully open goes through 4096 steps, meaning that each step opens the valve by 1/4096 in size.

By setting the DAC to one, we open the valve 1/4096 to represent  four mA. So setting the DAC to 2048 (2048/4096 = ½) will open the valve exactly halfway, and setting the DAC to 4096 will open the valve fully.

By adjusting the DACs, we can fine-tune the the loop. And when we have fine-tuned the DACs, the system will correctly calculate the points between.

### Conclusion

By setting the correct values and adjusting any DACs, you can make the meter provide the correct readings. And now you have the math to set those values and make those adjustments.

Original content here.

Author: Kam Bansal, Dir. of Engineering @ Sierra Instruments

Recommended articles