İşin matematik formülü kopyaladım, PIW giriş ADC den integer tipinde ham datadır, bu mantıkla kullanılan dilde kod olarak yazılabilir,,,
Y2 and Y1 are your limits, 160 and 70 (Both REAL values)
X1 and X2 and predifined PIW values.
Your range 4-20mA is from 0 to 27648 INT.
SO you say when I receive 4mA (number 0) I want to be 70(real) That means X1 is 0 and Y1 is 70
If you want maximum value 20mA to be 160 then Y2 is 160 and X2 27648.
BAsically you keep X1 and X2 almost always fixed 0 and 27648 (4-20mA) and you just change limits(Y1, and Y2 in your case 160 and 70)
In your example if you receive Analog input 12mA and thats 13824
PIW = 13824
X2 = 27648
X1= 0
Y2 = 160
Y1 = 70
Y = ( Y2 - Y1 ) / ( X2 - X1 ) * ( PIW - X1 ) + Y1
Y = (160-70)/(27648-0)*(13824-0) + 70 = 115
115 is midle between 70 and 160 same as 12mA is middle between 4mA and 20mA