Professional Documents
Culture Documents
Lad To Assembler
Lad To Assembler
1
the graphical LD to the native code properly. short
This paper proposes the proper translation method of a X0 : 0
Section 5.
memory
memory memory
2 Common Approach
b. call the execution routine that is associated with
each command
c. translate operands and read data in I/O table
programming
application
input input an execution routine prepared already. Accordingly,
a method is needed to overcome slow speed and low
program
panel circuit device
memory
e
ciency of this processing scheme.
I/O
micro
table
processor
memory
system
output output
program
3 Translation Method of LD
circuit device
memory
power supplier
3.1 Architecture
Figure 1: A general structure of PLC Figure 3 represents main ow of the proposed trans-
lation method of PLC by the block diagram. The rst
scribes operation to execute the application program.
After the PLC starts to control a plant, its memo- ladder diagram
ries repeat operation of gure 2. As a kind of con- application
LD/mnemonic
converter
troller, PLC itself includes little user interface gener- program
2
application program is converted to the program that ;M_LDID 0ffffh,0ffffh,R11
LDHI 0ffffh,R11
;; LD X3
;M_LDIA 08000h,03h,R0
;; ORB
LDI R10,R0
A LOAD 1
Figure 5: assembly code
ANDBLK
LOAD 2
B
ble, then the second pass refers to the table and con-
C AND 4
2 AND B
(b)
Figure 4: LD/mnemonic conversion duces both the size of the memory and the translation
time is shown in gure 6. PLC mnemonics have in-
Boolean equation (1). It makes translation of graph- dependent relation with each other except ones with
ical LD block into text format easy. A, B and C in ow control or global variable. Using this, at step
(b) pull the latest data from the stack, then carry out 1, addresses of labels commonly used with another
AND or OR logical operation with them. mnemonic are stored in a symbol table. After pro-
cessing labels and global variables, the assembly code
output(on=of f ) = 1 ^ 2 _ 3 ^ 4]] (1) block that matches with each mnemonic passes the
assembler in the order of 2,3,4,5... steps. Whenever
`_' and `^' represent `and' and `or' logical opera- a block nishes conversion, all data from the symbol
tions respectively. The (c) is a mnemonic program as table are erased except global data. Then, memory
an output of the LD/mnemonic converter. `LOAD' reduction and less translation time are achieved. As a
pushes the value of operand(the point of PLC) to
stack. `ANDBLOCK' and `ORBLOCK' operate _
and ^ logical operation respectively with the latest
;; LD X1
;M_LDIA 08000h,01h,R0
LDPK 08000h
LDI @01h,R0
..
AND001:
LSH -1,R10
OR R0,R10
3
3.2 Implementation of PLC mnemonics. For both methods, the graph of mean
We have built a large-scale PLC based on digital sig- value of measured execution time of various kinds of
nal processor (DSP) TMS320C40. It supports about LD mnemonics is shown in gure 7. The mnemon-
200 mnemonics including logical operations, arith- ics are classied according to their purpose and form,
metic operations, trigonometric functions, PID etc. It based on the grouping of a PLC manufacturers 12,13].
also has 10,000 points including I/O points and tempo- Common arithmetic mnemonic generally has three
ral registers. Serial communication port has been set operands which consist of two sources and one des-
to connect the PLC to the loader, IBM-PC. Internal tination. Mnemonics with three operands occupies
cache is disabled in order to measure constant execu- most of common PLC mnemonics. They provide the
tion time. The wait state of the I/O table memory largest reduction of the execution times because they
and the application program memory is set to 50ns, pass operand routine three times at least and fetch the
25ns respectively. Both translation methods are im- intermediate code in memory more frequently. On the
plemented for their performance evaluation. contrary, ow control mnemonics are in the least re-
duction since ow control mnemonics have an operand
as label and have brief machine code. Accordingly,
4 Performance Evaluation the proposed structure is e
cient when LD mnemon-
ics have more operands and longer code.
4.1 Execution Time of Mnemonics
Translation time and execution time can be consid- 4.2 Application
ered as main factors for performance evaluation. First,
the translation time of the existing method is much Y020 Y021 Y022 Y023
Y021
Y023
SHUT
(T 0 ) basic SHUT
DOWN
SHUT SHUT
DOWN RET LS RET
LS
(T 1 ) tranfer Y023
(T 2 ) timer,counter
SHUT
(T 3 ) compare RET
(T 4 ) common arithmetic
(T 5 )
special arithmetic Figure 8: LD for automotive process
(T 6 ) flow control
4
such as add, mul and sin can be assigned as outputs
in LD. They also can be represented as a form of fuc- 6
special (P 2 ) (msec)
3
arithmetic (P 5 ) timer,counter
1.0% 1.5% flow control
common
arithmetic (P 6 ) 2
2.2%
(P 4 ) 6.0% N exe =300
existing structure
proposed structure
5
As the role of the PLC is larger in various elds, fur- 12] POSFA PLC Programming manual, POSCON,
ther studies on e
cient translation method will be re- 1995
quired. They can be investigated with execution time 13] MCPU Programming manual, LG industrial elec-
and memory requirement. The translation method of tronics, 1996
other programming languages of the PLC may be valu-
able as well.
References
1] I. Warnock, Programmable Controllers - Opera-
tion and application, Prentice Hall, 1988
2] International Electrotechnical Commission, Pro-
grammable Controllers - Part 3 : Programming
language, IEC Publication1131-3, 1993
3] J. Park, N. Chang, G .S. Rho, and W. H.
Kwon, \Implementation of a Parallel Algorithm
for Event Driven Programmable Controllers,"
Control Eng. Practice, vol. 1, no. 4, pp. 663-670,
1993
4] H. Murakoshi, M. Sugiyama, G. Ding, T. Oumi,
T. Sekiguchi, and Y. Dohi, \A High-Speed Pro-
grammable Controller based on Petri Net," Pro-
ceeding of '91 IECON, pp. 1966-1971, 1991.
5] Jong-il Kim, J. Park, and W. H. Kwon, \Ar-
chitecture of a ladder solving processor for pro-
grammable controllers," Microprocessors and Mi-
crosystems, vol. 16, no. 7, pp. 369-379, 1992
6] G. Rho, J. Park, and W. H. Kwon, \Load Bal-
ancing of a Data-ow Based Programmable Con-
trollers," Proc. of IECON 93, Hawaii, U.S.A,
1993.
7] A J. Laduzinsky, \An Open Architecture, VME-
bus PLC," Control Engineering, vol. 38, no .13,
1991
8] K. Koo, G. Rho, J. Park, W.H. Kwon, and N.
Chang, \Architectural Design of a RISC Proces-
sor for Programmable Logic Controller," Journal
of Systems Architecture , vol.44, 1998
9] G. Rho, K. KOO, N. Chang, J. Park, and W.H.
Kwon, \Implementation of a RISC Processor for
Programmable Controllers," Microprocessors and
Microsystems, 1994.
10] Y. Shimokawa, T. Matsushita, H. Furuno, and Y.
Shimanuki, \A High-Performance VLSI chip for
Instrumentation and Electric Control," Proc. of
IECON 91, pp.884-889, 1991
11] R.W. Lewis, Programming Industrial Control
Systems using IEC 1131-3