Back to top
Changing Drive Opmode in a PxMM Program
The PxMM can control the AKD drive in Position, Velocity, or Torque OpMode. The default AKD Drive OpMode in a KAS program is Interpolated Position Mode. This is AKD Opmode 2 as shown on the drive's front LED Display. To precisely control motor torque independent of position or velocity, in some applications it is desired to configure the drive for Torque Mode operation which is AKD Opmode 0, as shown on the drive's front LED Display.
Method 1: ECATWritesdo function block
To change the Opmode in a KAS Project the ECATWritesdo function block can be used. Here is sample code:
COE (Can over Ethercat) SDO object 16x6060 (DriveOpmode) is used. The 16x6060 values are:
- Position OpMode: 16x6060 = 7 (DRV.OPMODE = 2, AKD front LED display = 2)
- Current OpMode: 16x6060 = 4 (DRV.OPMODE = 0, AKD front LED display =0)
The AKD Drive keyword for the OpMode setting is DRV.OPMODE.
Example Changing to Current OpMode: 16x6060 = 4 (DRV.OPMODE = 0, AKD front LED display =0)
Method 2: PDO Mapping (Deterministic)
Using the Flex PDO mapping capability of the IDE, SDO object 16x6060 can be added as part of the PDO mappings. The following shows 16x6060 mapped in Output PDO(Rx) 0x1601. (Note: DummySINT was included to make the total PDO byte size an even number)
Here the variable DrvOpmodePDO is mapped to 16x6060
Sample program code is as follows:
Note: Typically only one method should be used in an application.
Setting Opmode on KAS Program Startup
When a KAS Project is started up, the standard COE init settings executed for the AKD drive, is Position OpMode: 16x6060 = 7 (DRV.OPMODE = 2)
Considerations when switching Opmodes
When switch back from Torque to Position OpMode there can be a position jump since in Torque OpMode the KAS position command does not change with any movement of the motor. This can create a position error. To prevent the jump, the position error must be eliminated before changing back to Position OpMode. This can be done when in torque mode by commanding a position based KAS motion function block (such as MC_MoveRelative or MC_MoveAbsolute) to line up the commanded position with the actual position. The user can monitor position error and only change the OpMode to position when the following error has been eliminated.
Jogging in Position OpMode
Most application requirements are such that commanding a jog move can be done in the drive's Position Opmode using a KAS standard function blocks such as MC_MoveVelocity, eliminating the need to place the drive in a Velocity OpMode
Sample code to copy and paste:
//Change Opmode via SDO IF b_ChangeOpmodeSDO THEN InvalidOpmode := 0; Inst_ECATWriteSdo(FALSE, ANY_TO_INT(16#6060), 0, 1, 1001, DrvOpmode); OpModeChanging:= 1; Inst_ECATWriteSdo(TRUE, ANY_TO_INT(16#6060), 0, 1, 1001, DrvOpmode); IF Inst_ECATWriteSdo.Done THEN OpModeChanging:= 0; b_ChangeOpmodeSDO := 0; END_IF; IF Inst_ECATWriteSdo.Error THEN InvalidOpmode := 1; OpModeChanging:= 0; b_ChangeOpmodeSDO := 0; END_IF; END_IF; //Change Opmode via PDO ON b_ChangeOpmodePDO DO DrvOpmodePDO := ANY_TO_SINT(DrvOpmode); b_ChangeOpmodePDO := 0; END_DO;