errNr2 THEN GVL.ErrOut := errNr1; END_IF IF errorCollector = TRUE THEN GVL.ErrOut := 1; errorCollector := FALSE; END_IF //Feedback of coupling state IF Nc_AxisN[1].NcToPlc.CoupleState = 3 THEN gearedStatus := TRUE; ELSIF Nc_AxisN[1].NcToPlc.CoupleState = 0 THEN gearedStatus := FALSE; ELSE gearedStatus := TRUE; GVL.ErrOut := 1; END_IF executeMove := GVL.StartCmd; enableAxis := GVL.EnableAxis; executeGearIn := GVL.GerarInCmd; executeGearout := GVL.GerarOutCmd; executeStop := GVL.StopCmd; executeReset := GVL.Reset; GVL.GeraredStat := gearedStatus; //Executete Reset from Python IF executeReset = TRUE THEN GVL.ErrOut := 0; GVL.Done := FALSE; GVL.EnableAxis := FALSE; GVL.GerarInCmd := FALSE; GVL.GerarOutCmd := FALSE; GVL.StartCmd := FALSE; GVL.StopCmd := FALSE; GVL.Reset := FALSE; END_IF //for loop fbPower1( Axis := Nc_AxisN[0], Enable := enableAxis, Enable_Positive := bEndSwitchL, Enable_Negative := bEndSwitchR, Override := override, BufferMode := , Options := , Status => , Busy => , Active => , Error => , ErrorID => errNr1 ); fbPower4( Axis := Nc_AxisN[1], Enable := enableAxis, Enable_Positive := bEndSwitchR, Enable_Negative := bEndSwitchL, Override := override, BufferMode := , Options := , Status => , Busy => , Active => , Error => , ErrorID => errNr2 ); fbStop1( Axis := Nc_AxisN[0], Execute := executeStop, // The command is executed with a positive edge. Deceleration := , // If the value is <= 0, the deceleration // parameterized with the last Move command is used. Jerk := , // If the value is <= 0, the jerk parameterized // with the last Move command is used. Options := , Done => , Busy => , Active => , CommandAborted => , Error => , ErrorID => errNr1); fbStop4( Axis := Nc_AxisN[1], Execute := executeStop, // The command is executed with a positive edge. Deceleration := , // If the value is <= 0, the deceleration // parameterized with the last Move command is used. Jerk := , // If the value is <= 0, the jerk parameterized // with the last Move command is used. Options := , Done => , Busy => , Active => , CommandAborted => , Error => , ErrorID => errNr2); FOR i := 0 TO 1 DO AxisState[i] := Nc_AxisN[i].NcToPlc.CmdState; fbReset[i]( Axis := Nc_AxisN[i], Execute := executeReset, // The command is executed with a positive edge. Done => , Busy => , Error => errorCollector , ErrorID => ); END_FOR fbGearIn( Master := Nc_AxisN[0], Slave := Nc_AxisN[1], Execute := executeGearIn, RatioNumerator := 1, RatioDenominator := 1, Acceleration :=, Deceleration :=, Jerk :=, BufferMode := MC_BufferMode.MC_Aborting, Options =>, InGear =>, Busy =>, Active =>, CommandAborted =>, Error => errorCollector, ErrorID =>); fbGearOut( SLAVE := Nc_AxisN[1], Execute := executeGearout, Options :=, Done =>, Busy =>, Error => errorCollector, ErrorID =>); FOR i:= 0 TO 1 DO fbGetState[i]( Axis := Nc_AxisN[0], Enable := TRUE, Valid =>, Busy =>, Error =>, ErrorId =>, (* motion control statemachine states: *) ErrorStop => GVL.Axis1ErrStoped, Disabled => GVL.Axis1Enabled, Stopping => GVL.Axis1Stoping, StandStill => , DiscreteMotion =>GVL.Axis1moving, ContinuousMotion => , SynchronizedMotion =>, Homing =>, (* additional status *) ConstantVelocity =>, Accelerating =>, Decelerating =>, (* status data structure *) Status =>); END_FOR IF GVL.StartCmd = TRUE THEN position := GVL.moveInterface.targetPos; velocity := GVL.moveInterface.velocity; //Validate input here END_IF fbMoveAbsolute( Axis := Nc_AxisN[GVL.moveInterface.axisNr], Execute := executeMove, // The command is executed with a positive edge. Position := position, Velocity := velocity, Acceleration := , // If the value is 0, the standard acceleration from // the axis configuration in the System Manager is used. Deceleration := , // If the value is 0, the standard deceleration from // the axis configuration in the System Manager is used. Jerk := , // If the value is 0, the standard jerk from the axis // configuration in the System Manager is applied. BufferMode := MC_BufferMode.MC_Buffered, Options := , Done => GVL.Done, Busy => , Active => , CommandAborted => , Error => , ErrorId => errNr1); //Reset Vars IF bEndSwitchR = FALSE OR bEndSwitchL = FALSE OR bEndSwitchT = False OR bEndSwitchB = False THEN executeStop := TRUE; GVL.EnableAxis := FALSE; enableAxis := FALSE; END_IF executeGearIn := FALSE; executeGearout := FALSE; executeStop := FALSE; executeMove := FALSE; executeReset := FALSE; ]]>