SMC_Homing (FB) ¶ FUNCTION_BLOCK SMC_Homing This function block causes the execution of a homing sequence. If SMC_Homing is executed, the axis is moved at fVelocityFast in the direction specified by nDirection as long as the reference switch is open ( bReferenceSwitch := TRUE ). Once the reference switch is closed ( bReferenceSwitch := FALSE ), the axis is decelerated and driven at fVelocitySlow (the direction depends on the homing mode). At the point at which the reference switch opens again ( bReferenceSwitch := TRUE ), the following actions are performed: the index pulse and index position are used (optionally), the reference position fHomePosition is set, the drive is stopped. (The order of these actions depends on the homing mode, see SMC_HOMING_MODE .) InOut: Scope Name Type Initial Comment Inout Axis AXIS_REF_SM3 Input bExecute BOOL Rising edge: Starts the execution of the function block. fHomePosition LREAL Home position; set after homing (in technical unit [u]) fVelocitySlow LREAL Low velocity; used to drive out of the reference switch [u/s] fVelocityFast LREAL High velocity; used until reference switch is found [u/s] fAcceleration LREAL Value of the acceleration (increasing energy of the motor) [u/s^2] fDeceleration LREAL Value of the deceleration (decreasing energy of the motor) [u/s^2] fJerk LREAL Value of the Jerk [u/s^3] nDirection MC_Direction negative The direction for the fast movement searching the reference switch. ( positive or negative ) bReferenceSwitch BOOL TRUE TRUE : The switch is open (the drive is not in the switch) FALSE : The switch is closed (the drive is in the switch) fSignalDelay LREAL Time [s] for bReferenceSwitch to be transmitted. nHomingMode SMC_HOMING_MODE FAST_BSLOW_S_STOP Homing mode bReturnToZero BOOL TRUE : Moves to position zero after homing. bIndexOccured BOOL TRUE : Index pulse has been detected, the index position is stored in input fIndexPosition . fIndexPosition LREAL Position where index occured bIgnoreHWLimit BOOL Disables the limit switch handling in the driver by setting bHWLimitEnable to FALSE during homing. Please note that for most servo drives, this is necessary but not sufficient to disable the limit switch handling in the drive. Often, the limit switch handling in the drive must be deactivated by other means before calling SMC_Homing, and reactivated when SMC_Homing is done. (For example by writing a drive-specific configuration object.) Output bDone BOOL TRUE : Homing has been done. bBusy BOOL TRUE : FB is not idle. bCommandAborted BOOL TRUE : Commanded motion has been interrupted by any motion FB acting on the same axis except MoveSuperImposed . bError BOOL TRUE : Error has occured within function block. nErrorID SMC_ERROR Error identification* bStartLatchingIndex BOOL For some homing modes, the index pulse is evaluated. TRUE : Storing of the index pulse has been started and must be done by the application. The result is expected in the inputs bIndexOccured and fIndexPosition .
SMC_Inch (FB) ¶ FUNCTION_BLOCK SMC_Inch This function block causes a gradual motion on the axis, which is carried out step by step. InOut: Scope Name Type Initial Comment Inout Axis AXIS_REF_SM3 Reference to axis Input InchForward BOOL TRUE : Axis is moved with the dynamic values Velocity , Acceleration , Deceleration and Jerk in a positive direction until Distance has been travelled. If InchForward is set to FALSE and back to TRUE , a further motion is started. If InchForward is set to FALSE before Distance has been travelled, the axis is immediately decelerated to the velocity value zero. Busy is then set to FALSE . If InchBackward and InchForward are TRUE at the same time, then no motions are carried out. InchBackward BOOL TRUE : Axis is moved with the dynamic values Velocity , Acceleration , Deceleration and Jerk in a negative direction until Distance has been travelled. If InchBackward is set to FALSE and back to TRUE , a further motion is started. If InchBackward is set to FALSE before Distance has been travelled, the axis is immediately decelerated to the velocity value zero and Busy is then set to FALSE . If InchBackward and InchForward are TRUE at the same time, then no motions are carried out. Distance LREAL Distance that is travelled Velocity LREAL Positive velocity in [u/s] Acceleration LREAL Positive acceleration in [u/s²] Deceleration LREAL Positive deceleration in [u/s²] Jerk LREAL Positive jerk in [u/s³] Output Busy BOOL FALSE TRUE : Function block operating CommandAborted BOOL FALSE TRUE : Execution has been interrupted by another function block instance operating on Axis . CommandAborted remains set as long as InchForward or InchBackward is set, but for at least one cycle. Error BOOL TRUE : Error has occurred while InchForward or InchBackward have been set for one cycle. ErrorId SMC_ERROR Error identification
SMC_MoveContinuousAbsolute (FB) ¶ FUNCTION_BLOCK SMC_MoveContinuousAbsolute This function block executes an absolute movement with a given end-velocity. In contrast to MC_MoveAbsolute , it will not reach the target position with zero velocity, but with the specified EndVelocity . It is designed for generating via movements. Once the target position has been reached, the function block sets the InEndVelocity output and keeps this velocity until interrupted by another movement. Note Take care when using MC_SetOverride while this function block is active. If AdaptEndVelToAvoidOvershoot is set to FALSE, reducing the acceleration or jerk override or changing the velocity override can lead to a position overshoot or reversal. This happens if the (potentially overridden) EndVelocity cannot be reached from the current state using the overridden Acceleration , Deceleration , and Jerk limits. InOut: Scope Name Type Initial Comment Inout Axis AXIS_REF_SM3 Reference to axis Input Execute BOOL Rising edge: Starts the execution of the function block. Position LREAL Target position (in technical units [u]) Velocity LREAL Value of maximum velocity (not necessarily reached) [u/s] EndVelocity LREAL Unsigned value of end velocity [u/s] EndVelocityDirection MC_Direction current Determines dthe irection of end velocity. Permissible values: positive , negative , current ; Not applicable: shortest , fastest Acceleration LREAL Value of acceleration (increasing energy of the motor) [u/s²] Deceleration LREAL Value of deceleration (decreasing energy of the motor) [u/s²] Jerk LREAL Value of the jerk [u/s³] Direction MC_Direction shortest Direction of movement, only used for modulo axes. Permissible values: positive , negative , current , shortest Not applicable: fastest AdaptEndVelToAvoidOvershoot BOOL In some cases, a given EndVelocity may lead to a position overshoot. For example, if the remaining distance is too short to reach the end velocity from the current velocity and acceleration, then the axis may turn in opposite direction, leading to an overshoot. Another case is an end velocity that has opposite direction to the distance to be travelled. To arrive at the target position with this velocity, the axis will first exceed the position, reverse and accelerate to the end velocity, again causing an overshoot. If the input AdaptEndVelToAvoidOvershoot is TRUE, then the effective end velocity will be adapted in order to avoid an overshoot. These are the two situatons where an overshoot will be avoided: First, if the remaining distance is too short to reach the desired EndVelocity. In this case, the effective end velocity is reduced (if the current velocity is lower) or increased (if the current velocity is higher) to the closest velocity that can be reached in the given distance. Second, if the direction of the end velocity is opposite to the direction of the movement. In this case, the effective end velocity will be set to zero. Note that the direction of the movement is not determined by the current velocity and acceleration, but by the sign of the distacne to the target position. Note that the output InEndVelocity is set only after the programmed end velocity has been reached. Once the given position has been reached the output PositionReached is set and the axis is accelerated or decelerated to the given (programmed) EndVelocity. Output InEndVelocity BOOL TRUE : Commanded posiotion has been reached and the programmed EndVelocity has been reached. If AdaptEndVelToAvoidOvershoot is FALSE, this output rises to TRUE in the same cycle as PositionReached . Otherwise, it may rise to TRUE later. PositionReached BOOL TRUE : Commanded position has been reached. Axis runs with commanded velocity``EndVelocity`` (or possibly slower if AdaptEndVelToAvoidOvershoot has been set). Busy BOOL TRUE : Execution of function block has not been finished yet. CommandAborted BOOL TRUE : Command has been aborted by another command. Error BOOL TRUE : Error has occurred within the function block. ErrorID SMC_ERROR Error identification
SMC_MoveContinuousRelative (FB) ¶ FUNCTION_BLOCK SMC_MoveContinuousRelative This function block executes a relative movement with a given end-velocity. In contrast to MC_MoveRelative , it will not reach the target position with zero velocity, but with the specified EndVelocity . It is designed for generating via movements. Once the target position has been reached, the function block sets the InEndVelocity output and keeps this velocity until interrupted by another movement. Note Take care when using MC_SetOverride while this function block is active. If AdaptEndVelToAvoidOvershoot is set to FALSE, reducing the acceleration or jerk override or changing the velocity override can lead to a position overshoot or reversal. This happens if the (potentially overridden) EndVelocity cannot be reached from the current state using the overridden Acceleration , Deceleration , and Jerk limits. InOut: Scope Name Type Initial Comment Inout Axis AXIS_REF_SM3 Reference to axis Input Execute BOOL Rising edge: Starts the execution of the function block. Distance LREAL Relative (signed) distance to travel (in technical units [u]) Velocity LREAL Value of maximum velocity (not necessarily reached) [u/s] EndVelocity LREAL Unsigned (!) value of end velocity in [u/s]. This end velocity may also be higher than Velocity. EndVelocityDirection MC_Direction current Determines direction of end velocity. permissible values: positive , negative , current . Not applicable: shortest , fastest . Acceleration LREAL Value of acceleration (increasing energy of the motor) [u/s²] Deceleration LREAL Value of deceleration (decreasing energy of the motor) [u/s²] Jerk LREAL Value of the Jerk [u/s³] AdaptEndVelToAvoidOvershoot BOOL In some cases, a given EndVelocity may lead to a position overshoot. For example, if the remaining distance is too short to reach the end velocity from the current velocity and acceleration, then the axis may turn in opposite direction, leading to an overshoot. Another case is an end velocity that has opposite direction to the distance to be travelled. To arrive at the target position with this velocity, the axis will first exceed the distance, reverse and accelerate to the end velocity, again causing an overshoot. If the input AdaptEndVelToAvoidOvershoot is TRUE, then the effective end velocity will be adapted in order to avoid an overshoot. These are the two situatons where an overshoot will be avoided: First, if the remaining distance is too short to reach the desired EndVelocity. In this case, the effective end velocity is reduced (if the current velocity is lower) or increased (if the current velocity is higher) to the closest velocity that can be reached in the given distance. Second, if the direction of the end velocity is opposite to the direction of the movement. In this case, the effective end velocity will be set to zero. Note that the direction of the movement is not determined by the current velocity and acceleration, but by the sign of the distacne to the target position. Note that the output InEndVelocity is set only after the programmed end velocity has been reached. Once the given distance has been travelled the output DistanceTravelled is set and the axis is accelerated or decelerated to the given (programmed) EndVelocity. Output InEndVelocity BOOL TRUE : Commanded distance has been travelled and the programmed EndVelocity has been reached. If AdaptEndVelToAvoidOvershoot is FALSE, this output rises to TRUE in the same cycle as DistanceTravelled . Otherwise, it may rise to TRUE later. DistanceTravelled BOOL TRUE : Commanded distance has been travelled. Axis runs with commanded velocity``EndVelocity`` (or possibly slower if AdaptEndVelToAvoidOvershoot has been set). Busy BOOL TRUE : Execution of function block has not been finished yet. CommandAborted BOOL TRUE : Command has been aborted by another command. Error BOOL TRUE : Error has occurred within the function block. ErrorID SMC_ERROR Error identification
MC_SetOverride (FB) ¶ FUNCTION_BLOCK MC_SetOverride This function block sets velocity, acceleration/deceleration and jerk override factors for an axis. Function blocks that are working on the axis consider these override factors. The factors contribute as a factor to the calculation of the commanded velocity, acceleration and jerk of the motion. Example 1 Use of MC_SetOverride In this example, the axis is moved from position 0 u to position 100 u with MC_MoveAbsolute . The maximum velocity is 100 u/s, the maximum acceleration is 1000 u/s², and the maximum jerk is 10000 u/s³. Shortly after the axis reaches position 50 u, an override is commanded with velocity factor 0.75 (75%). Note The override factors can be changed at any time and act directly on the ongoing motion. The function block instance of MC_SetOverride should be called before the movement function blocks of the axis are called. If it is called after the movement function block, the override will take effect one cycle later. Changing the override should require about the same amount of computation as aborting an ongoing movement with a new movement. An override has no influence on slave axes once they are ramped in / in sync. However, the override does act while ramping in or gearing in. It is recommended to use ramp type trapezoid or quadratic when using this function block. With the other ramp types sin² and quadratic_smooth, an overshoot may occur when applying a new override. This is analogous to the possible overshoot when aborting movements with these ramp types. Coordinated movements (e.g. MC_MoveLinearAbsolute ) commanded on an axis group will consider override factors set on any axis of the axis group. In state discrete_motion reducing the AccFactor and/or JerkFactor can lead to a position overshoot – a possible cause of damage. If SMC_MoveContinuousAbsolute or SMC_MoveContinuousRelative is active, a change of VelFactor can also lead to a position overshoot or an unwanted reversal. See the documentation for these two function blocks for details. Example 2 An override during deceleration leading to position overshoot. The maximum velocity is 100 u/s, the maximum acceleration is 1000 u/s², and the maximum jerk is 10000 u/s³. The override for acceleration and jerk is reduced to 0.5 (50%) during deceleration to the target position 100 u. In this situation, the override leads to a position overshoot and a reversal of the axis. InOut: Scope Name Type Initial Comment Inout Axis AXIS_REF_SM3 Reference to the axis Input Enable BOOL TRUE : The override factors are continuously written VelFactor LREAL 1 New override factor for the velocity in the range [0, 1] AccFactor LREAL 1 New override factor for the acceleration/deceleration in the range (0, 1] JerkFactor LREAL 1 New override factor for the jerk in the range (0, 1] Output Enabled BOOL TRUE : The override factors are set successfully Busy BOOL TRUE : Function block is in operation Error BOOL TRUE : Error has occurred during execution ErrorID SMC_ERROR Error identification
MC_Stop (FB) ¶ FUNCTION_BLOCK MC_Stop MC_Stop places the axis in the stopping state. As a result, currently running motions of function block instances are aborted. (The only exception is a running MC_Stop instance, which is not aborted. Instead, the just started MC_Stop instance returns an error.) As long as the axis is in the stopping state, no other instance can execute a motion on it. If the axis reaches the velocity value zero, the Done output is set to TRUE . As long as the Execute input is TRUE , the axis remains in the stopping state. If Execute goes to FALSE and the Done output is TRUE , the axis enters the standstill state. Hint In versions before CODESYS V3.5 SP4, the behavior was such that the axis went from stopping to standstill as soon as the velocity value reached zero. Example Use of MC_Stop The illustration shows how the FB2 instance of the type MC_Stop is combined with the FB1 instance of the type MC_MoveVelocity . The rotary axis is ramped down by FB2 . The axis does not execute any motion commands as long as FB2.Execute is TRUE . FB1 outputs an error message indicating that the FB2 instance is active. InOut: Scope Name Type Comment Inout Axis AXIS_REF_SM3 Reference to the axis Input Execute BOOL TRUE : Starts execution on rising edge. Deceleration LREAL Maximum deceleration, positive, in [u/s²] Jerk LREAL Maximum jerk, positive, in [u/s³] Output Done BOOL TRUE : The axis has reached the velocity 0. Busy BOOL TRUE : Function block is in operation. Error BOOL TRUE : An error has occurred. ErrorID SMC_ERROR Error identification
MC_VelocityProfile (FB) ¶ FUNCTION_BLOCK MC_VelocityProfile This function block is designed for commanding a time-velocity locked motion profile. Note If Axis does not reach standstill after this movement and no subsequent movement is commanded in the same cycle when Done is set, then Axis switches to the errorstop state and reports error SMC_MOVING_WITHOUT_ACTIVE_MOVEMENT . Hint A shift between different profiles can be managed. Alternatively to MC_VelocityProfile , a cam function block coupled to a virtual master can be employed. Warning MC_MoveSuperimposed is not supported on top of MC_VelocityProfile Forecasts that are set up by SMC_SetForecast are not supported. InOut: Scope Name Type Initial Comment Inout Axis AXIS_REF_SM3 Reference to axis TimeVelocity MC_TV_REF Reference to time/velocity description Input Execute BOOL Rising edge: Starts the execution of the function block. ArraySize INT Dimension of the array VelocityScale LREAL 1 Overall velocity scaling factor Offset LREAL Overall velocity offset ([u/s]) Output Done BOOL TRUE : Profile has been completed. Busy BOOL TRUE : Execution of function block has not been finished yet. CommandAborted BOOL TRUE : Command has been aborted by another command. Error BOOL TRUE : Error has occurred within the function block. ErrorID SMC_ERROR Error identification
Master/Slave ¶ MC_CamIn (FunctionBlock) MC_CamOut (FunctionBlock) MC_GearIn (FunctionBlock) MC_GearInPos (FunctionBlock) MC_GearOut (FunctionBlock) MC_Phasing (FunctionBlock)
SMC_BacklashCompensation (FB) ¶ FUNCTION_BLOCK SMC_BacklashCompensation This function block can be used to compensate the backlash which arises for example at a belt drive or in a gear-box. For this purpose a (usually virtual) master axis gets mirrored on the real slave axis, whose backlash should be compensated. The function block works similar to a phasing function block, the phase depends on the direction of the master axis. If the master axis starts in a certain direction, the slave axis does the same plus an additional movement (distance: fBacklash ) in this direction; if the master axis inverts, the slave axis also turns around and additionally covers the double distance fBacklash in this new direction. Take care that the master axis and the slave axis are at the same position when the module starts working, because otherwise the slave axis would be positioned on the master axis. InOut: Scope Name Type Initial Comment Inout Master AXIS_REF_SM3 Reference to master axis Slave AXIS_REF_SM3 Reference to slave axis Input bExecute BOOL Rising edge: Starts the execution of the function block. It stays active until the slave axis gets interrupted by another movement, or if an error occurs. fBacklash LREAL Distance/Backlash to be compensated. fCompensationVel LREAL Additional velocity, which should be used for the compensation. fCompensationAcc LREAL Additional acceleration, which should be used for the compensation. fCompensationDec LREAL Additional deceleration, which should be used for the compensation. fCompensationJerk LREAL Additional jerk, which should be used for the compensation. eBacklashMode SMC_BACKLASH_MODE SMC_BL_AUTO The mode of backlash compensation. SMC_BL_AUTO : Direction in which the master axis moves; determines the compensation direction. SMC_BL_POSITIVE : Compensation in positive direction, independent on the movement of the master axis. SMC_BL_NEGATIVE : Compensation in negative direction, independent on the movement of the master axis. SMC_BL_OFF : No compensation eBacklashStartState SMC_BACKLASH_STARTSTATE SMC_BL_START_NONE The start condition of the axis. SMC_BL_START_NEGATIVE : The slave axis is under traction in negative direction, that is: a movement in negative direction needs no compensation; in case of a movement in positive direction the double fBacklash -distance will be made up. SMC_BL_START_POSITIVE : The slave axis is under traction in positive direction, that is: a movement in positive direction needs no compensation; in case of a movement in negative direction the double fBacklash -distance will be made up. SMC_BL_START_NONE : The slave axis is not under traction; a movement in positive or negative direction will cause a corresponding compensating movement of distance fBacklash . Output bBusy BOOL TRUE : Execution of the function block is not finished yet. bCommandAborted BOOL TRUE : Command has been aborted by another command. bError BOOL TRUE : Error has occured within the function block. iErrorID SMC_ERROR Error identification bCompensating BOOL TRUE : While compensating a backlash.
Direct ¶ SMC_FollowPosition (FunctionBlock) SMC_FollowPositionVelocity (FunctionBlock) SMC_FollowSetValues (FunctionBlock) SMC_FollowVelocity (FunctionBlock) SMC_SetTorque (FunctionBlock) SMC_TrackAxis (FunctionBlock) SMC_TrackSetValues (FunctionBlock)