Professional Documents
Culture Documents
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.
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:
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 architecture of the interpreter is designed such that it addresses following main steps while
reading the ASCII part program file:
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
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
STOP
(b) SUB – MISC (FOR M Functions)
B
B
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
Error
B
Build Command
Calculate Steps
Go sub command
execution
Return
C
Build Command
Calculate Steps
Go sub command
execution
STOP
(d) Sub Feed (for F)
Yes
Is it No
ERROR
Numeric?
Yes
Next is Yes A1
Space
No
Next is CR Yes A1
No
No
ERROR
A1
Go sub Command
execution
Return
B1
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
yes No
A2
No
Error
A2
Go sub Command
Execution
Return
B2
Go sub Command
Execution
STOP
(f) Sub Tool (for T)
No
Check the next letter It is Numeric
yes
yes
Next Yes
Next is Space No Letter is CR A3
yes No
A3 Next
Letter is Yes B3
EOF
No
ERROR
A3
Go sub Command
execution
Return
B3
Go sub Command
execution
STOP
COMMAND EXECUTION
G Commands
Is it yes
Set Rapid Traverse Return
G00
No
No
Is it G02
Yes Set Circular Interpolation Flag Return
no
No
No
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
No
Coolant Mist ON /
Is it M07 Yes Go SUB M07 Return
Flag Set
No
No
No
Restore start
Is it M02 Yes Go SUB M02 position/ Stop Return
Program
No
ERROR
Feed Speed and Tool
No
No
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
Return
iii. Check Flag for Rapid Traverse
iv. Check Flag for Spindle on (CW/CCW)
yes
Return
V. Check Flag for Coolant (mist/flood)
yes
P
vi. Check Flag for Linear Interpolation
Similarly perform circular interpolation in counter clockwise direction and for other planes.