You are on page 1of 28

6.

13: Case Study: Pseudo Code for EIA-274D Interpreter

Pseudo Code provides the logic for developing a computer program without referring to
semantics of a high or low level language. This case study provides pseudo code logic for
developing EIA-274D: 1979 interpreter. Once the pseudo code logic is developed the interpreter
can be programmed using any lower high level language. An interpreter executes each command
after reading it unlike compiler that makes an .exe file once the whole program is available and
has no semantic error in it.

To perform this exercise a control block for the machine tool controller combination need to be
defined. A control block provides the format and syntax of command in the way those appear in
the part program.

The next task is the selection of commands from the large set of commands available in EIA
274D: 1979 standard to demonstrate the pseudo coding. Following section provide the control
block; and, selected G&M pseudo codes from EIA274D1979 standard for pseudo coding.

A 3-axes open loop CNC milling machine is considered for this exercise. The axes motors are
stepper motor while the spindle motor is an AC servo motor. Spindle speed is automatically
adjusted as per given speed command within the available speed range.

7.8.1. Selected G&M Code Command Set:

The pseudo code for the CNC machinery shall be the first step for all the programmable
functions of the real machine tool. Real CNC machinery generally implements part of the
requisite features targeted to a section of industry for which the machine tool is designed and
built. In order to demonstrate operation of the pseudo coding using EIA 274D: 1979, following
G & M command set is selected. These are most common type of command used at G & M code
based CNC machinery.

The control block for the controller machine tool combination is:

G2 M2 X4.2 Y4.2 Z4.2 I 4.2 J4.2 K 4.2 F2 S4 T2

This control block specifies that the N command (sequence number) is not used. The format of
numeric value specific that e.g. If there is a whole number, the command is followed by as many
digits. The Numerical Values with decimals points e.g. 4.2 specifies that there are four digits
before the decimal point and two digits after the decimal point,

“Space” is taken as command separator and carriage Return (CR) represents the end of block.
End of file (EOF) is the end of part program. No error trapping is introduced in the pseudo
codding. If this interpreter encounters an error it shall stop working.

The selected G&M code commands are given as under:

"G00" point to point movement - positioning


"G01" linear interpolation
"G02" circular interpolation (clockwise – two dimensional
“G70" inch programming
“G71" metric programming
“G90" absolute dimension input
“G91" incremental dimension input

"M02" stop / end of program


"M03" spindle on - clockwise
“M04" spindle on – counter clockwise
“M05" spindle off
"M07" coolant on - mist
"M08" coolant on - flood
“M09" coolant off

“I" polar coordinate (x axis)


“J" polar coordinate (y axis)
“K” polar coordinate (y axis)
“F" feed
“S" spindle speed
“T" Tool

"X" movement in (+ve) x-direction


"Y" movement in (+ve) y-direction
"Z" movement in (+ve) z-direction

The architecture of the interpreter is designed such that it addresses following main steps while
reading the ASCII part program file:

(i) It performs the command identification step


(ii) It performs the command formation step
(iii) It performs the command execution step

Following flow charts takes into account the above procedure while describing development of
pseudo code for EIA 274D: 1979 Interpreter.

Command Identification: Command identification identifies each letter in the part program.
The first flow chart for command identification is given as under. The process of command
identification proceeds by reading a letter, from the ASCII part program file, comparing it with
the selected G&M code set and forwarding it to command formation stage.
yes
START Is it G Go to Sub-Prep

no
yes
Is it M Go to Sub-Misc

no
yes
Is it X Go to Sub-Axes

no
yes
Is it Y Go to Sub-Axes

no
yes
Is it Z Go to Sub-Axes

no
yes
Is it I Go to Sub-Axes

no
yes
Is it J Go to Sub-Axes

no
yes
Is it K Go to Sub-Axes

no
yes
Is it F Go to Sub-Feed

no
yes
Is it S Go to Sub-Speed

no
yes
Is it T Go to Sub-Tool

no

Is it yes Go to next command


Space RETURN

no
yes
Is it CR Go to Next Block RETURN

no
Is it yes
EOF
Stop

no
Command formation:
Command formation concatenates the letter with its associated numerical value and sets the
necessary flags required at the execution stage. Following subroutines perform the command
formation based on defined control block for specific controller machine tool combination.
(a) SUB-PREP (For G Functions)

B
B

Build Command & Set Flag

Go Sub Command Execution

STOP
(b) SUB – MISC (FOR M Functions)

B
B

Build Command & Set Flag

Go Sub Command Execution

STOP
(c) SUB – AXES (ASSUMING ALL +VE) (For Axes & Polar coordinates)

no
Check the next letter It is Numeric

yes

no
Next is Numeric

yes

no
Next is Numeric

yes

no
Next is Numeric ERROR

yes

no
Next is point (.)

yes

no
Next is Numeric

yes

Next is Numeric no

A
A

Yes
B
Next letter
is Space

No

Yes
Next letter B
is CR

No

Next letter Yes C


is EOF

Error
B

Build Command

Check G Flags &


M Flags

Calculate Steps

Go sub command
execution

Return
C

Build Command

Check G Flags &


M Flags

Calculate Steps

Go sub command
execution

STOP
(d) Sub Feed (for F)

Check Next Letter Is it No


ERROR
Numeric?

Yes

Is it No
ERROR
Numeric?

Yes

Next is Yes A1
Space

No

Next is CR Yes A1

No

Next is EOF Yes B1

No

ERROR
A1

Build Command And


set flag

Go sub Command
execution

Return

B1

Build Command And


set flag

Go sub Command
execution

STOP
(e) Sub Speed (for S)

No
Check the next letter It is Numeric

yes

Next is Numeric No

yes

No
Next is Numeric Error

yes

No
Next is Numeric
No
yes

Next is space No Next letter Yes A2


is CR

yes No

A2

Next letter Yes B2


is EOF

No

Error
A2

Build Command And


set flag

Go sub Command
Execution

Return

B2

Build Command And


set flag

Go sub Command
Execution

STOP
(f) Sub Tool (for T)

No
Check the next letter It is Numeric

yes

Next is Numeric No ERROR

yes
Next Yes
Next is Space No Letter is CR A3

yes No

A3 Next
Letter is Yes B3
EOF

No

ERROR
A3

Build Command And


set flag

Go sub Command
execution

Return

B3

Build Command And


set flag

Go sub Command
execution

STOP
COMMAND EXECUTION
G Commands
Is it yes
Set Rapid Traverse Return
G00

No

Yes Set Linear Interpolation Flag Return


Is it G01

No

Is it G02
Yes Set Circular Interpolation Flag Return

no

Yes Set Absolute Coordinate Flag Return


Is it G90

No

Yes Set Incremental Coordinate Flag Return


Is it G91

No

Yes Set Inch Coordinate Flag Return


Is it G70

No
Yes Set Metric Coordinate Flag Return
Is it G71

No

ERROR

Command execution sets a flag or generate a signal for the machine tool that should be applied
to stepper motor in the light of available flags condition.
M Commands

Spindle ON CW
Is it M03 Yes Go SUB M03 Return
Flag & Motor

No

Spindle ON CCW
Is it M04 Yes Go SUB M04 Return
Flag & Motor

No

Spindle OFF Flag


Is it M05 Yes Go SUB M05 Return
Set

No

Coolant Mist ON /
Is it M07 Yes Go SUB M07 Return
Flag Set

No

Coolant Fluid ON/


Is it M08 Yes Go SUB M08 Return
Flag Set

No

Coolant OFF/ Flag


Is it M09 Yes Go SUB M09 Return
Set

No

Restore start
Is it M02 Yes Go SUB M02 position/ Stop Return
Program

No

ERROR
Feed Speed and Tool

Check Flag & Set


Is it F Yes Go SUB Feed Return
Feed

No

Check Flag & Set


Is it S Yes Go SUB Speed Return
Speed

No

Check Flag &


Is it T Yes Go SUB Tool Return
Load Tool

No

ERROR
Subroutine Feed
Set flag <Feed>
Set feed
Return

Subroutine Speed
Set flag <Speed of Spindle>
Set spindle speed
Return

Subroutine Tool
Set flag <tool to be used>
Select tool
Return

Subroutine G00
Set flag <Rapid traverse>
Return

Subroutine G01
Set flag <Linear interpolation>
Return

Subroutine G02
Set flag <Circular interpolation CW>
Return

Subroutine G03
Set flag <Circular interpolation CCW>
Return

Subroutine G70
Set flag <Inch programming>
Return

Subroutine G71
Set flag <Metric programming>
Return

Subroutine G90
Set flag <Absolute Input>
Return

Subroutine G91
Set flag <Incremental Input>
Return

Subroutine M02
Set flag <End of program>
Return

Subroutine M03
Set flag <Spindle CW>
Spindle on CW
Return

Subroutine M04
Set flag <Spindle CCW>
Spindle on CCW
Return

Subroutine M05
Set flag <Spindle off>
Spindle off
Return

Subroutine M07
Set flag <Coolant on mist>
Mist coolant on
Return

Subroutine M08
Set flag <Coolant on flood>
Flood coolant on
Return

Subroutine M09
Set flag <coolant off>
Return
Subroutine X
i. Check Flag for units

Return

ii. Check Flag for Absolute or Incremental System

Flag for Absolute or


Incremental System

Return
iii. Check Flag for Rapid Traverse
iv. Check Flag for Spindle on (CW/CCW)

Check flag for spindle on (CW or CCW) no Error

yes

Spindle ON (CW or CCW)

Return
V. Check Flag for Coolant (mist/flood)

o Check flag for coolant on (mist or flood) no Error

yes

P
vi. Check Flag for Linear Interpolation

Similarly perform linear interpolation in other planes.


vii. Check Flag for clockwise circular interpolation in XY plane.

Similarly perform circular interpolation in counter clockwise direction and for other planes.

You might also like