Hallo,
danke für die schnelle Antwort. Im Systemmanager von Beckhoff habe ich die Variablen eigentlich richtig verknüpft.
Man muss ja nur bei der NC-Achse den Eingang und Ausgang mit der jeweiligen Variable verknüpfen. Dann habe ich noch den Skalierungsfaktor und die Bezugsgeschwindigkeit angegeben. Warum der jetzt nicht bereit ist, weiß ich leider nicht.
Hier der code:
PROGRAM MAIN
VAR
Direction: MC_Direction; (* Aufzählungstyp mit Bewegungsrichtungen für MC_MoveVelocity *)
fbMoveAbsolute_Axis_1: MC_MoveAbsolute; (* Es wird eine absolute Positionierung durchgeführt *)
fbMoveVelocity_Axis_1: MC_MoveVelocity; (* Es wird eine Endlosfahrt durchgeführt *)
fbPower_Axis_1: MC_Power; (* Es werden die Freigaben für die Achse gesetzt *)
fbReadActualPosition_1: MC_ReadActualPosition; (* Es wird die aktuelle Position der Achse gelesen *)
fbReset_Axis: MC_Reset; (* Es wird ein Reset der Achse durchgeführt *)
fbStop: MC_Stop; (* Die Achse wird gestoppt *)
bAxis_Ready: BOOL; (* Überprüft, ob die Achse bereit ist *)
bMove_Absolut_Aborted: BOOL; (* Wird true, wenn die Positionierung nicht vollständig ausgeführt werden konnte *)
bMove_Absolut_Done: BOOL; (* Zeigt, ob die Positionierung abgeschlossen ist *)
bReset_Done: BOOL; (* Zeigt, ob ein Resetvorgang absgeschlossen ist *)
lrAcc_Axis_1: LREAL ; (* Beschleunigung bei absoluter Positionierung, beim Wert 0 wirkt Standard *)
lrActual_Position: LREAL; (* Aktuelle Position der Achse *)
lrDecel_Axis_1: LREAL ; (* Verzögerung bei absoluter Positionierung, beim Wert 0 wirkt Standard *)
lrJerk_Axis_1: LREAL; (* Ruck bei absoluter Positionierung, beim Wert 0 wirkt Standard *)
lrPosition_Drive_to: LREAL; (* Position, die bei einer absoluten Positionierung angefahren werden soll *)
lrVelocity_Move_Ab_Axis_1: LREAL; (* Geschwindigkeit, mit der bei einer absoluten Positionierung gefahren werden soll *)
InVelocity : BOOL;
CommandAborted : BOOL;
bError : BOOL;
ErrorId : UDINT;
MC_Home : MC_Home;
Start : BOOL;
bTest : BOOL;
PowerStatus : BOOL; (* B *)
Busy : BOOL; (* V *)
Active : BOOL; (* V *)
PowerError : BOOL; (* B *)
PowerErrorID : UDINT; (* E *)
StopDone : BOOL;
StopError : BOOL;
StopErrorID : UDINT;
END_VAR
(* Freigabesignale werden gesetzt *)
fbPower_Axis_1(
Enable := bEnable,
Enable_Positive := bEnable,
Enable_Negative := bEnable,
Override := 100.000,
AxisRefIn := strNC_TO_PLC,
AxisRefOut := strPLC_TO_NC,
Status => PowerStatus,
Error => PowerError,
ErrorID => PowerErrorID);
(* Überprüft, ob die Achse bereit ist *)
bAxis_Ready := AxisIsReady(strNC_TO_PLC.nStateDWord );
(* Reset der Achse *)
fbReset_Axis(
Execute := bReset_Axis,
Axis := strNC_TO_PLC,
Done => bReset_Done,
Error => ,
ErrorID => );
(* Führt eine Absolutbewegung durch *)
fbMoveAbsolute_Axis_1(
Execute := bMove_Absolut,
Position := lrPosition_Drive_to,
Velocity := lrVelocity_Move_Ab_Axis_1 ,
Acceleration := lrAcc_Axis_1,
Deceleration := lrDecel_Axis_1,
Jerk := lrJerk_Axis_1 ,
Axis := strNC_TO_PLC,
Done => bMove_Absolut_Done ,
CommandAborted => bMove_Absolut_Aborted ,
Error => ,
ErrorID => );
IF fbMoveAbsolute_Axis_1.Done THEN
bMove_Absolut := FALSE;
END_IF
(* Führt eine Endlosbewegung durch *)
IF bMoveRight THEN
Direction := MC_Positive_Direction;
ELSIF bMoveLeft THEN
Direction := MC_Negative_Direction;
END_IF
fbMoveVelocity_Axis_1(
Execute := bMoveRight OR bMoveLeft OR bMove_Absolut,
Velocity := 1000,
Acceleration := lrAcc_Axis_1,
Deceleration := lrDecel_Axis_1,
Jerk := ,
Direction := Direction,
Axis := strNC_TO_PLC,
InVelocity => InVelocity,
CommandAborted => CommandAborted,
Error => bError,
ErrorId => ErrorId);
IF bMove_Absolut OR bMoveLeft OR bMoveRight THEN
bStop := FALSE;
ELSE
bStop := TRUE;
END_IF
(*
(* Stoppt die Achse *)
fbStop(
Execute := bStop,
Deceleration := 500,
Jerk := ,
Axis := strNC_TO_PLC,
Done => StopDone,
Error => StopError,
ErrorId => StopErrorID);
*)
(* Auslesen der aktuellen Position *)
fbReadActualPosition_1(
Enable := TRUE ,
Axis := strNC_TO_PLC ,
Done => ,
Error => ,
ErrorID => ,
Position => lrActual_Position);