Beispiel Steigungskompensation
[This is preliminary documentation and subject to change.]

Dieses Beispiel zeigt, wie die Funktionsbausteine FB_PositionCompensation und FB_WritePositionCorrection zur Steigungskompensation einer Spindel verwendet werden.
Abhängig von der erforderlichen Genauigkeit wird empfohlen, die SPS Task mit der gleichen Zykluszeit wie die NC_SAF Task auszuführen. Ebenfalls ist es notwendig, die gegenwärtige Positionskorrektur der Achse zu aktivieren (System Manager).

VAR
fbPitchCompensation : FB_PositionCompensation;
fbWritePosCorrection : FB_WritePositionCorrection;
bAxisIsHomed : BOOL;
bEnablePitchCompensation : BOOL := FALSE;
fCompensationValue : LREAL;
bError : BOOL;
nErrorId : UDINT;
bActive : BOOL;
bLimiting : BOOL;
END_VAR
VAR CONSTANT
stXDescPitch: ST_CompensationDesc := (fPosMin:=0.0, fPosMax:=100.0, nTableElements:=11);
stXPitchTable: ARRAY[0..10] OF ST_CompensationElement
:=(fPos:=0.0, fCompensation:=0.0),
(fPos:=10.0, fCompensation:=0.1),
(fPos:=20.0, fCompensation:=0.2),
(fPos:=30.0, fCompensation:=0.3),
(fPos:=40.0, fCompensation:=0.4),
(fPos:=50.0, fCompensation:=0.5),
(fPos:=60.0, fCompensation:=0.6),
(fPos:=70.0, fCompensation:=0.7),
(fPos:=80.0, fCompensation:=0.8),
(fPos:=90.0, fCompensation:=0.9),
(fPos:=100.0, fCompensation:=1.0);
END_VAR
Die Kompensationstabelle und -beschreibung ist in diesem Fall als konstant definiert. fPos hält die unkorrigierte absolute Position und für jede Position gibt es einen Kompensationswert fCompensation.
In annähernd allen Applikationen ist die Kompensation nur brauchbar wenn die Achse referenziert wurde (homing). FB_PositionCompensation sollte nur aktiviert werden, wenn diese Voraussetzung gegeben ist.
IF bAxisIsHomed THEN
(* generally the compensation is just allowed if the axis is referenced *)
(* so we check here, if the axis is homed & enable the pitch compensation if so *)
bEnablePitchCompensation := TRUE;
ELSE
bEnablePitchCompensation := FALSE;
END_IF
fbPitchCompensation(
Enable:= bEnablePitchCompensation ,
pTable:= ADR(stXPitchTable),
cbSize:= SIZEOF(stXPitchTable),
ReferenceAxis:= in_stXNcToPlc,
Desc:= stXDescPitch,
Compensation=>fCompensationValue,
Error=>bError,
ErrorId=>nErrorId,
Active=>bActive);
fbWritePosCorrection(
Enable:=TRUE,
PositionCorrectionValue:=fCompensationValue,
CorrectionMode:= POSITIONCORRECTIONMODE_FAST,
Acceleration:= 500,
CorrectionLength:= ,
AxisRefIn:= in_stXNcToPlc,
AxisRefOut:= out_stXPlcToNc,
Busy=> bLimiting,
Error=> ,
ErrorID=> ,
Limiting=> );
Voraussetzungen
Entwicklungumgebung | Zielplattform | Einzubindende SPS Bibliotheken |
---|---|---|
from TwinCAT v2.10 Build 1314 | PC (i386) | TcNc.Lib |