: 2021-01-05

: komatic

: SCL



diameter



/ .

, .



Sources taken from : SIMATIC Winder and Tension Control



1: Diameter calculation after division method v/n
2: Diameter calculation with thickness addition
3: Diameter calculation after integral method



:
, :

diameter := FILTER(lineVelocity) / FILTER(shaftSpeed) * gearRatio;


shaftSpeed -
lineVelocity -
gearRatio - ( )
FILTER -



-
-



:



//------------------------------------------------------------------------------
//SIEMENS AG I DT MC PMA APC / Erlangen, Germany | Norcross, Georgia. USA
//------------------------------------------------------------------------------
//functionality : V/N diameter Calculation
//assignment : OB3x
//------------------------------------------------------------------------------
//change log table:
//version date expert in charge changes applied
//01.00.00 30.11.2011 APC Converting group Creation
//01.00.02 13.03.2014 APC Converting group Bugfix
// - calculation of diameter with imperial units fixed
//==============================================================================
FUNCTION_BLOCK DiamCalcDivision
TITLE ='ID: 5101 - Diameter calculation after division method v/n'
VERSION:'1.0'
AUTHOR :'APC'
NAME :'DiamDiv'
FAMILY :'CONV_LIB'

CONST
// Unit identification
UNIT_ID := 16#5101_0000;

// Constant PI
PI := 3.141592;

DINT_SCALE := 1073741824.0;
INT_SCALE := 16384.0;
PERCENT_SCALE := 100.0;

//Error: NO_ERROR
//Reason: No error
NO_ERROR := 16#0000_0000;
 
//Error: WRONG_TASK
//Reason: Function block is assigned to an invalid task
WRONG_TASK := 16#0000_8001;

//Error: INVALID_CONFIG_DATA
//Reason: One or more configuration values are invalid
INVALID_CONFIG_DATA := 16#0000_8005;
END_CONST
 
VAR_INPUT
enable : BOOL := FALSE; // rising edge enables, falling edge disables FB
holdDiameter : BOOL := FALSE; //[-] Hold diameter Calculation
metricUnits : BOOL := True; //[-] True = Metric [MPM] False = English [FPM]
setDiameter : BOOL := FALSE; //[-] True = Set diameter to diameter set value
diameterSetValue : REAL := 1.0; //[m / in] diameter Set Value [M or inches]
lineVelocity : REAL := 0.0; //[LU/min] Actual Line Speed in MPM or FPM
shaftSpeed : REAL := 0.0; //[rpm] Actual shaft speed in RPM
minDia : REAL := 0.1; //[m / in] Minimum diameter Allowed
maxDia : REAL := 2.0; //[m / in] maximum diameter Allowed
minLineVelocity : REAL := 5.0; //[LU/min] Minimum line speed for calculation
minShaftSpeed : REAL := 5.0; //[rpm] Minimum shaft speed for calculation
lineFilterTime : REAL := 20.0; //[ms] Filter time
shaftFilterTime : REAL := 20.0; //[ms] Filter time
diameterFilterTime : REAL := 50.0; //[ms] Filter time i
END_VAR
 
VAR_IN_OUT
diameter : REAL; //[m / in] diameter latch
END_VAR
 
VAR_OUTPUT
busy : BOOL := FALSE;
error : BOOL := FALSE; //[-] FALSE: No Error TRUE: Error occured
errorID : DWORD := NO_ERROR; //[dword] Error identification

atMinDia : BOOL := FALSE; //[-] At minimum diameter
atMaxDia : BOOL := FALSE; //[-] At maximum diameter
END_VAR
 
VAR
LinePT1 : PT1;
ShaftPT1 : PT1;
DiameterPT1 : PT1;
RawDiameter : REAL;
tcyc : REAL;
enableOld : BOOL; // indicates 1st run of FB
END_VAR
 
VAR_TEMP
mySetDiameter : BOOL;
END_VAR
 
IF enable AND NOT(enableOld) THEN // init
atMinDia := FALSE;
atMaxDia := FALSE;
busy := FALSE;
error := FALSE;
errorId := NO_ERROR;
Tcyc := ReadCycleTime();
IF (minDia <= 0.0)
OR (maxDia <= 0.0)
OR (minDia >= maxDia)
OR (minLineVelocity <= 0.0)
OR (minShaftSpeed<= 0.0)
THEN
atMinDia := TRUE;
atMaxDia := TRUE;
error := TRUE;
errorid := UNIT_ID OR INVALID_CONFIG_DATA; // FB NO Valid Data return
ELSIF Tcyc = 0.0 THEN
atMinDia := TRUE;
atMaxDia := TRUE;
error := TRUE;
errorid := UNIT_ID OR WRONG_TASK; // FB NO Valid Data return
ELSE
busy := TRUE;
END_IF;
enableOld := enable;
RETURN;
END_IF;
IF NOT(enable) AND enableOld THEN // disable
atMinDia := FALSE;
atMaxDia := FALSE;
busy := FALSE;
error := FALSE;
errorId := NO_ERROR;
enableOld := enable;
RETURN;
END_IF;

IF busy THEN
mySetDiameter := setDiameter AND (ShaftPT1.y < minShaftSpeed);

//Filter the Actual Line speed
LinePT1(
set := mySetDiameter,
x := ABS(lineVelocity),
setValue := ABS(lineVelocity),
smoothingTime := lineFilterTime);

//Filter the Actual Shaft Speed
ShaftPT1(
set := mySetDiameter,
x := ABS(shaftSpeed),
setValue := ABS(shaftSpeed),
smoothingTime := shaftFilterTime);

// Check if above min speeds for calcualtions and not diameter Hold
IF (LinePT1.y >= minLineVelocity)
AND (ShaftPT1.y >= minShaftSpeed)
AND NOT holdDiameter
THEN
IF metricUnits THEN
RawDiameter := LIMIT(
MN:= minDia,
IN:= (LinePT1.y / ShaftPT1.y / PI),
MX:= maxDia);
ELSIF NOT metricUnits THEN
RawDiameter := LIMIT(
MN:= minDia,
IN:= (LinePT1.y / ShaftPT1.y / PI) * 12,
MX:= maxDia);
END_IF;
END_IF;

IF mySetDiameter THEN
RawDiameter := LIMIT(MN:=minDia, IN:= diameterSetValue, MX:= maxDia);
END_IF;

// diameter calculator filter
DiameterPT1(
set := mySetDiameter,
x := RawDiameter,
setValue := RawDiameter,
smoothingTime := diameterFilterTime);

diameter := LIMIT(MN:=minDia,IN:=DiameterPT1.y,MX:=maxDia);
atMinDia := (diameter = minDia);
atMaxDia := (diameter = maxDia);
END_IF;
END_FUNCTION_BLOCK











:
:

diameter := INTEGRAL(FILTER(shaftSpeed)) / 60.0 * webThickness * 2.0;


shaftSpeed -
webThickness -
INTEGRAL -
FILTER -



-
-



:



//------------------------------------------------------------------------------
//SIEMENS AG I DT MC PMA APC / Erlangen, Germany | Norcross, Georgia. USA
//------------------------------------------------------------------------------
//functionality : Turns Counter diameter Calculation
//assignment : OB3x
//------------------------------------------------------------------------------
//change log table:
//version date expert in charge changes applied
//01.00.00 30.11.2011 APC Converting group Creation
//==============================================================================
FUNCTION_BLOCK DiamCalcAddition
TITLE ='ID: 5102 - Diameter calculation with thickness addition'
VERSION:'1.0'
AUTHOR :'APC'
NAME :'DiamAdd'
FAMILY :'CONV_LIB'

CONST
// Unit identification
UNIT_ID := 16#5102_0000;

// Winding mode constants
REWIND_FROM_ABOVE := 0;
REWIND_FROM_BELOW := 1;
UNWIND_FROM_ABOVE := 2;
UNWIND_FROM_BELOW := 3;

//Error: NO_ERROR
//Reason: No error
NO_ERROR := 16#0000_0000;
 
//Error: WRONG_TASK
//Reason: Function block is assigned to an invalid task
WRONG_TASK := 16#0000_8001;

//Error: INVALID_CONFIG_DATA
//Reason: One or more configuration values are invalid
INVALID_CONFIG_DATA := 16#0000_8005;
END_CONST
 
VAR_INPUT
enable : BOOL := FALSE; // rising edge enables, falling edge disables FB
holdDiameter : BOOL := FALSE; //[-] False = No Hold, True = Hold diameter Calculation
setDiameter : BOOL := FALSE; //[-] False = No set, True = Set diameter to diameter set value
typeOfWinder : INT := REWIND_FROM_ABOVE; //[0-3]Type of winder 0-RfA,1-RfB,2-UfA,3-UfB
diameterSetValue : REAL := 1.0; //[m / in] diameter Set Value
webThickness : REAL := 0.001; //[m / in] Actual Web Thickness
minDia : REAL := 0.1; //[m / in] Minimum diameter Allowed
maxDia : REAL := 2.0; //[m / in] maximum diameter Allowed
minShaftSpeed : REAL := 0.5; //[rpm] Minimum shaft speed for calculation
shaftSpeed : REAL := 0.0; //[rpm] Actual shaft speed in RPM
shaftFilterTime : REAL := 20.0; //[ms] Filter time in ms
END_VAR
 
VAR_IN_OUT
diameter : REAL; //[m / in] diameter latch
END_VAR
 
VAR_OUTPUT
busy : BOOL := FALSE;
error : BOOL := FALSE; //[-] FALSE: No Error TRUE: Error occured
errorID : DWORD := NO_ERROR; //[dword] Error identification
atMinDia : BOOL := FALSE; //[-] TRUE = At minimum diameter
atMaxDia : BOOL := FALSE; //[-] TRUE = At maximum diameter
END_VAR
 
VAR
ShaftPT1 : PT1;
fbINT1 : Integrator;
Tcyc : REAL;
enableOld : BOOL;
END_VAR
 
IF enable AND NOT(enableOld) THEN // init
atMinDia := FALSE;
atMaxDia := FALSE;
busy := FALSE;
error := FALSE;
errorId := NO_ERROR;
Tcyc := ReadCycleTime();
IF (minDia <= 0.0)
OR (maxDia <= 0.0)
OR (minDia >= maxDia)
OR (webThickness <= 0.0)
OR (minShaftSpeed<= 0.0)
OR typeOfWinder < 0
OR typeOfWinder > 3
THEN
atMinDia := TRUE;
atMaxDia := TRUE;
error := TRUE;
errorid := UNIT_ID OR INVALID_CONFIG_DATA; // FB NO Valid Data return
ELSIF Tcyc = 0.0 THEN
atMinDia := TRUE;
atMaxDia := TRUE;
error := TRUE;
errorid := UNIT_ID OR WRONG_TASK; // FB NO Valid Data return
ELSE
busy := TRUE;
END_IF;
enableOld := enable;
RETURN;
END_IF;
IF NOT(enable) AND enableOld THEN // disable
atMinDia := FALSE;
atMaxDia := FALSE;
busy := FALSE;
error := FALSE;
errorId := NO_ERROR;
enableOld := enable;
RETURN;
END_IF;
 
IF busy THEN
//Filter the Actual Shaft Speed
ShaftPT1(
set := setDiameter,
x := shaftSpeed, // [ rpm ]
setValue := shaftSpeed, // [ rpm ]
smoothingTime := shaftFilterTime);

// Check if above min speeds for calcualtions and not diameter Hold
IF ((ABS(ShaftPT1.y) >= minShaftSpeed) AND NOT holdDiameter) OR setDiameter THEN
fbINT1(
set := setDiameter AND (ABS(ShaftPT1.y) < minShaftSpeed),
x := SEL(G := (typeOfWinder = REWIND_FROM_BELOW
OR typeOfWinder = UNWIND_FROM_ABOVE), // Invert counting to drive speed
IN0 := ShaftPT1.y/60 * ABS(webThickness) * 2.0, // FALSE
IN1 := ShaftPT1.y/60 * -ABS(webThickness) * 2.0), // TRUE
setValue := diameterSetValue,
upperLimit := maxDia,
lowerLimit := minDia,
integralTime := 1000.0);

diameter := fbINT1.y;
atMaxDia := fbINT1.upperLimitReached;
atMinDia := fbINT1.lowerLimitReached;
END_IF;
END_IF;
END_FUNCTION_BLOCK
 











:
:

diameter := LINEAR(INTEGRAL(FILTER(lineVelocity)) / INTEGRAL(FILTER(shaftSpeed)) * 2.0);


shaftSpeed -
lineVelocity-
LINEAR -
INTEGRAL -
FILTER -


- ...
- , , , :)



:



//------------------------------------------------------------------------------
//SIEMENS AG I DT MC PMA APC / Erlangen, Germany | Norcross, Georgia. USA
//------------------------------------------------------------------------------
//functionality : diameter Calculation Integral
//assignment : OB3x
//------------------------------------------------------------------------------
//change log table:
//version date expert in charge changes applied
//01.00.00 30.11.2011 APC Converting group Creation
//==============================================================================
FUNCTION_BLOCK DiamCalcIntegral
TITLE ='ID: 5103 - Diameter calculation after integral method'
VERSION:'1.0'
AUTHOR :'APC'
NAME :'DiamInt'
FAMILY :'CONV_LIB'

CONST
// Unit identification
UNIT_ID := 16#5103_0000;

// Constant PI
PI := 3.141592;
 
//Error: NO_ERROR
//Reason: No error
NO_ERROR := 16#0000_0000;

//Error: WRONG_TASK
//Reason: Function block is assigned to an invalid task
WRONG_TASK := 16#0000_8001;

//Error: INVALID_CONFIG_DATA
//Reason: One or more configuration values are invalid
INVALID_CONFIG_DATA := 16#0000_8005;
END_CONST
 
VAR_INPUT
enable : BOOL := FALSE; // rising edge enables, falling edge disables FB
holdDiameter : BOOL := FALSE; //[-] TRUE = Hold diameter Calculation
metricUnits : BOOL := True; //[-] TRUE = Metric [MPM] False = English [FPM]
setDiameter : BOOL := FALSE; //[-] TRUE = Set diameter to diameter set value
diameterSetValue : REAL := 1.0; //[m / in] diameter Set Value [M or inches]
lineVelocity : REAL := 0.0; //[LU/min] Actual Line Speed in MPM or FPM
shaftSpeed : REAL := 0.0; //[rpm] Actual shaft speed in RPM
minDia : REAL := 0.1; //[m / in] Minimum diameter Allowed
maxDia : REAL := 2.0; //[m / in] maximum diameter Allowed
minLineVelocity : REAL := 0.5; //[LU/min] Minimum line speed for calculation
minShaftSpeed : REAL := 0.5; //[rpm] Minimum shaft speed for calculation
lineFilterTime : REAL := 20.0; //[ms] Filter time in mS
shaftFilterTime : REAL := 20.0; //[ms] Filter time in mS
measuringRevolutionCount : REAL := 2.0; //[rev] Shaft Revolutions counts for valid data
END_VAR
 
VAR_IN_OUT
diameter : REAL; //[m / in] diameter latch
END_VAR
 
VAR_OUTPUT
busy : BOOL := FALSE;
error : BOOL := FALSE; //[-] FALSE: No Error TRUE: Error occured
errorID : DWORD := NO_ERROR; //[dword] Error identification
webThickness : REAL := 0.0; //[m / in] Calculated web thickness in units
atMinDia : BOOL := FALSE; //[-] At minimum diameter
atMaxDia : BOOL := FALSE; //[-] At maximum diameter
END_VAR
 
VAR
LinePT1 : PT1;
LineINT : Integrator;
ShaftPT1 : PT1;
ShaftINT : Integrator;
Radpersec : REAL;
RawDiameter : REAL := 0.1;
LastRawDiameter : REAL;
ResetIntegrators : BOOL;
LatchRawValue : BOOL;
Tcyc : REAL:= 0.0; // [ s ] saved cycle time
enableOld : BOOL;
END_VAR

IF enable AND NOT(enableOld) THEN // init
atMinDia := FALSE;
atMaxDia := FALSE;
busy := FALSE;
error := FALSE;
errorId := NO_ERROR;
webThickness := 0.0;
Tcyc := ReadCycleTime();
IF (minDia <= 0.0)
OR (maxDia <= 0.0)
OR (minDia >= maxDia)
OR (minLineVelocity <= 0.0)
OR (minShaftSpeed<= 0.0)
OR (measuringRevolutionCount <= 0.0)
THEN
atMinDia := TRUE;
atMaxDia := TRUE;
error := TRUE;
errorid := UNIT_ID OR INVALID_CONFIG_DATA; // FB NO Valid Data return
ELSIF Tcyc = 0.0 THEN
atMinDia := TRUE;
atMaxDia := TRUE;
error := TRUE;
errorid := UNIT_ID OR WRONG_TASK; // FB NO Valid Data return
ELSE
busy := TRUE;
END_IF;
enableOld := enable;
RETURN;
END_IF;
IF NOT(enable) AND enableOld THEN // disable
atMinDia := FALSE;
atMaxDia := FALSE;
busy := FALSE;
error := FALSE;
errorId := NO_ERROR;
webThickness := 0.0;
enableOld := enable;
RETURN;
END_IF;

IF busy THEN
//Filter the Actual Line speed
LinePT1(
set := setDiameter,
x := lineVelocity,
setValue := lineVelocity,
smoothingTime := lineFiltertime);
// integrate smoothed lineSpeed
LineINT(
set := ResetIntegrators,
x := LinePT1.y / 60.0,
setValue := 0.0,
upperLimit := 1000.0,
lowerLimit := -1000.0,
integralTime := 1000.0);

//Filter the Actual Shaft Speed
ShaftPT1(
set := setDiameter,
x := shaftSpeed,
setValue := shaftSpeed,
smoothingTime := shaftFilterTime);
// Convert shaftspeed Revolutions into Radians
Radpersec := ShaftPT1.y * 2.0 * PI / 60.0; // [ RPS ] into [ rad/s ]
// integrate smoothed shaftspeed
ShaftINT(
set := ResetIntegrators,
x := Radpersec,
setValue := 0.0,
upperLimit := 1000.0,
lowerLimit := -1000.0,
integralTime := 1000.0);

// set reset flag for integrators
LatchRawValue := ABS(ShaftINT.y) >= (ABS(measuringRevolutionCount) * 2.0 * PI);
ResetIntegrators := (LatchRawValue) OR (holdDiameter) OR setDiameter; // set revolutions ok OR "Hold Diam!"

// Check if above min speeds for calcualtions and not diameter Hold
IF NOT holdDiameter
AND (ABS(ShaftINT.y) > 0.0)
THEN
IF LatchRawValue THEN // D_raw := 2*(s/angle)
LastRawDiameter := RawDiameter;
RawDiameter := (ABS(LineINT.y) / ABS(ShaftINT.y) * 2.0); // S/Angle -> [ LU ]/[ rad ]
IF RawDiameter <> LastRawDiameter THEN
webThickness := ABS(RawDiameter - LastRawDiameter) / measuringRevolutionCount / 2.0;
END_IF;
IF NOT metricUnits THEN
RawDiameter := RawDiameter * 12.0;
webThickness := webThickness * 12.0;
END_IF;
END_IF;
ELSE
// If not calculating diameter then ok to set diameter value only if within limits
IF setDiameter AND (ABS(ShaftPT1.y) < minShaftSpeed) THEN
RawDiameter := LIMIT (MN:=minDia, IN:= diameterSetValue, MX:= maxDia);
LastRawDiameter := RawDiameter;
END_IF;

IF ResetIntegrators THEN
LastRawDiameter := RawDiameter;
END_IF;
END_IF;

// Limit diameter between min and max
diameter := LIMIT(
MN:= minDia,
IN:= SEL(G := LatchRawValue,
IN0:= Linear( // Interpolate diameter
x := ABS(ShaftINT.y),
x1 := 0.0,
y1 := LastRawDiameter,
x2 := ABS(measuringRevolutionCount) * 2 * PI,
y2 := RawDiameter),
IN1 := LastRawDiameter),
MX:= maxDia);
atMinDia := (diameter = minDia); // If diameter at min set output BOOL
atMaxDia := (diameter = maxDia); // If diameter at max set output BOOL
END_IF;
END_FUNCTION_BLOCK





Documentation (pdf, 9Mb)

Project (zip, 46Kb)







: 519

: maomao    : 2021-01-06

Thank you ! komatic.

: maomao    : 2021-01-06

Can you get the
TIA Portal-"PID_Compact V2" source code.

:

(4000 max):

: