Teach

This core function is used for referencing analog encoder systems.
Syntax:
FUNCTION_BLOCK FB_Teach EXTENDS FB_CorefunctionFeedback
Properties
Name | Type | Access | Description |
|---|---|---|---|
InitState | BOOL | Get, Set | The core function is not completely and successfully initialized. |
FB_Teach | |||
AllowAxisDisable | BOOL | Get, Set | If |
IncrNeg | DINT | Get, (Set) | The recorded value when executing |
IncrPos | DINT | Get, (Set) | The recorded value when executing |
MinResolution | UDINT | Get, Set | The minimum resolution (between |
MinStroke | LREAL | Get, Set | The minimum stroke required for a meaningful result. |
Position | LREAL | Get, Set | The position setpoint to be set at the taught (teach) position. If |
SetUpperPosition | BOOL | Get, Set | If |
Stroke | LREAL | Get, Set | The distance (or stroke) that is spanned between |
Valid | BOOL | Get | Two valid values were recorded. |
FB_CorefunctionFeedback | |||
AbortedState | BOOL | Get, Set | Signals the abort of a command by another Corefunction. |
BusyState | BOOL | Get, Set | Signals the active execution of a command. |
DoneState | BOOL | Get, Set | Signals the successful execution of a command. |
IdleState | BOOL | Get, Set | The Corefunction is ready for operation and commandable. |
IsCommanded | BOOL | Get | Signals the pending of a command. |
FB_Corefunction | |||
FailedState | BOOL | Get, Set | If IsActivated is TRUE at the same time: Signals the failure of an accepted command. If IsActivated is FALSE at the same time: Signals the rejection of a command. |
HasFeedback | BOOL | Get | The core function has responded to a pending command. |
IsActivated | BOOL | Get | The core function has an accepted command pending. |
IsLocalCmd | BOOL | Get | Signals that the axis is assigned with a command of this core function. |
ReadyState | BOOL | Get, Set | The Corefunction is ready for operation, but is not commandable at this time. Possible reasons are: |
Methods
Name | Description |
|---|---|
[ | This method is called cyclically by the axis. |
FB_Teach | |
DoTeach( | Sets the axis to teaching mode. Teaching mode is ended prematurely on a falling edge. |
DoUpdate( | Triggers the final calculation of the encoder parameters. |
TeachNeg( | Triggers the recording of the lower position. |
TeachPos ( | Triggers the recording of the upper position. |
Interfaces
Type | Description |
|---|---|
I_Corefunction | Standard interface on FB_Corefunction. |
FB_Teach | |
I_Teach | Standard interface on FB_Teach. |
I_TeachDev | Extended interface with access to the inaccessible properties. |
I_TeachPosition | Compatibility interface to the obsolete FB_TeachPosition function. |
I_TeachUpdate | Compatibility interface to the obsolete FB_TeachUpdate function. |
I_CorefunctionFeedback | Standard interface on FB_CorefunctionFeedback. |
Example:
CASE nState OF
0: // activate the teach mode
IF bStartTeaching AND iAxisBase.Teach.IdleState THEN
iAxisBase.Teach.DoTeach(TRUE);
ELSIF iAxisBase.Teach.BusyState THEN
nState := nState + 1;
ELSIF iAxisBase.Teach.FailedState THEN
nState := -1;
END_IF
1: // move to the first teach position
// approaching the upper position by a jog command
// e.g. by pressing a push button
iAxisBase.Jog.DoJogP(bButtonFwd);
// on reaching final position, use a second button to teach the value
iAxisBase.Teach.TeachPos(bTeach);
IF bTeach THEN
iAxisBase.Jog.DoJogP(FALSE);
nState := nState + 1;
END_IF
2: // wait for teach button release
IF NOT bTeach THEN
nState := nState + 1;
END_IF
3: // move in the opposite direction for the second teach position
// approaching the lower position by a jog command
// e.g. by pressing a push button
iAxisBase.Jog.DoJogM(bButtonBwd);
// on reaching final position, use the second button again to teach the value
iAxisBase.Teach.TeachNeg(bTeach);
IF bTeach THEN
iAxisBase.Jog.DoJogM(FALSE);
nState := nState + 1;
END_IF
4: // configure teach parameters and update the axis by the taught positions
iAxisBase.Teach.AllowAxisDisable := TRUE;
iAxisBase.Teach.Position := 0.0; // mm
iAxisBase.Teach.Stroke := 200.0; // mm
IF iAxisBase.Teach.Valid THEN
iAxisBase.Teach.DoUpdate(TRUE);
nState := nState + 1;
ELSE
nState := -1;
END_IF
5: // wait for the update procedure getting done
IF iAxisBase.Teach.DoneState THEN
nState := nState + 1;
ELSIF iAxisBase.Teach.FailedState THEN
nState := -1;
END_IF
6, // teaching done
-1: // error
iAxisBase.Teach.DoTeach(FALSE);
iAxisBase.Teach.DoUpdate(FALSE);
END_CASE
Requirements
Development environment | Target platform | PLC libraries to include |
|---|---|---|
TwinCAT v3.1.4024.71 | PC or CX (x64, x86) | Tc3_PlasticFunctions (>= v12.12.0.0) |