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_GetMaxSetVelocity (FB) ¶ FUNCTION_BLOCK SMC_GetMaxSetVelocity This function block may be employed to measure the maximum value of velocity of an axis. Measuring will be done if bEnable is TRUE , and will be reset to 0, if bEnable is FALSE . With dwTimeStamp you can provide a call counter, which is latched output in dwTimeAtMax with a new maximum value. InOut: Scope Name Type Initial Comment Inout Axis AXIS_REF_SM3 Input bEnable BOOL FALSE TRUE : Starts execution of the function block. dwTimeStamp DWORD Optional time stamp input; can be used to find out when the maximum occured. Output bValid BOOL FALSE bBusy BOOL TRUE : Parameter is available. fMaxVelocity LREAL 0 TRUE : Eecution of the function block is not finished yet. dwTimeAtMax DWORD 0 Maximum velocity in [u/s²]
SMC_GetTrackingError (FB) ¶ FUNCTION_BLOCK SMC_GetTrackingError This function block may be employed to measure the current and maximum lag error compensating the dead time, which can arise from the communication via a field bus and will be given in number of cycles ( byDeadTimeCycles ). Similar to SMC_GetMaxSetVelocity a time stamp ( dwTimeStamp ) can be used to measure the time at the maximum. InOut: Scope Name Type Initial Comment Inout Axis AXIS_REF_SM3 Input bEnable BOOL FALSE TRUE : Starts execution of the function block. byDeadTimeCycles BYTE 2 Number of dead time cycles dwTimeStamp DWORD Optional time stamp input; can be used to find out when the maximum occured. Output bValid BOOL TRUE : Parameter is available. bBusy BOOL TRUE : Execution of function block has not been finished yet. fActTrackingError LREAL 0 Current lag error fMaxTrackingError LREAL 0 Maximum lag error dwTimeAtMax DWORD 0 Maximum value of dwTimeStamp
SMC_InPosition (FB) ¶ FUNCTION_BLOCK SMC_InPosition This function block monitors the offset between the nominal and actual positions of an axis (drag error). This tests whether the drag error lies within a specified value range for over a defined period of time (position window). When using logical axes, it is possible with the function block to compare a real and a logical axis. This tests whether the logical axis, which is the mapping of a real axis compensated by communication time, is close to the values of the real axis. Instead of the deviation between the nominal and actual positions, the deviation of the actual position of the logical axis is used as the nominal position of the real axis. The function block SMC_InPosition can be used for this test under the following conditions: The motion type must be identical (limited/modulo). In the case of “modulo”, the position period must be the same. Identical offsets must be defined (e.g., set by MC_SetPosition ). If these conditions are not satisfied, then the compared positions will probably never match and therefore there is no point in using the FB. In this case, an error is not issued. InOut: Scope Name Type Comment Inout Axis AXIS_REF_SM3 Input bEnable BOOL TRUE : Starts execution of the function block. fPosWindow LREAL The drive is inside the position window, if fPosWindow >= Distance(actual position, set position) [u]. fPosTime LREAL Time that the FB has to stay inside the position window before bInPosition is set [s]. fTimeOut LREAL If the time since enabling the FB is larger than this value and bInPosition is not set, bTimeOut is set; this mechanism is deactivated, if fTimeOut = 0. Output bInPosition BOOL TRUE : Parameter is available. bBusy BOOL TRUE : Execution of the function block is not finished yet. bTimeOut BOOL TRUE : Error has occurred within the function block.
SMC_MeasureDistance (FB) ¶ FUNCTION_BLOCK SMC_MeasureDistance This function block may be employed on a rotary axis to measure the covered distance by regarding the wrap. InOut: Scope Name Type Comment Inout Axis AXIS_REF_SM3 Input bExecute BOOL Output fDistance LREAL bBusy BOOL Travelled distance since start of measurement. bError BOOL TRUE : Execution of the function block has nor been finished yet. nErrorID SMC_ERROR TRUE : Error has occurred within the function block.
SMC_ReadSetPosition (FB) ¶ FUNCTION_BLOCK SMC_ReadSetPosition This function block can be used for reading the currently set position of the drive. InOut: Scope Name Type Initial Comment Inout Axis AXIS_REF_SM3 Reference to axis Input Enable BOOL FALSE TRUE : Enables the execution of the function block. Output Valid BOOL FALSE TRUE : Parameter is available. Busy BOOL FALSE TRUE : Execution of function block has not been finished yet. Error BOOL FALSE TRUE : Error has occurred within the function block. ErrorID SMC_ERROR 0 Error identification Position LREAL 0 Position of drive
SMC_ReadSetValues (FB) ¶ FUNCTION_BLOCK FINAL SMC_ReadSetValues Reads the set position, velocity, acceleration, and jerk of an axis. Allows setting a positive TimeOffset to read future set values. With TimeOffset = 0 the set values from the beginning of the current cycle are read. Note Reading future set values requires setting a ForecastDuration using SMC_SetForecast . InOut: Scope Name Type Comment Inout Axis AXIS_REF_SM3 Reference to the axis Input Enable BOOL Read the set values continuously while enabled. TimeOffset LREAL Time offset relative to the current cycle for which the set values should be read. The TimeOffset must be between 0 and the ForecastDuration set using SMC_SetForecast . If the TimeOffset is outside this range the error SMC_INVALID_PARAMETER is reported. Output Valid BOOL TRUE : Valid outputs are available. Busy BOOL TRUE : Execution of the function block has not been finished yet. Error BOOL TRUE : Error has occurred within the function block. ErrorID SMC_ERROR Error identification Position LREAL The set position Velocity LREAL The set velocity Acceleration LREAL The set acceleration Jerk LREAL The set jerk