Creating and initializing NC axis
There are several ways to create an NC axis. One possible procedure is shown below as an example.
- 1. Create the three instances of the following objects:
fbCarriageAxis (FB_AxisNcBase): TF8560 axis (here NC)
fbCarriage (FB_Carriage): Specifically implemented axis type (here carriage axis)
fbCarriageHmi (FB_CarriageHmi): Parallel HMI interface of the axis type (here carriage axis)
{attribute 'qualified_only'}
VAR_GLOBAL
{attribute 'TcHmiSymbol.Hide'}
{attribute 'TcContextName':='MotionTask'}
fbCarriageAxis: FB_AxisNcBase('', Tc3_PlasticBaseAppStaticParams.cnMaxPtpPoints, 0, 0, 0);
{attribute 'TcHmiSymbol.Hide'}
fbCarriage: FB_Carriage;
fbCarriageHmi: FB_CarriageHmi;
END_VAR
- 2. Create/link an NC axis in the project to the created instance of the
fbCarriage
axis.
If the TF8560 axes from the PLC do not appear in the selection dialog, the project has not been created. Only once the PLC project has been successfully created after the instance has been created, the instances become visible in the mapping. - 3. It is recommended that you create a PLC task with the same cycle time of the NC (default 2 ms) for the drive control part (if an axis does not already exist).
- 4. Assign a TF8560 axis to the specific axis in the PLC.
Axes.fbCarriage.SetAxisRef(Axes.fbCarriageAxis);
- 5. Add the axis to the runtime.
Tasks.fbRuntime.Append(Axes.fbCarriage, Axes.fbCarriageHmi);
If you do not want to work with FB_BaseRuntime, the following further steps are necessary:
- 6. Assign the HMI interface to the specific axis.
Axes.fbCarriage.SetHMI(Axes.fbCarriageHmi);
- 7. Initialize the axis with a single call to the
Init()
method and check the return values.
IF NOT bInit THEN
bInit := TRUE;
Axes.fbCarriage.SetAxisRef(Axes.fbCarriageAxis);
Axes.fbCarriage.SetHMI(Axes.fbCarriageHmi);
hr := Axes.fbCarriage.Init();
bInitFailed := FAILED(hr);
END_IF
- 8. After successful initialization, call the
CoreCyclic()
method of the axis with a fast task.
IF NOT PRG_AxisApplication.bInitFailed THEN
Axes.fbCarriage.CoreCyclic();
END_IF
- 9. In parallel with the
CoreCyclic()
method, call theCyclic()
method in a slower task and initialize the default parameterization using theParamInit()
method.
VAR
bInit: BOOL;
bInitFailed: BOOL;
bParamInit: BOOL;
hr: HRESULT;
END_VAR
IF NOT bInit THEN
bInit := TRUE;
Axes.fbCarriage.SetAxisRef(Axes.fbCarriageAxis);
Axes.fbCarriage.SetHMI(Axes.fbCarriageHmi);
hr := Axes.fbCarriage.Init();
bInitFailed := FAILED(hr);
ELSIF NOT bInitFailed THEN
IF NOT bParamInit THEN
hr := Axes.fbCarriage.ParamInit();
bParamInit := SUCCEEDED(hr);
END_IF
Axes.fbCarriage.Cyclic();
END_IF