Scaling Function

Manoj M

Member
Join Date
Feb 2014
Location
London
Posts
59
Hello Experts,
I am using Step 7 V5.5 Sp4 for my project. In my project, I was scaling 4-20mA signal to -180 to 180. As of now it sounds like a liner function but the customer has changed the specifications.
The signal which is available now is 4.11mA to 19.89mA and the range has changed to -152 to 180. For your reference I have attached the table.
As you can see from the table after 5.24mA the display value is not changing and it stays on -152. I have managed to write the code for this.
My concern is the positive side, as you can see after 19.56 mA the remote joystick position is changing in 0.5 degree but the actual display is changed by 1 degree.
As of now my scaling function is showing me the range from -152 to +175 but in actual it should show -152 to +180.
I hope I am making some sense.
Appreciate your comments/feedback.

Regards
Manoj
 
Is it still linear? Yes, so f(x) = mx + b

You have two points from the function? Yes.

So, slope m = (y2 - y1) / (x2 - x1) = ( 180 - (-152) ) / ( 19.89 - 4.11 ) = 332 / 15.78 = 21.0392902408

So far, we've got f(x) = 21.0392902408x + b

Inserting an ordered pair from above: 180 = 21.0392902408( 19.89 ) + b

b = 180 - 21.0392902408( 19.89 ) = 180 - 418.4714828897 = -238.4714828897

Putting that together, f(x) = 21.0392902408x - 238.4714828897

Checking random inputs:

f( 4.11 ) = 21.0392902408( 4.11 ) - 238.4714828897 = -152

f( 4.27 ) = 21.0392902408( 4.27 ) - 238.4714828897 = -148.6337135615

f( 7.56 ) = 21.0392902408( 7.56 ) - 238.4714828897 = -79.4144486693

...

f( 19.89 ) = 21.0392902408( 19.89 ) - 238.4714828897 = 179.9999999998

Where did my remaining 0.0000000002 go? :confused: ;)
 
Last edited:
Thanks Jeremy for putting so much effort.
If you please look into the excel sheet, @5.24mA the angle reaches -152 and after that it doesn't matter if it goes to 4.11mA the value remains same as -152 and like I mentioned earlier, I have already written that part and there is no problem in it. For me the concern is the positive side.

Regards
Manoj
 
Without knowing which calculation has been used, there's really no way for us to tell what goes wrong.
For instance, what is the raw data supplied by the AI-card for the values you're testing?
 
Hi Jeebs,
The data supplied by AI card is 0-27648 for 4-20mA signal and I have tried a code which is working(I hope). First of all what I have done is scaled 4-20mA signal into -180 to 180. So when the data reaches 2150 [(27648/360)*28] which is equivalent to 5.24mA then and the angle is -152, here I stopped scale function and the value remains -152 for rest of the signal. That is anyway for the negative side. And now for the positive side when it reaches 169 which is equivalent to 26803 [(27648/360)*349] from AI card, then another loop kicks in and do the following

L 27320 (27320 are the maximum number for the mA signal available)
L PIW274
-I
T MW56
L MW56
L 47 ----((27320-26803)/(180-169))
/I
T MW54
L 180
L MW54
-I
T ACTUAL ANGLE

I hope it makes some sense and anyway I have tried this logic and it is working fine.

Regards
Manoj
 

Similar Topics

Hi all, i am trying to scale a 0 - 1000 analogue input to a -10000 to 10000 output with 0-500 been -10000 to 0 and 501-1000 to 0-1000 is there...
Replies
7
Views
2,898
Hi All Omron Experts I need help to create a FB for Omron PLC CP1L-E Task: Detect and Monitor Oil Level in a Hyd. Tank Using Incorporated...
Replies
1
Views
1,746
Hi Friends, Please, who can tell me the Function Block used for scaling 4-20mA to say 0-200PSI in Mitsubishi GX Works3?
Replies
6
Views
7,319
Hello Experts, Need your advice on this. I am using Step7 V5.5 SP4 for my programming. I am using FC105 scaling function to scale 4-20 mA signal...
Replies
7
Views
2,274
I have written a scling block to scale real values in the PLC code to integers for use on analogue output blocks, I want the scaling block to...
Replies
4
Views
2,335
Back
Top Bottom