CNCLib

CNC Library

The CNC basic library provides an easy to use interface to the B&R ARNC0 Kernel.

This library provides the basic commands that every CNC application will use. This includes program control, error handling and reading status information.

The library only takes control of the axes when they are being used for CNC functions. This means that it is compatible with existing ACP10 motion systems.

CNCLib works in conjuction with Synchro to manage automatically engaging a Robotics hierarchy where applicable.

Usage

The CNC Basic Library can be integrated into any project using the provided structures and functions calls.

Initialization

All of the initialization of the CNC basic library is handled internally. The following parameters are optional and should only be set in the INIT section of the task.

gCNCMgr.IN.CFG.CNCObjectName:=	'CNC1';

Cyclic Operation

To control the CNC kernel cyclicly, the CNCBasicFn() must be called in the CYCLIC routine of your program, once every scan unconditionally. This function typically runs in a slow task class of around ~100 ms.


// If the CNC manager is used with Synchro, assign the TCPManager to use
gCNCMgr[0].IN.CFG.pTCPManager :=	 _SynchroTCP.pTCPMgr;

// Call function block
CNCBasicFn( gCNCMgr );	

// Reset CNC Mgr commands
gCNCMgr.IN.CMD.Start:=	FALSE;
gCNCMgr.IN.CMD.RunBlock:=FALSE;
gCNCMgr.IN.CMD.StartBlockNumber:=FALSE;
gCNCMgr.IN.CMD.Continue:=FALSE;
gCNCMgr.IN.CMD.Stop:=	FALSE;
gCNCMgr.IN.CMD.EStop:=	FALSE;
gCNCMgr.IN.CMD.Pause:= 	FALSE;
gCNCMgr.IN.CMD.InitLimts:= FALSE;

Reference

Inputs

The CNC Basic inputs are divided into commands (IN.CMD), parameters (IN.PAR), and configuration settings (IN.CFG).

Commands are used to initiate operations, and parameters and configuration settings determine how the commands will be processed. The difference between parameters and configuration settings is that configuration settings are generally set only once, while parameters might be set any time a command is issued.

Configuration

These configuration settings are optional. With a standard setup the defaults will work.

  • CNCObjectName - (default: “CNC1”) The name of the ARNC0 object in the CNC Object Mapping table.
  • EnableWarnings - By default some warnings are turned off internally, this disables that behavior.
  • pTCPManager - Synchro Manager to interface with to engage axes

Commands

  • Start - Start a program [ProgramName]
  • StartBlockNumber - Start a program [ProgramName] from a block number [BlockNumber]
  • RunBlock - Start the program block given [Block]
  • Stop - Stop a program using configured stop behavior (CNC init object)
  • EStop - Stop a program using configured e-stop behavior (CNC init object)
  • Pause - Pause the current program
  • Continue - Continue the paused program
  • EnableHandWheel - Feed override is controlled by [HandWheelVelocity] x [HandWheelMult]
  • EnableSingleStep - Enables stepping through a program 1 step at a time. Continue using [Continue] command. The definition of 1 step is defined in the CNC Init Object
  • EnableSimution - Enable CNC simulation mode. This can be used to check for syntax errors before running
  • EnableSkip - Enable skip block mode. Skip blocks are denoted by /0 /1 .. /9. Which blocks are active are set in the CNC object
  • InitLimits - Intitialize the CNC limits with what is currently in the CNC object
  • AcknowledgeError - Acknowledge the active error.

Parameters

  • ProgramName - Name of a program to run.
  • Block - Short block of G-Code to run STRING[320]
  • BlockNumber - Block number within program [ProgramName] to run
  • HandWheelVelocity - Scale 0 - 100 of program speed (x HandWheelMult)
  • HandWheelMult - Scale the hand wheel sensitivity
  • IgnoreEngage - Start a program, ignoring synchro integration

Outputs

Functional Outputs

  • NCBlocks[0..4] - NC Line text of the currently active line +-2

Status Outputs

General errors

  • STAT.ErrorString - Text of active error
  • STAT.StatusString - Text of the active state (informational)
  • STAT.CurrentProgram - Name of the active program
  • STAT.ErrorID - ID of active error
  • STAT.ErrorCount - Number of active errors
  • STAT.Engaging - In the process of synchronizing the axes
  • STAT.RunningProgram - A program is currently running
  • STAT.Paused - The running program is paused
  • STAT.Finished - The last program started was successfully finished
  • STAT.Aborted - The last program started was aborted. This could be from an error or from the stop command.
  • STAT.Error - Indicates an error exists
  • STAT.Busy - The last command is busy
  • STAT.Done - The last command was finished
  • STAT.HandWheelActive - The handwheel is active
  • STAT.Simulation - CNC Simulation is active
  • STAT.SingleStep - Single step is enabled
  • STAT.Initialized - The CNC kernel is initialized and ready