FUNCTION_BLOCK SMC_SetControllerMode
This function block, if supported by the drive, can be used to switch to another controller mode. Preconditions:
The axis must support the desired controlling mode. In order to check this, see the feature documentation PDF inside the corresponding SoftMotion driver library.
The needed cyclic I/O data (e.g. for torque mode: set torque object) must be mapped.
The axis must NOT be in the state errorstop, stopping or homing when this function block is called. Else, an error SMC_SCM_AXIS_IN_WRONG_STATE will be reported.
Behavior when active:
This function block sets the byControllerMode (command value of operation mode) parameter of the axis and waits until the parameter byRealControllerMode (actual value of operation mode) reflects this value.
If this does not happen during 1000 cycles, the function block will abort with an error.
When switching from a lower level to a higher level control mode (e.g. torque -> velocity, torque->position, velocity->position), the function block calculates the set values of the higher level signal. E.g. when switching from torque mode to position mode, the function block uses the actual position of the axis and adds an expected position distance, that compensates the time lag between actual and set values depending on the actual velocity and the time shift in cycles (Axis.fSetActTimeLagCycles). The later value depends strongly on the system (controller hardware, field bus, drive) and may need to be adjusted.
What function blocks have to be called after SMC_SetControllerMode reports bDone?
As soon as byRealControllerMode reflects byControllerMode, the function block sets its Done output and stops any action. This means that the application program is immediately responsible for calculating the correct set values beginning with this cycle. E.g. an axis was torque controlled and shall be switched to position control. The axis was still moving when the function block SMC_SetControllerMode was started. During the switching time, the function block calculates the proper values for the set position. But as soon as it sets Done, no function block continues to provide set values and the axis would stop immediately and report an error. Therefore e.g. a function block MC_Halt, MC_MoveVelocity or MC_MoveAbsolute could be triggered by the Done output of SMC_ControllerMode and take over the control of the axis.
InOut:
Scope |
Name |
Type |
Initial |
Comment |
Inout |
Axis |
Axis |
||
Input |
bExecute |
BOOL |
FALSE |
TRUE: Starts changing the controlling mode. |
nControllerMode |
SMC_position |
|||
Output |
bDone |
BOOL |
TRUE: Mode switching has been done. |
|
bBusy |
BOOL |
TRUE: FB is not idle. |
||
bError |
BOOL |
TRUE: Error has occured within function block. |
||
nErrorID |
SMC_ERROR |
Error identification |