FC_DrvEncSetPosition - General Information

Overview

Type:

Function

Available as of:

SystemInterface_1.32.6.0

Support for:

oPDL_FB_SetDriveEncoder

Versions:

Current version

Task

Modify the absolute encoder position permanently.

Description

This function sets the encoder position to a preset absolute position value. The coordinate system of the encoder is moved. This requires a write process to the non-volatile memory of the encoder. A few milliseconds are required for this write access. Using the function FC_DrvEncPosition­GetState() it can be determined whether the writing procedure has been completed.

Dependent on the object parameter EncoderMode (if available), the new position is set to the motor encoder (EncoderMode = "Only use motor encoder") or the machine encoder (EncoderMode = "Machine encoder is only used for position control").

The position i_lrPosition must meet specific criteria. It is distinguished between single-turn in multi-turn encoders. Single-turn encoders detect a resolution within one turn. Multi-turn encoders extend the position boundaries and have an addressable range between zero and 4096 turns. The position can be set within these defined boundaries (absolute travel range of the encoder).

When you energize or reset a drive, the absolute value of the SinCos encoder is read. This value forms the actual position. When exceeding or underrunning the position range, a jump in position up to the encoder period occurs for the absolute value of the encoder (1 revolution or 4096 revolutions). This position jump does not occur in the object parameter MechPosition when the drive is moved as the absolute encoder value is only evaluated after being energized or reset. Then the drive is moved in increments.

By virtual axes, this function has no effect.

As of version V1.50.1.x, the function call-up takes longer since the complete writing of the new EncoderPosition value in the motor nameplate is awaited now. Therefore, when reading the state with the FC_DrvEncPositionGetState function, value 1 (= motor nameplate is currently programmed) does not occur any longer. However, the return value still indicates whether programming was successful.

The function running time can take up to several hundred milliseconds.

Interface

Input

Data type

Description

i_stAxisID

ST_LogicalAddress

Logical address of the drive

i_lrPosition

LREAL

Encoder position

Return Value

Data type

Description

DINT

0: Error-free operation

-1: Incorrect i_stAxisID

-2: Invalid position

-3: Axis is virtual

-4: Axis is deactivated

Examples

Set the encoder position to 360 units.

FeedConstant = 360 units / rotation

EncoderType = 16#22; that is, SinCos Singleturn

This results in an EncoderPosition 0 ... 360 units.

The EncoderPosition 360 corresponds to EncoderPosition 0. The resolution of the encoder is 219 increments per rotation. This results in a maximum EncoderPosition of:

FeedConstant * (number of rotations – 2-19)

Number of rotations:

oSingle turn= 1

oMulti turn= 4096

In this case:

360 units/rotation * (1 rotation – 2-19 rotations) = 359.9993134 units

 FC_DrvEncSetPosition(i_stAxisID:=Axis.LogAdr, i_lrPosition:=0);