Author Topic: Input scaling  (Read 15883 times)

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Input scaling
« on: August 08, 2012, 01:54:26 PM »
Hi,

I'm trying to read a PT100 via a 4-20 converter but i'm getting the wrong reading.

The converter is scaled 4-20mA, 100Ohm to 198Ohm = 0 to 260 DegC.

I process the 4-20 via a 250 Ohm resistor to get 0-5V

as I see it 260 / 5 (0-5V input) = 52

B = ADC(1)* (2600+520)/4096 - 520

but to get a sensible reading I need to use 650 not 520 but I cannot calculate why??

B = ADC(1)* (2600+650)/4096 - 650

The usable range of the input is 1 - 5 Volts = 0 to 260 deg C as the converter sends out 4-mA as a minimum so I guess this is where my conversion is going wrong!

Any thoughts?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Input scaling
« Reply #1 on: August 08, 2012, 04:29:42 PM »
Your formula don't look right.

Assuming ADC reading = A.  Temperature = T

T = 0  => 4mA => A = 4/20*4096 = 819
T = 260 => 20mA => A = 4096

Linear relationship:

(A - 819)/4096-819) = (T - 0)/(260 - 0)

=> T = (A - 819)*260/3277

You can substitute value of A = 819 and A = 4096 in the above formula to verify that the resulting T is correct with given A.
 
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:Input scaling
« Reply #2 on: August 09, 2012, 12:56:41 AM »
Hi Thanks,

I went down the road of B = ADC(1) * 2600/(4096-819), but was getting the wrong values again.

Thanks for the assistance.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Input scaling
« Reply #3 on: August 09, 2012, 01:14:17 AM »
It should be:

B = (ADC(1)-819) * 2600/(4096-819)
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:Input scaling
« Reply #4 on: August 09, 2012, 01:26:27 AM »
Hi,

I used the example which works but yours is more efficient so thanks again! :)

B = ADC(1)
B = (B - 819)*2600/3277

Ruaidhri

  • Newbie
  • *
  • Posts: 2
  • I'm a llama!
    • View Profile
Re:Input scaling
« Reply #5 on: June 21, 2014, 04:26:58 AM »
Hi Guys
Im delighted i came across this in the forum I have been struggling with a similar problem, however reading your solutions really helped.
the problem i have now is i am not getting the expected value back from my adc.
the probe i am using is a -40 to +150 type
so using the same formula and I am assuming its between 16-20 degrees here....
my expected value at adc should be ((t+40)/190)*3277+819 = 1853 for 20 degrees and 1784 for 16 degrees
but i am only getting a value of 1504 at the adc.
I have checked and rechecked everything and the only thing i can find is the resistor is 248ohm instead of 250ohm and im not sure if this will affect my value.(reading via meter).
i am a complete beginner to all of this so sorry if this seems like a remedial problem!
Thanks in advance!
Ruaidhri
also where did you get the value of 2600?

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Input scaling
« Reply #6 on: June 21, 2014, 08:14:30 PM »
The use of the 248 Ohm resistor will result in an error of about 2.5%.  This probably is not the source of your problem.

Your equation is about correct.  An ADC reading of 1504 is pretty close to 0C.  I'm guessing that the RTD was not sitting in an ice bath.

I would suggest that you make two temperature readings: one at 0C (ice bath) and the second at 100C (boiling water).  With these 2 data points we can calibrate your system.  With a single point, I can't make much of a guess as to what is wrong.

This is a picture of what I'd expect if your RTD/4-20 mA transmitter were working as you described.

As an aside, the relation between Temperature and ADC readings if your system was working as described is as follows:

    y = 0.058X - 87.5

where:
   y is temperature in degrees C
   x is ADC readings in the range of 0..4095

Be aware that this equation will have to be scaled to work with TBASIC as it does not support floating point (except on the newest PLCs).

Gary D.
« Last Edit: June 21, 2014, 08:24:49 PM by garysdickinson »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Input scaling
« Reply #7 on: June 23, 2014, 02:19:10 PM »
What don't you take a meter to measure the voltage at the ADC inputs and the reference input and you can then verify if the voltage reading match what you are expecting.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS