FC105 scaling strangeness

dwoodlock

Lifetime Supporting Member
Join Date
Nov 2012
Location
Cincy/nKY
Posts
548
So I've got a machine using a 4-20ma pressure transducer into a 12bit analog card on a s7-315

The OE transducer had to be replaced, and when we inquired with the manufacturer of the part they said that transducer was no longer available, and had been changed to ##### model which is functionally and physically the same, but has a great increase in range.

Original
0-5.2bar

newer equivalent
0-28.4bar

So the OEM used fc105 to do the scaling of the input, and even after reading the siemens description of the function im a little confused with how it was setup.

Original configuration:
PIW268
in0 =300
in1 =-300

After we replaced it with the 28.4bar newer sensor the analog input was reading in the 12XXX range at atmosphere.

I started manipulating the values in in0 and in1 to make it end up with a zero result in out4 because when the machine starts it needs to be reading atmosphere.

I ended up with
in0=27.648
in1=12.4

This may be completely wrong and I fully acknowledge that.

My problem is that I am struggling to make sense of why they did 300 to -300 in the original setup.

According to the siemens document:
Configured measuring range of 4 to 20mA (0 to 5 bar)
Example:
The integer value 27648 corresponds to 20mA and thus 5 bar in this example. The integer value 0 corresponds to 4mA and thus 0 bar in this example. Therefore, you should parameterize the high limit HI_LIM to 5.0 and the low limit LO_LIM to 0.0 to obtain correct scaling.

After reading this I initially set the min max according to the sensor, but that didn't seem to work at all.

Any pointers or education on this would be great, thanks in advance.
 
If it is Siemens card, then raw data (PIW) should be on scale 0..27648 which is scaled to real type.


http://www.plctalk.net/qanda/showthread.php?t=119238




Which AI card you have, is it for s7-300 rack or newer car type from ET-range?

card is a 331-7kf02-0ab0

The biggest confusion to me is why they have used 300 and -300. I figured if I could make sense of the way they did it, I could then figure out how it needed to be adapted.
 
My confused guess is that you wouldn't get 0 from whatever it is reading now. I would think you would take the value from the sensor when the system is at rest (say, maybe on machine power on), and save that off. Then you calculate the offset from nominal by subtracting the saved value from the actual value. It's possible the sensor takes care of that for you, though.

What I would ACTUALLY expect to work based on your info is to set the High lim to 28.4 and the low lim to 0. However, you would need to check the specs of your sensor to see how it outputs the signal. I've seen sensors that try to do internal scaling, and max range doesn't end up where you expect it.


The fact that the previous code was using +-300, and presumably working, says that there must be something else going on. Can you say the old/new part numbers of the sensor?
 
Alright so after taking another crack at it, I ended up with what seems to work.

Its very odd and not what Siemens described, but the machine is now creating distillate properly.

Basically I tried all the suggestions, and was able to figure out eventually that the maximum value in In1 was critical that it remain the same.

so when I changed this value, the pressure in the machine displayed as 50mbar, this quickly became obvious was not good, because the higher the mbar the higher it spins the vapor compressor. Thankfully ours has forged lobes, or we could have been in trouble at this point.

The settings I ended up with are

in1:300
in2:-59

I tried using the 28.4-0, and 27.648-0, even went back to 300 - -300.

I then finally tried 300-0 and the output value was 59ish. I then proceeded to change the minimum to -59 and voila it was at zero, and because the maximum value is identical to the other original sensors, they all seem to interact in a linear fashion, without the new one being out of scale in reference to the other originals.

Anyway its running now, gonna watch it for a while and see how it goes.
 
For reference, here is the help for FC105:


Code:
Scaling Values: FC105

Description

The SCALE function takes an integer value (IN) and converts it to a real value in engineering units scaled between a low and a high limit (LO_LIM and HI_LIM). The result is written in OUT. The SCALE function uses the equation:
    OUT = [ ((FLOAT (IN) – K1)/(K2–K1)) * (HI_LIM–LO_LIM)] + LO_LIM
The constants K1 and K2 are set based upon whether the input value is BIPOLAR or UNIPOLAR.
·    BIPOLAR: The input integer value is assumed to be between –27648 and 27648, therefore, K1 = –27648.0 and K2 = +27648.0
·    UNIPOLAR: The input integer value is assumed to be between 0 and 27648, therefore, K1 = 0.0 and K2 = +27648.0

If the input integer value is greater than K2, the output (OUT) is clamped to HI_LIM, and an error is returned. If the input integer value is less than K1, the output is clamped to LO_LIM, and an error is returned.

Reverse scaling can be obtained by programming LO_LIM > HI_LIM. With reverse scaling, the value of the output decreases as the value of the input increases.

FC105 Parameters

Parameter    Declaration    Data type    Memory area    Description    

EN    Input    BOOL    I,Q,M,D,L    Enable input with signal state of 1 activates the box.    

ENO    Output    BOOL    I,Q,M,D,L    Enable output has a signal state of 1 if the function is executed without error.    

IN    Input    INT    I,Q,M,D,L,P, Constant    The input value to be scaled to a real value in engineering units.    

HI_LIM    Input    REAL    I,Q,M,D,L,P, Constant    Upper limit in engineering units.    

LO_LIM    Input    REAL    I,Q,M,D,L,P, Constant    Lower limit in engineering units.    

BIPOLAR    Input    BOOL    I,Q,M,D,L    A signal state of 1 indicates that the input value is bipolar. A signal state of 0 indicates that the input value is unipolar.    

OUT    Output    REAL    I,Q,M,D,L,P    Result of the scale conversion.    

RET_VAL    Output    WORD    I,Q,M,D,L,P    Returns a value of W#16#0000 if the instruction executes without error. See Error Information for values other than W#16#0000.    


Error Information

If the input integer value is greater than K2, the output (OUT) is clamped to HI_LIM, and an error is returned. If the input integer value is less than K1, the output is clamped to LO_LIM, and an error is returned. The signal state of ENO is set to 0 and RET_VAL is equal to W#16#0008.
 
It would be better if you found out how it works and why.

There is no way that FC105 can produce these results. -300..+300 and the sensor is actually 0..28.4

And this bit also do not make much sense:
and because the maximum value is identical to the other original sensors, they all seem to interact in a linear fashion, without the new one being out of scale in reference to the other originals
You replaced a 0-5.2 Bar sensor with a 0-28.4 Bar sensor, and by manipulating the minimum scaled value you got it to work !?
I think that possibly you have it work only around the working point.

I would measure the mA signal, and simultanously observe the raw unscaled value, and the scaled value coming from FC105.
 
One odd possibility.
Maybe FC105 is NOT the Siemens library function but another scaling block made by someone else.
Neither FC105 or the symbolic name "SCALE" are fixed. It is possible to make a block with the same FC number and the same symbolic name.
Conversely, it is possible to copy the siemens library block to another FC number and give it a different symbolic name.
 
One odd possibility.
Maybe FC105 is NOT the Siemens library function but another scaling block made by someone else.
Neither FC105 or the symbolic name "SCALE" are fixed. It is possible to make a block with the same FC number and the same symbolic name.
Conversely, it is possible to copy the siemens library block to another FC number and give it a different symbolic name.


Fair point. It also seemed odd that he was referring to in1/in2 vs Hi_lim/Lo_Lim.


I'd still need to see data sheets on the sensors to be able to say anything for sure. Agree that we all seem to be missing something.
 
Well it seems this is a custom block. thanks for the pointers.

I assumed you wouldn't be able to use another FC105 since it was a Siemens block, but I guess if you don't drop their block in the program it doesn't care.

Of course its protected so it wont let me see what's going on inside, but I'll keep tweaking 'til I get it working correctly.
 
I think the simplest way would be for you to create a scaling block of your own.

It wouldn't take but 10 min, then you know how it works, an you can make it work how you want.
 

Similar Topics

Hi Guys , I have one little problem I try to write ladder diagram using Fc105 using simatic manager simulator and every time i make the program...
Replies
11
Views
2,342
I used FC105 for scaling analog inputs and I (renamed it) as I read advices here in order to not override the original function. Anyway I...
Replies
6
Views
2,792
Hi Site, I have recently come a cross a problem and I am searching for anyone with experience of this. I am using a scaling function of...
Replies
3
Views
4,473
hey mates, I'm new in plc programming and I'm experiencing a problem on using the fc105 scale. When I'm trying to simulate the program it suddenly...
Replies
3
Views
1,969
Hi there I got confused so this question: I have got thermocouple connected to the AI. Iam using FC105 to scale the values into Engineering value...
Replies
12
Views
3,941
Back
Top Bottom