FB_WriteDriveEncoder

 

FB_WriteDriveEncoder - General Information

Overview

Type:

Function block

Available as of:

V1.0.3.0

Inherits from:

-

Implements:

-

Versions:

Current version

NOTE: The elements FB_WriteDriveEncoder und FC_ReadDriveEncoder are obsolete.

Use instead the elements FB_HomeAbs and FB_HomeSetPos with the mode PDL.ET_HomeSetPosMode.RestoreFromAxisEncoder.

Task

The position of the motor sensor should be changed.

Description

This function block 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 EEPROM of the encoder. A few milliseconds are required for this write access. The cycle time of the task is increased by the function block.

The axis is "disabled" during the implementation and "enabled" again in case it was "enabled".

The waiting time after the writing procedure is considered by the function block automatically. This means, you do not have to verify if the writing procedure has been completed with the function FC_DrvEncPositionGetState().

The position is read back and checked after completing the writing procedure.

Interface

Input

Data type

Description

i_xEnable

BOOL

A rising edge FALSE -> TRUE activates the POU, a falling edge TRUE -> FALSE deactivates the POU.

A deactivated POU does not execute any actions.

NOTE: Cancelling the encoder position modification leads to an undefined condition.

If the input i_xEnable is set to FALSE before q_xDone or q_xError = TRUE, then the function block stops and q_xActive also switches to FALSE. Depending on when i_xEnable is set to FALSE, the encoder setting is not started or the axis is disabled and will not be enabled.

With the rising edge at i_xEnable, the cycle monitoring time is increased. The overrun time (diagnostic message 317 "Cycle time overrun") is increased by 100 ms and is reset to the original value with the negative edge.

i_ifDrive

IF_Drive

Input for the axis that shall be controlled.

i_lrHomePos

LREAL

Position value that the motor encoder (RefPosition of the axis) should be set to.

The position value should lie within the encoder period (0 ... MaxEncoderValue). If the position value lies outside the encoder period, then the function PDL.FC_ReadDriveEncoder has to be used. Single turn and multi turn encoders are supported.

With i_lrUserPeriod > 0 the position is set in the application period (e.g. machine period).

i_lrAbsEncOffset

LREAL

Allows the position to be reconstructed after the controller or drive has been reset (e.g. Lexium 62), when the position of the axis is less than i_lrHomePos . This is only effective with i_ lrUserPeriod = 0.

Value range: 0 < lrAbsEncOffset < Max. Encoder value

Start of run range = i_lrHomePos i_lrAbsEncOffset

End run range = Begin run range + Encoder period

See also input i_lrUserPeriod.

i_lrUserPeriod

LREAL

Position range (e.g. machine period) that the encoder position (EncoderPosition) should be within.

oi_lrUserPeriod = 0

The i_lrAbsEncOffset is taken into account when setting RefPosition.

oi_lrUserPeriod <> 0

The input i_lrAbsEncOffset is not taken into account. If the value is outside the period range, the POU determines the respective position within the period (Position = i_lrHomePos MOD i_lrUserPeriod).

i_xExecute

BOOL

If i_xEnable = TRUE, this input can be used to start the encoder writing process. Once the encoder writing process has been started, it is not possible to cancel the process using i_xExecute TRUE -> FALSE.

Output

Data type

Description

q_xActive

BOOL

TRUE: The POU is active and has to be executed further.

FALSE: The POU is inactive.

q_xReady

BOOL

TRUE: The POU is ready to operate and can accept user commands.

FALSE: The POU is not ready to accept user commands.

q_xBusy

BOOL

Writing process active, the function block has to be executed further

q_xDone

BOOL

Writing completed

q_etDiag

GD.ET_Diag

General library-independent statement on the diagnostic.

A value not equal to ET_Diag.Ok corresponds to an diagnostic message.

q_etDiagExt

ET_DiagExt

POU-specific output on the diagnostic.

q_etDiag = ET_Diag.Ok -> Status message

q_etDiag <> ET_Diag.Ok -> Diagnostic message

q_sMsg

STRING[80]

Event-triggered message which gives more detailed information on the diagnostic state.

Examples

Example with Single-Turn-Encoder (Encoder period standardized to 0 ... 360° standardized)

i_lrHomePos

i_lrAbsEncOffset

i_lrUserPeriod

Axis position according to FB_WriteDriveEncoder or FC_ReadDriveEncoder

Run range

1000

100

0

1000

900 ... 1260 (Delta 360)

0

100

0

0

-100 ... 260 (Delta 360)

-1000

100

0

-1000

-1100 ... -740 (Delta 360)

1000

0

360

280

0 ... 360

-1000

0

360

80

0 ... 360

1

0

36

1

0 ... 36

35

0

36

35

0 ... 36

54

0

36

18

0 ... 36

-54

0

36

18

0 ... 36

-55

0

36

17

0 ... 36

Diagnostic Messages

q_etDiag

q_etDiagExt

Enumeration value

Description

OK

Disabled

9

The POU is disabled.

OK

Initializing

4

The POU is being initialized.

OK

WaitForExecute

180

Wait for execution.

OK

WaitUntilDriveDisabled

179

Waiting until the drive is deactivated.

OK

WaitUntilDriveEnabled

145

Waiting until the drive is enabled.

OK

WaitUntilEncoderWritten

188

Waiting until the encoder has been written.

OK

WritingPositionDone

184

The encoder position has been written.

DriveConditionInvalid

DriveEncoderInvalid

175

The drive encoder is invalid.

DriveConditionInvalid

DriveIsMoving

182

The drive is moving.

DriveConditionInvalid

DriveNotDisabled

183

The drive is not disabled.

DriveConditionInvalid

NoAccessToEEPROM

187

The EEPROM of the drive cannot be accessed.

DriveConditionInvalid

NoRealDrive

176

The drive is not real.

DriveConditionInvalid

ProgrammingInProgress

189

Writing is being performed on the encoder.

DriveConditionInvalid

ProgrammingInvalidEEPROM

186

An error has been detected while writing on the encoder EEPROM.

ExecutionAborted

AsyncInitNotFinished

290

Init has not been completed yet.

ExecutionAborted

ColdResetOfControllerNecessary

297

A cold start of the controller is required

ExecutionAborted

NoAsyncTasksCreated

289

No asynchronous task has been generated.

InputParameterInvalid

AbsEncOffsetRange

178

AbsEncOffset is outside the valid range.

InputParameterInvalid

AsyncInvalid

288

The value of IF_Async is invalid.

InputParameterInvalid

DriveInvalid

3

The connected drive is invalid.

InputParameterInvalid

UserPeriodRange

177

UserPeriod is outside the valid range.

UnexpectedProgramBehavior

AsyncAddWasNotSuccessful

284

It was not possible to transfer an asynchronous job to a task.

UnexpectedProgramBehavior

EncoderWriteTimeOut

185

Timeout during encoder writing.

UnexpectedProgramBehavior

InterfaceCastFailed

285

The prompt for the interface was unsuccessful.

UnexpectedProgramBehavior

SemaphoreMeCreateFailed

287

The creating of a Semaphore failed

UnexpectedProgramBehavior

SercosNotInPhaseFour

19

The Sercos bus is not in phase 4.

UnexpectedProgramBehavior

UnexpectedFeedback

1

An unintended detected error occurred during execution.

UnexpectedProgramBehavior

UnknownState

2

The POU is in an undefined state.

AbsEncOffsetRange

Enumeration name:

AbsEncOffsetRange

Enumeration value:

178

Description:

AbsEncOffset is outside the valid range.

Issue

Cause

Solution

-

At the input i_lrAbsEncOffset, a number <= 0 or greater than the encoder period has been transferred.

For i_lrAbsEncOffset, the following must hold: 0 < i_lrAbsEncOffset < maximum possible value of Drive.EncoderPosition.

For the valid value range for i_lrAbsEncOffset, see output q_sMsg of FB_WriteDriveEncoder

AsyncAddWasNotSuccessful

Enumeration name:

AsyncAddWasNotSuccessful

Enumeration value:

284

Description:

It was not possible to transfer an asynchronous job to a task.

Issue

Cause

Solution

-

An error has been detected and occurred in the internal execution.

Please inform the support team about this detected error.

AsyncInitNotFinished

Enumeration name:

AsyncInitNotFinished

Enumeration value:

290

Description:

Init has not been completed yet.

Issue

Cause

Solution

-

Init() method has not yet been completed.

Call up the Init() before you call up Start() for the first time.

After you have called up the Init, wait until Init has been executed successfully. (Init.q_xDone = TRUE)

AsyncInvalid

Enumeration name:

AsyncInvalid

Enumeration value:

288

Description:

The value of IF_Async is invalid.

Issue

Cause

Solution

-

No valid value has been transferred at the i_ifAsync input.

Verify the value at the i_ifAsync input for <> 0.

ColdResetOfControllerNecessary

Enumeration name:

ColdResetOfControllerNecessary

Enumeration value:

297

Description:

A cold start of the controller is required

Issue

Cause

Solution

-

Gc_udiNumOfAsyncTasks has been changed.

A cold start of the controller and a call up of Init() is required.

Disabled

Enumeration name:

Disabled

Enumeration value:

9

Description:

The POU is disabled.

The function block is disabled and executes no actions whatsoever. i_xEnable and q_xActive are set to FALSE

DriveEncoderInvalid

Enumeration name:

DriveEncoderInvalid

Enumeration value:

175

Description:

The drive encoder is invalid.

Issue

Cause

Solution

-

The axis encoder is not supported.

Use an axis with a different encoder.

DriveInvalid

Enumeration name:

DriveInvalid

Enumeration value:

3

Description:

The connected drive is invalid.

Issue

Cause

Solution

-

At the input i_ifDrive, no drive was applied.

At the input i_ifDrive, a valid drive must be transferred.

-

The connected drive does not support all required functionalities.

Establish which functionalities are not supported by the drive by means of output q_sMsg.

Use a drive which supports all required functionalities.

DriveIsMoving

Enumeration name:

DriveIsMoving

Enumeration value:

182

Description:

The drive is moving.

Issue

Cause

Solution

-

The axis is moving.

Verify the state of the axis.

DriveNotDisabled

Enumeration name:

DriveNotDisabled

Enumeration value:

183

Description:

The drive is not disabled.

Issue

Cause

Solution

-

The axis is not in AxisState 1

Verify the state of the axis.

EncoderWriteTimeOut

Enumeration name:

EncoderWriteTimeOut

Enumeration value:

185

Description:

Timeout during encoder writing.

Issue

Cause

Solution

-

The encoder writing process has taken too long.

Verify the connection to the encoder and retry.

Initializing

Enumeration name:

Initializing

Enumeration value:

4

Description:

The POU is being initialized.

The function block is being initialized and thus is not yet ready to receive commands at its inputs.

The function block will signalize that it is ready for operation with the signal q_xReady = TRUE.

InterfaceCastFailed

Enumeration name:

InterfaceCastFailed

Enumeration value:

285

Description:

The prompt for the interface was unsuccessful.

Issue

Cause

Solution

-

An error has been detected and occurred in the internal execution.

Please inform the support team about this detected error.

NoAccessToEEPROM

Enumeration name:

NoAccessToEEPROM

Enumeration value:

187

Description:

The EEPROM of the drive cannot be accessed.

Issue

Cause

Solution

-

The access to the encoder has been denied.

Verify the axis state.

NoAsyncTasksCreated

Enumeration name:

NoAsyncTasksCreated

Enumeration value:

289

Description:

No asynchronous task has been generated.

Issue

Cause

Solution

-

Gc_udiNumOfAsyncTasks = 0

Allocate Gc_udiNumOfAsyncTasks with a value > 0 and <= 10.

NoRealDrive

Enumeration name:

NoRealDrive

Enumeration value:

176

Description:

The drive is not real.

Issue

Cause

Solution

-

At the input i_ifDrive, a virtual axis has been applied.

At the input i_ifDrive, a real axis must be transferred.

ProgrammingInProgress

Enumeration name:

ProgrammingInProgress

Enumeration value:

189

Description:

Writing is being performed on the encoder.

Issue

Cause

Solution

-

You cannot write on the encoder because a writing process is already active.

Wait until the active writing process is completed and try to perform the FB_WriteDriveEncoder again.

If this diagnostic message occurs even after retrying it several times, then please inform the support team about this detected error.

ProgrammingInvalidEEPROM

Enumeration name:

ProgrammingInvalidEEPROM

Enumeration value:

186

Description:

An error has been detected while writing on the encoder EEPROM.

Issue

Cause

Solution

-

Writing is already being performed on the encoder.

Please retry later.

SemaphoreMeCreateFailed

Enumeration name:

SemaphoreMeCreateFailed

Enumeration value:

287

Description:

The creating of a Semaphore failed

Issue

Cause

Solution

-

An error has been detected and occurred in the internal execution.

Please inform the support team about this detected error.

SercosNotInPhaseFour

Enumeration name:

SercosNotInPhaseFour

Enumeration value:

19

Description:

The Sercos bus is not in phase 4.

Issue

Cause

Solution

-

The parameter State of the SERCOS bus is not 4.

Set the SERCOS bus parameter PhaseSet to 4.

Verify the SERCOS bus for errors.

UnexpectedFeedback

Enumeration name:

UnexpectedFeedback

Enumeration value:

1

Description:

An unintended detected error occurred during execution.

Issue

Cause

Solution

-

An error occurred in the internal execution.

Please inform the support team about this error.

UnknownState

Enumeration name:

UnknownState

Enumeration value:

2

Description:

The POU is in an undefined state.

Issue

Cause

Solution

-

An error occurred in the internal execution.

Please inform the support team about this error.

UserPeriodRange

Enumeration name:

UserPeriodRange

Enumeration value:

177

Description:

UserPeriod is outside the valid range.

Issue

Cause

Solution

-

The input i_lrUserPeriod is negative.

For the input i_lrUserPeriod, a positive value or zero must be specified.

-

The input i_lrUserPeriod does not fit into the encoder period.

Assign the i_lrUserPeriod with zero to not consider any offset.

The input i_lrUserPeriod must be chosen such that the following formula is fulfilled:

ABS(lrEncoderPeriode/i_lrUserPeriod - TRUNC_INT(lrEncoderPeriode / i_lrUserPeriod)) = 0

with

lrEncoderPeriode := EncoderRange * FeedConstant * DINT_TO_LREAL(GearIn) / DINT_TO_LREAL(GearOut)

EncoderRange, FeedConstant, GearIn and GearOut are parameters of the i_ifDrive axis.

WaitForExecute

Enumeration name:

WaitForExecute

Enumeration value:

180

Description:

Wait for execution.

The function block is ready. As reaction to a positive edge from i_xExecute, the data is written on the encoder.

WaitUntilDriveDisabled

Enumeration name:

WaitUntilDriveDisabled

Enumeration value:

179

Description:

Waiting until the drive is deactivated.

The axis is disabled.

WaitUntilDriveEnabled

Enumeration name:

WaitUntilDriveEnabled

Enumeration value:

145

Description:

Waiting until the drive is enabled.

The function block enables the position control of the axis.

WaitUntilEncoderWritten

Enumeration name:

WaitUntilEncoderWritten

Enumeration value:

188

Description:

Waiting until the encoder has been written.

Writing is being performed on the encoder of the axis.

WritingPositionDone

Enumeration name:

WritingPositionDone

Enumeration value:

184

Description:

The encoder position has been written.

Writing on the axis encoder has been completed.