Creating and initializing NC transformation axis
Several steps are necessary to create a new NC transformation axis. One possible procedure is shown below as an example.
- 1. Create the three instances of the following objects:
fbClampAxis (FB_AxisNcTrafoBase): TF8560 axis (here transformation NC)
fbClamp (FB_Clamp): Specifically implemented axis type (here clamping unit)
fbClampHmi (FB_ClampHmi): Parallel HMI interface of the axis type (here clamping unit).
{attribute 'qualified_only'}
VAR_GLOBAL
{attribute 'TcHmiSymbol.Hide'}
{attribute 'TcContextName':='MotionTask'}
fbClampAxis: FB_AxisNcTrafoBase('', Tc3_PlasticBaseAppStaticParams.cnMaxPtpPoints, Tc3_PlasticBaseAppStaticParams.cnNoOfTrafoPoints, 0, 0, 0);
{attribute 'TcHmiSymbol.Hide'}
fbClamp: FB_Clamp;
fbClampHmi: FB_ClampHmi;
END_VAR
- 2. Create/link two NC axes in the project for the drive and load sides of the created instance of the
fbClamp
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. Set the following parameterization on the NC axis of the load side:
- Axes > ClampLoad > Settings > Axis Type: = Standard
- Axes > ClampLoad > Enc > NC-Encoder > Type: = Encoder SSI
- Axes > ClampLoad > Enc > Parameter > Scaling Factor Numerator = 0.0001
- Axes > ClampLoad > Enc > Parameter > Scaling Factor Denominator = 1.0
- Axes > ClampLoad > Enc > Parameter > Position Bias = -1000.0
- Axes > ClampLoad > Enc > Parameter > Encoder Mode = POSVELOACC
And map the following variables additionally between NC and PLC:
- Axes > ClampLoad > Enc.Inputs.In.nDataIn1 <--> GVL_Xyz.fbNcTrafoAxis.fbLocalNc.fbActuals.nDataIn1
- Axes > ClampLoad > Enc.Inputs.In.nState4 <--> GVL_Xyz.fbNcTrafoAxis.fbLocalNc.fbActuals.nState4
- 4. 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).
- 5. Additionally, instantiate a Table Generator in your application to create a transformation table.
VAR
fbTableGen: FB_TableGeneratorClampStandard_1;
END_VAR
- 6. Assign a TF8560 axis to the specific axis in the PLC.
Axes.fbClamp.SetAxisRef(Axes.fbClampAxis);
- 7. Assign the Table Generator to the specific axis in the PLC.
Axes.fbClamp.Specific.Trafo.TableGenerator := fbTableGen;
- 8. Define the geometry of the mechanics to use the transformation function. In the case of the clamping unit, a standard clamping mechanism is parameterized in this sample.
Method DefineTable : HRESULT
// Assign geometries
fbTableGen.BaseDistance := 672.0; // [mm]
fbTableGen.DriveArm := 228.0; // [mm]
fbTableGen.LoadArm := 325.2; // [mm]
fbTableGen.ToolArm_1 := 602.52; // [mm]
fbTableGen.ToolArm_2 := 455.4; // [mm]
fbTableGen.ToolArm_3 := 114.0; // [mm]
fbTableGen.ToolArm_Angle := 216.0; // [mm]
fbTableGen.ToolOffset := 288.0; // [mm]
fbTableGen.DriveLowEnd := 0.0; // [°]
fbTableGen.DriveHighEnd := 180.0; // [°]
// calculate resulting point table
IF NOT fbTableGen.DefineTable() THEN
DefineTable:= F_HresultFailure(E_AdsErr.DEVICE_INVALIDPARM);
RETURN;
END_IF
// copy parameter to machine data file
fbTableGen.WriteToParamList();
// activates table in TF8560 axis
F_SucceededHr(Axes.fbClamp.Specific.Trafo.AssignTableToAxis(FALSE), DefineTable);
// copies table drive ends to nc-Softends
F_SucceededHr(Axes.fbClamp.Specific.Trafo.CopyTableDriveEnds(FALSE, FALSE), DefineTable);
- 9. Add the axis to the runtime.
Tasks.fbRuntime.Append(Axes.fbClamp, Axes.fbClampHmi);
If you do not want to work with FB_BaseRuntime, the following further steps are necessary:
- 10. Assign the HMI interface to the specific axis.
Axes.fbClamp.SetHMI(Axes.fbClampHmi);
- 11. Initialize the axis with a single call to the
Init()
method and check the return value.
IF NOT bInit THEN
bInit := TRUE;
Axes.fbClamp.SetAxisRef(Axes.fbClampAxis);
Axes.fbClamp.SetHMI(Axes.fbClampHmi);
hr := Axes.fbClamp.Init();
bInitFailed := FAILED(hr);
END_IF
- 12. After successful initialization, call the
CoreCyclic()
method of the axis with a fast task.
IF NOT PRG_AxisApplication.bInitFailed THEN
Axes.fbClamp.CoreCyclic();
END_IF
- 13. 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;
fbTableGen: FB_TableGeneratorClampStandard_1;
END_VAR
IF NOT bInit THEN
bInit := TRUE;
Axes.fbClamp.SetAxisRef(Axes.fbClampAxis);
Axes.fbClamp.Specific.Trafo.TableGenerator := fbTableGen;
Axes.fbClamp.SetHMI(Axes.fbClampHmi);
hr := Axes.fbClamp.Init();
bInitFailed := FAILED(hr);
ELSIF NOT bInitFailed THEN
IF NOT bParamInit THEN
hr := DefineTable();
bParamInit := SUCCEEDED(hr);
hr := Axes.fbClamp.ParamInit();
bParamInit := bParamInit AND SUCCEEDED(hr);
END_IF
Axes.fbClamp.Cyclic();
END_IF