Skip to content

Function Blocks

FB_Component_NciBase

(extends FB_ComponentBase, implements I_NciChannel and I_NciBase)

Serves as manager for NCI basic functions as Load/Start and Stop the NCI channel.

Requires to be linked to desired NCI Channel object via NcToPlc and PlcToNc.

Quickstart
  1. Create instance of FB.

    1
    Nci : FB_Component_NciBase := (Name := 'Nci', Override := 1_000_000);
    

  2. Link FB to Interpreter NcToPlc and PlcToNc.

  3. Assign the Axis Ids and build the Nci Group.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    10: // Startup
        Nci.XAxisId  := X.Axis.NcToPlc.AxisId;
        Nci.YAxisId  := Y.Axis.NcToPlc.AxisId;
        Nci.ZAxisId  := Z.Axis.NcToPlc.AxisId;
        Nci.Q1AxisId := Q1.Axis.NcToPlc.AxisId;
        IF Nci.BuildNCIGroup() THEN
            Seq := Seq + 10;
        END_IF
    
    20: // Done
        IF NOT Nci.Busy AND NOT Nci.Error THEN
            Seq := Seq + 10;
        END_IF
    
  4. Load the .nc file into the interpreter

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    30: // Load Nc Program
        Nci.ProgramPath := 'C:\TwinCAT\Mc\Nci\9999.nc';
        IF Nci.LoadNciProgram() Then
            Seq := Seq + 10;
        END_IF
    
    40: // Done
        IF NOT Nci.Busy AND NOT Nci.Error THEN
            Seq := Seq + 10;
        END_IF
    

  5. Start Interpreter

    1
    2
    3
    4
    5
    6
    7
    8
    9
    50:
        IF Nci.InterpreterStart() THEN
            CIRSeq := CIRSeq + 10;
        END_IF
    
    60:
        IF Nci.InterpreterState >= NCI_INTERPRETER_RUNNING AND NOT Nci.Busy AND NOT Nci.Error THEN
            CIRSeq := CIRSeq + 10;
        END_IF
    

Example .nc file

Create file with .nc ending that contains the following code.

1
2
G00 X100 Y100 Z100
G00 X0 Y0 Z0

Properties

Property Type Access Description Classification
ProgramPath String GET/SET Program Path for .nc file to load Config
Override UDINT SET Override in 0..1000000 (0..100%) Start-Stop
Jerk LREAL SET Jerk for E-Stop deceleration Start-Stop
Deceleration LREAL SET Deceleration for E-Stop Start-Stop
InterpreterState UINT GET Feedback interpreter state
IsHandshake BOOL GET Feedback if handshake M-Code is active M Functions
GetHskMFunction INT GET Get number of handshake M-Code M Functions
GroupIsBuilt BOOL GET NCI Group is built Config
BlockSearchStartPosition ST_ItpBlockSearchStartPosition GET Startposition when blocksearch was executed Retracing
XAxisId BOOL GET/SET Axis Id Config
YAxisId BOOL GET/SET Axis Id Config
ZAxisId BOOL GET/SET Axis Id Config
Q1AxisId BOOL GET/SET Axis Id Aux Axis Config
Q2AxisId BOOL GET/SET Axis Id Aux Axis Config
Q3AxisId BOOL GET/SET Axis Id Aux Axis Config
Q4AxisId BOOL GET/SET Axis Id Aux Axis Config
Q5AxisId BOOL GET/SET Axis Id Aux Axis Config

Note

Axis Ids are to find in the corresponding axis object NCTOPLC_AXIS_REF.AxisId.

Methods

Method Return Type Description Classification
BuildNciGroup BOOL Build Nci group with assigned AxisIds. Uses CfgBuildExt3DGroup Config
LoadNciProgram BOOL Loads .nc file from ProgramPath into interpreter. Uses ItpLoadProgEx Config
DissolveNciGroup BOOL Dissolve built Nci group. Uses CfgReconfigGroup Config
InterpreterStart BOOL Start interpreter execution. Uses ItpStartStopEx Start-Stop
InterpreterStop BOOL Stop interpreter execution. Uses ItpStartStopEx Start-Stop
InterpreterStopOnPath BOOL Stop movement on path, enables the possibility of resume. Uses ItpEstopEx Start-Stop
ResumeAfterEstop BOOL Resumes movement after Stop on Path. Uses ItpStepOnAfterEStopEx Start-Stop
EnableRetrace BOOL Enable the possibility of retracing on path. Uses ItpEnableFeederBackup Retracing
RetraceBackward BOOL Retrace on path. Uses ItpRetraceMoveBackward Retracing
RetraceForward BOOL Retrace on path. Uses ItpRetraceMoveForward Retracing
BlockSearch BOOL Executes block search in .nc file. Uses ItpBlocksearch Retracing
SetSearchOptionFlags BOOL Configuration for Blocksearch. St_ItpBlockSearchOptions Retracing
StepOnAfterBlocksearch BOOL Activates the block of the .nc file which was searched and found, starts the interpreter. Uses ItpStepOnAfterBlocksearch Retracing
IsFastMFunction BOOL Query for active fast M-Code. If AutoReset is set to TRUE the function is reset in next cycle. Uses ItpIsFastMFunc M Functions
ConfirmHsk BOOL Confirms Handshake M-Code. Uses ItpConfirmHsk M Functions

Warning

Retracing only functional with classic dialect!

FB_Component_NciReadWriteRParameter

(extends FB_Component_NciParameterBase, implements I_NciChannel)

Properties

Property Type Access Description
Channel I_NciChannel SET Assign NCI Channel to be used for read/write operations. Assign FB_Component_NciBase

Methods

Method Return Type Description
Read BOOL Input RParameter assigned to custom defined LREAL or Array of LREAL. Will read the length of the assigned RParameter Datatype length from Nci Channels R-Parameter. StartRParameter defines the first R-Parameter to be read.
Write BOOL Input RParameter assigned to custom defined LREAL or Array of LREAL. Will write the length of the assigned RParameter Datatype length to the Nci Channels R-Parameter. StartRParameter defines the first R-Parameter to be written.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
VAR
    Nci                 : FB_Component_NciBase                      := (Name := 'Nci Channel');
    NciReadWriteR       : FB_Component_NciReadWriteRParameter       := (Name := 'Read Write R', Channel := Nci);

    RParameterToBeRead  : ARRAY[20..24] OF LREAL; // Read R-Parameter 20-24, a total of 5 R-Parameter from NCI channel.
    Read                : BOOL;
END_VAR

IF Read THEN
    Read := FALSE; 
    NciReadWriteR.Read(RParameter := RParameterToBeRead, StartRParameter := 20 ); // After successful read the values will be stored in `NciReadWriteR`
END_IF