1 of 74

1

2

3

CODESYS CNC:Introduction to Operational Architecture

DIN66025 G:Code Standard

CODESYS CNC:Kinematic Model

2 of 74

AGENDA

CODESYS CNC:Introduction to Operational Architecture

2

3

DIN66025 G:Code Standard

CODESYS CNC:Kinematic Model

1

3 of 74

CODESYS CNC

CODESYS CNC Frame

CNC Editor

IEC-Application

Drive Interface

Interpolator

Inverse kinematics transformation

kinematics transformation

Buffer

Buffer

Decoder

Path- pre-

processor(s)

OutQueue

OutQueue

CNC_REF

4 of 74

CNC Editor

Graphical DIN 66025 editor (G-code support)

G-code editing

Graphical display

5 of 74

CNC Editor

CNC Editor in Visualization

6 of 74

CNC Editor

7 of 74

CNC Editor

Changing the Graphics Editor Display

Edit CNC code

Import/export CNC codes

CNC菜单栏

8 of 74

CNC Editor

switch between both views

Accelerate.

Uniform speed

Decelerate

9 of 74

CNC Editor

10 of 74

SMC_OutQueue

SMC_CNC_REF

File

SMC_NCDecoder

SMC_ReadNCFile

Path �preprocessing

SMC_CheckVelocity

Interpolator

SMC_RoundPath SMC_SmoothPath

。。。

CNC Code Analysis

11 of 74

Buffer

(ARRAY [x..y] OF SMCGeoInfo)

Buffer

(ARRAY [x..y] OF SMCGeoInfo)

SMC_Interpolator

3

4

7

6

5

8

NC_Decoder

SMC_SmoothPath

SMC_CheckVelocities

2

1

Data processing queue

CNC Code Analysis

12 of 74

Path preprocessing method

Configuration in the editor

- Display of pre-processing results in the graphical editor

  • Creation of CNC files in OutQueue format.

PLC program realization

  • Via FunctionBlocks

CNC path preprocessing

13 of 74

Configure path preprocessing in CNC settings

CNC path preprocessing

14 of 74

SMC_CheckVelocities

The main task of this function block is to check the path of sharp bends and reduce the speed at these bends to zero.

Allowable Angle Limit🡪 dAngleTol bCheckAddAxVelJumpChecking additional axis speed jumps dMaxAddAxVelDifferenceMaximum permissible velocity step jump from axis

dAngleTol = 5,000

constant velocity

dAngleTol = 0,001

acceleration

deceleration

CNC path preprocessing

15 of 74

SMC_RoundPath

Adds an arc path between two lines

Input:

  • OutQueue (poqDataIn)
  • Distance from edge dRadius(added to Dxx in G code)
  • Allowable angle limit(dAngleTol)
  • New OutQueue buffer

Output:

  • OutQueue (poqDataOut)

bAbort:Termination block handling

bAppend: This input set to FALSE clears the DataOutQueue each time it is reset. set it to TRUE and the new incoming data will be written to the end of the DataOutQueue.

CNC path preprocessing

16 of 74

SMC_RoundPath

nSizeOutQueue:UDINT

OutQueue buffer value size

pbyBufferOutQueue:POINTER TO A

OutQueue buffer Pointer

CNC path preprocessing

17 of 74

CNC path preprocessing

18 of 74

SMC_RoundPath

d

d=min(1/2L1, 1/2L2, (dRadius+D))

L1

L2

First path length L1 Second path length L2 Distance from corner to cutoff point d G52 D?

Therefore, the object is cut to at most half the length of the shorter object.

CNC path preprocessing

19 of 74

SMC_RoundPath

G Activation in code

G52 Activate circular path

G50 Cancel circular path

D Distance from edge

Example: G52 D10

CNC path preprocessing

20 of 74

For smoothing edges (using spline)

Input:

  • Distance from edge dEdgeDistance (Dxx appended to G-code)
  • New OutQueue buffer
  • bSymetricalDistances symmetry distance
  • eMode

SP_SPLINE3: Insert 3rd order spline.

SP_SPLINE5: Insert 5th order spline.

SMC_SmoothPath

bSymetricalDistances TRUE

bSymetricalDistances FALSE

CNC path preprocessing

21 of 74

SMC_SmoothPath

Output:

  • OutQueue (poqDataOut)

How to activate?

G51 activates smoothing

G50 de-activate smoothing

D (distance from edge)

Example: G51 D10

CNC path preprocessing

22 of 74

SMC_SmoothAddAxes

This function smoothes the motion of additional axes that are distributed among multiple objects. This allows the additional axes P, Q, U, V, W to have the same slope and the axes A, B and C to use optimized polynomial motion profiles.

How to activate?

G71 Lxx Activate Smooth G70 Lxx Deactivate

In the case of additional axes A, B and C, the user can determine which part of the path is available to the additional axes for acceleration/deceleration and which part runs at a constant speed. 0: no acceleration/deceleration phases are set. 1: no constant motion can be generated. 0.5: the acceleration phase plus the deceleration phase takes the same amount of time as the constant motion. In the case of additional axes A, B and C, the user can determine which part of the path is offered to the additional axes for acceleration/deceleration and which part runs at constant speed.

CNC path preprocessing

23 of 74

SMC_SmoothBSpline

Segments of consecutive G1 elements are smoothed using five B-splines. Each segment consisting of at least five consecutive G1 elements of non-zero length is replaced by a spline. The start and end positions of the G1 elements are used as control points for the created B Spline Curve. Only the start and end positions of the segments are interpolated exactly.

H functions are not supported

Changes to G51, G52, G40, etc. are not supported and will be ignored

3D mode required

Can be turned on and off from G code using G38/G39

CNC path preprocessing

24 of 74

  • TC_BLIND_POS:
  • TC_RAMP_IN:

Inserts an empty run path element. Accelerate to the second element.

SMC_ToolCorr

Function block for tool radius correction

Input:

  • OutQueue (poqDataIn)
  • Tool radius dToolRadius (appended to Dxx in G-code)
  • New OutQueue buffer
  • eMode

CNC path preprocessing

25 of 74

SMC_ToolCorr

Output:

  • OutQueue (poqDataOut)

How to activate?

G40 Tool radius compensation off

G41 Left tool radius compensation

G42 Right tool radius compensation

D (tool radius)

Example: G41 D13

CNC path preprocessing

26 of 74

SMC_ToolCorr

G41 Left tool radius compensation

Original path

G42 Right tool radius compensation

CNC path preprocessing

27 of 74

SMC_AvoidLoop

Function blocks are used to eliminate loops in the path.

Input:

  • OutQueue (poqDataIn)
  • New OutQueue buffer
  • Outputs:
    • OutQueue (poqDataOut)

How to activate?

G61 Avoid Cycling On

G60 Cycle Avoidance Off

Example: G61

CNC path preprocessing

28 of 74

G42

right tool radius compensation

Tool change

Activation Avoidance Cycle

SMC_AvoidLoop

CNC path preprocessing

29 of 74

Other FBs for path preprocessing

There is no need to activate it in G-code.

Configuration/Programming Only

Input:

  • OutQueue (poqDataIn)
  • New OutQueue buffer

Output:

  • OutQueue (poqDataOut)

CNC path preprocessing

30 of 74

SMC_CheckForLimits

Checks if the position of the defined axis (X,Y,Z,...) is between piMin and piMax.

Enter wAddAxis to specify the axis to be checked

X – Bit0

Y – Bit1

Z – Bit2

CNC path preprocessing

31 of 74

SMC_ExtendedVelocityChecks

This function limits the velocity, acceleration, and deceleration of the path so that the final velocity, acceleration, and deceleration of the additional axes (P, Q, U, V, W, A, B, C, and Z in 2D mode) do not exceed the values set in F and E. The final velocity, acceleration, and deceleration of the additional axes will not exceed the values set in F and E.

These restrictions are usually found in G codes using the G code words FZ, FP, FQ, FU, FV, FW, FA, FB, FC, and EZ, EP, EQ, EU, EV, EW, EA, EB, EC.

FZ0, FP0, ... , FC0 Reset the speed limit of the additional axes. EZ0, EP0, ... , EC0 Reset the acceleration or deceleration limits of the additional axes. , EC0 Reset the acceleration or deceleration limits of the additional axes. FZ and EZ are only valid in 2D mode.

CNC path preprocessing

32 of 74

CNC路径预处理

SMC_LimitCircularVelocity

This function block limits the path speed of circular elements based on their radius.

This function block controls the transition between two elements (a line on an arc, an arc on a line, or an arc on an arc) and adjusts the ending velocity of the first element so that the acceleration jumps do not exceed the value dMaxAccJump. In addition, the function block limits the acceleration in the X and Y directions to the value dMaxAcc.

CNC path preprocessing

33 of 74

SMC_LimitDynamics

This function block reduces the velocity and acceleration/deceleration of the path so that the final velocity, acceleration, and deceleration of the Cartesian axes and the additional axes do not exceed the input values dMaxVel, dMaxAcc, and dMaxDec. --- (This is a limit set at the pin that will not be exceeded)

Enter wAddAxis to specify the axis to be checked

X – Bit0

Y – Bit1

Z – Bit2

CNC path preprocessing

34 of 74

34

FB blocks for management

  • SMC_RotateQueue2D
  • SMC_ScaleQue3D
  • SMC_TranslateQueue3D

CNC path preprocessing

35 of 74

35

SMC_RotateQueue2D

This function block will rotate the path stored in poqDataIn around the z-axis by the angle given by dPhi[°]

  • dPhi

Positive values -> rotate counterclockwise

Negative values -> rotate clockwise

CNC path preprocessing

36 of 74

36

SMC_ScaleQueue3D

This function block will stretch the path contained in poqDataIn by the factor fScaleFactor.

CNC path preprocessing

37 of 74

37

SMC_TranslateQueue3D

This function block transforms the paths stored in poqDataIn according to the vector given by vec

vecSMC_VECTOR3D

CNC path preprocessing

38 of 74

View path preprocessing in CNC Editor

Configure path preprocessing in CNC settings

Activate "Show Path Preprocessing"

1

2

CNC path preprocessing

39 of 74

1

5

3

4

2

CNC Program Structure

40 of 74

Y+

SMC_Interpolator

Calculate the position of a given path at certain time intervals

CNC interpolator

41 of 74

SMC_Interpolator

  • SMC_OUTQUEUE (FB)

Used to convert the continuous path described by the SMC_GEOINFO object to discrete path position points

  • SMC_GEOINFO (STRUCT)

Used to store a path object

  • SMC_POSINFO (STRUCT)

Position of additional axes describing their coordinates and specific location points

CNC interpolator

42 of 74

SMC_Interpolator

  • Input:bExecute
  • PoqDataIn (OutQueue) (Path)
  • Deceleration stop(bSlow_Stop)
  • Emergency stop(bEmergency_Stop
  • Waiting stopbWaitAtNextStop
  • Magnification(dOverride
  • Speed Mode(iVelMode)

Trapezoidal

    • S-shape
  • Cancel(bAbort)
  • One-step(bSingleStep)

Confirmation of M function(bAcknM)

CNC interpolator

43 of 74

SMC_Interpolator

  • DonebDone
  • Position (point of contour) (piSetPosition)
  • Current stateiStatus

Current point path speed (dVel)

  • Current point path tangent(vecActTangent)
  • Line number of the current processing path (iActObjectSourceNo)
  • Path Switch , H Function(dwSwitches)
  • Distance calculation (dWayPos)

M Function (wM)

CNC interpolator

44 of 74

SMC_Interpolator2Dir

Ability to interpolate a trajectory inversely

CNC interpolator

45 of 74

SMC_XInterpolator

  • SMC_XInterpolator Function blocks enable the mixing of CAM and CNC.

CNC interpolator

46 of 74

SMC_Interpolator

Input:

  • poqDataIn (OutQueue) (Path)
  • Velocity Mode(iVelMode)

Trapezoidal

    • S-shaped
  • magnification(dOverride
  • cancel(bAbort)
  • one-step(bSingleStep)
  • Confirmation of M function(bAcknM)

CNC interpolator

47 of 74

SMC_Interpolator

Output:

  • Position (point of contour) (piSetPosition)

Current point path speed (dVel)

  • Current point path tangent(vecActTangent)
  • Line number of the current processing path (iActObjectSourceNo)
  • Path switch (dwSwitches)
  • Distance calculation (dWayPos)

M Function (wM)

CNC interpolator

48 of 74

AGENDA

1

3

2

CODESYS CNC:Introduction to Operational Architecture

DIN66025 G:Code Standard

CODESYS CNC:Kinematic Model

49 of 74

The German standard DIN 66025 is one of the most advanced international CNC standards and is widely used in Europe.

G代码

G - code

50 of 74

G代码

G-code

(This is a nice G code program) N000 F100 E100 E-100

N010 G01 X100 Y100

Each line represents a path (in red).

Each line consists of multiple keywords (in blue)

Each keyword defines a variable value

Each line starts with N+number (e.g. "N010")

Comments are put in brackets

27

G - code

51 of 74

28

(This is a nice G code program)

1 2 3

N000 F100 E100 E-100 N010 G01 X100

4 5

  • F for feed rate [path-units/sec] (feed)
  • E+ positive value indicates acceleration [path-units/sec2]

  • E+ negative for deceleration [path-units/sec2]

G01 is linear interpolation (see online help for other G-code commands).

Move 100 units in phase X direction (direction + distance)

Don't forget the speed of movement and acceleration and deceleration!

G代码

G-code

G - code

52 of 74

N010 G01 X100

🡪Move to position X100 at speed 100

N020 G01 Y100

🡪Move in the Y direction with a speed of 100, using the original position as a reference point.

N030 G01 X0 Y0 F50

🡪Move to position X0,Y0 at speed 50.

N040 G01 Y100

🡪Move in the Y direction with speed 50 to position 100

29

G代码

G-code

N000 F100 E100 E-100

G - code

53 of 74

program)

N010 G01 X100

N020 G01 Y100

N030 G01 X0 Y0

N040 G01 Y100

N050 G01 X50 Y150

N060 G01 X100 Y100

G-code

(This is a nice G code

N000 F100 E100 E-100

N070 G01 X0

N080 G01 X100 Y0

30

Y+

X+

Basic Information

54 of 74

G代码

Commonly used G-code

CODESYS 版权所有

G-Code

Description

G01

Linear interpolation

G02

Clockwise interpolation

G03

Counterclockwise interpolation

G04

Pause

G05

2D spline

G06

Parabola

G08

Clockwise Ellipse

G09

Counterclockwise ellipse

G10

3D Spline

G - code

55 of 74

G代码

Commonly used G-code

CODESYS 版权所有

CODESYS 版权所有

G-Code

Description

G15

Switch to 2.5D mode

G16

Specify normal vector by I/J/K in the plane Switch to 3D mode

G17

Switch to 3D mode in X/Y plane.

G18

Switch to 3D mode in the Z/X plane.

G19

Switch to 3D mode in the Y/Z plane.

G - code

56 of 74

G代码

Commonly used G-code

CODESYS 版权所有

CODESYS 版权所有

G-Code

Description

G20

Jump to the specified line of G-code

G36

Writing the value of a variable

G37

Adding a value to a variable

G - code

57 of 74

G代码

Commonly used G-code

CODESYS 版权所有

G-Code

Description

G40

Cancel Tool Compensation

G41

Tool Compensation-Left

G42

Tool Compensation-Right

G43

Tool Length Compensation

G - code

58 of 74

G代码

Commonly used G-code

G-Code

Description

G50

Cancel smoothing/rounding

G51

Corner smoothing

G52

Corner Rounding

G - code

59 of 74

G代码

Commonly used G-code

G-Code

Description

G53

Canceling Coordinate Offset

G54

Absolute transformation of the coordinate system

G55

Relative transformation of the coordinate system

G56

Set current point as reference point

G60

End loop suppression

G61

Start cycle suppression

G - code

60 of 74

G代码

Commonly used G-code

G-Code

Description

G70

Cancel Additional Axis Smoothing

G71

Additional Axis Smoothing

G75

Wait before interpolation

G - code

61 of 74

G代码

Commonly used G-code

CODESYS 版权所有

CODESYS 版权所有

G-Code

Description

G90

Absolute Motion Mode

G91

Relative Motion Mode

G92

Setting the machining coordinate system

G98

Center point (I/J/K) absolute mode

G99

Center point (I/J/K) relative mode

G - code

62 of 74

Supported dimensions.

X Y Z: Cartesian coordinate system A B C: rotation axis

P Q U V W: additional axis

Defining Motion Limits: F: Velocity Definition

E+: acceleration definition E-: deceleration definition

Interacting with other processes:

M: Execute machine start-up action and wait for confirmation

H: Position monitoring logic switch

G - code

63 of 74

AGENDA

1

CODESYS CNC:Introduction to Operational Architecture

2

DIN66025 G:Code Standard

CODESYS CNC:Kinematic Model

3

64 of 74

CNC运动学变换

Kinematic Transformation

  • The interpolator outputs the position (X,Y,Z,...) in the Cartesian coordinate system via piSetPosition.
  • Cartesian coordinate system -> Axis coordinate system (according to the mechanical structure) .

Gantry (position  position)

Scara (position→ angle)

CNC Kinematic Transformation

65 of 74

Supported kinematic models

Gantry systems (2-axis/3-axis)

Gantry system with tools

CNC Kinematic Transformation

66 of 74

Supported kinematic models

Gantry system with rotary cutting axis

CNC Kinematic Transformation

67 of 74

Supported kinematic models

Gantry 5-axis system

CNC Kinematic Transformation

68 of 74

Supported kinematic models

H Gantry

T Gantry

CNC Kinematic Transformation

69 of 74

Supported kinematic models

polar coordinate system

CNC Kinematic Transformation

70 of 74

Supported kinematic models

Scara robot

CNC Kinematic Transformation

71 of 74

Supported kinematic models

parallel robot

CNC Kinematic Transformation

72 of 74

Supported kinematic models

4-axis palletizing robot

CNC Kinematic Transformation

73 of 74

Supported kinematic models

6-axis robot

CNC Kinematic Transformation

74 of 74

CNC DEMO

COD