Question

Is there a way to read out the drive parameters found in the parameter tab in TwinCAT?

In my code, I want to check if the fast axis stop is enabled. This option can be set if you select MOTION > Axes > {Your Axis} and open the Parameter tab. I've tried to find these options in the process parameters that can be read out using CoE, but these options are not there.

enter image description here

When you hover over a parameter, an index and an offset are shown, but I'm not sure how or where this can be read.

 3  63  3
1 Jan 1970

Solution

 3

This is achieved using the MC_ReadParameter function block.

The relevant parameters are these:

AxisFastStopSignalType,             (* dword *) (* IndexOffset= 16#0000_001E *)
AxisFastAcc,                        (* lreal *) (* IndexOffset= 16#0000_010A *)
AxisFastDec,                        (* lreal *) (* IndexOffset= 16#0000_010B *)
AxisFastJerk,                       (* lreal *) (* IndexOffset= 16#0000_010C *)
2024-07-02
Jakob

Solution

 1

To elaborate on Jakobs answer, a complete working example.

Note: For the ParameterNumber you have to use the ENUM MC_AxisParameter, using the integer directly like _maxVelocityIndex : INT := 16#0000_0027;, doesn't work.

VAR
    axisRef : REFERENCE TO AXIS_REF;
    _mcReadDriveParameter : MC_ReadParameter;
    _maxVelocity : LREAL;
END_VAR

_mcReadDriveParameter(
    Axis:=axisRef, 
    Enable:=TRUE, 
    ParameterNumber:=MC_AxisParameter.AxisMaxVelocity
);
IF _mcReadDriveParameter.Error THEN
    // Implement error handling
    ...
    // Disable the fucntion block again
    _mcReadDriveParameter(Axis:=axisRef, Enable:=FALSE);
ELSIF NOT _mcReadDriveParameter.Busy THEN
    _maxVelocity := _mcReadDriveParameter.Value;
    _mcReadDriveParameter(Axis:=axisRef,Enable:=FALSE);
END_IF

2024-07-17
Roald