Professional Documents
Culture Documents
Via dell’Artigianato, 21
31050 VASCON (TV)
Tel. 0422/447411 - Fax 0422/447444
e-mail:cmz@cmz.it - support@cmz.it
331 SOFTWARE PLC user's manual ver. 3.11
WARNING
CMZ Sistemi Elettronici can modify or improve the products herein described at any time without prior notice.
This manual has been written by CMZ Sistemi Elettronici exclusively for its customers to provide them with the latest
and more updated information on its products. Information in this document is subject to change and does not represent a
commitment on the part of the company.
Special attention is required when using the functions herein described to avoid any possible danger for workers, damages
to the machines or any consequential damage that may result from wrong installation or misuse of the equipment.
No further guarantees are given by CMZ Sistemi Elettronici in particular for imperfections, incomplete information
and/or operative difficulties.
SUMMARY
chapter 1. OVERVIEW.......................................................................................................................... 6
1.1 PLC RESET.....................................................................................................................................6
1.1.1 Total reset.................................................................................................................................6
1.1.2 Partial reset...............................................................................................................................7
1.2 USING THE PLC PROGRAM WITHOUT A COEXISTING FORTH PROGRAM.................7
1.2.1 CTE300 ....................................................................................................................................7
1.2.2 331CPU ....................................................................................................................................8
1.3 USING PLC PROGRAM WITH A COEXISTING FORTH PROGRAM..................................9
1.4 FLASH EPROM ..........................................................................................................................12
1.4.1 CTE300 ..................................................................................................................................13
1.4.2 331CPU ..................................................................................................................................13
1.5 features...........................................................................................................................................14
This manual is aimed at giving AWL programmers all the necessary information to use the internal
PLC of the systems based on MC68331 CPU (CTE300, CTX618 and CTD913 controllers).
This manual introduces the AWL language syntax, the use of test video pages and of the internal
editor. The reader should have a general knowledge on PLC.
chapter 1. OVERVIEW
The PLC software program implemented in the controller enables the system to work as a normal
PLC that can be programmed in the instructions list (AWL)
It can work either independently or together with FORTH or ASSEMBLER programs. It can also
call programs written in both these languages. This characteristic enabled the creation of application
packages for various branches of industrial automation that enhance PLC functions.
The program has two sections: the run-time (from here on called PLC cycle) and the user interface
(PLC user interface).
By means of user interface the source code is created and stored in the controller’s RAM. This code
is then compiled to generate the object code, which is also stored in the controller’s RAM.
In order to program in AWL or other languages, the controller must be connected to a PC IBM or
compatible with a RS232 serial port (in PCs the COM1 is used as standard port). A special program,
supplied as a MS-DOS executable file called PCTER, enables to change the PC into a terminal for
the controller. The transmission protocol has the following format: 9600 baud, 8 data bit, even
parity, one stop bit.
NOTE
The PCTER program is similar to the standard communication program TER that enables the controller to
better manage disks.
Once the PCTER program is connected and activated, a message appears on the top of the screen:
followed by the system identifier and the operative system’s revision number. At pressing the Enter
key the system answers with the message ok indicating it is ready to work.
Whenever the PLC cycle is activated, the system executes a total reset to initialise all working
memory areas and internal variables, or a partial reset to clear not retentive PLC variables.
When the PLC is first started, a total reset is executed and all standard working memory areas are
allocated and cleared.
The PLC knows it has to execute a total reset because: a) memory areas are dirty (variable
FOR_PLC); b) after working areas have been modified (word PLC_CFG); c) in the systems
equipped with UNIPOW60 - power supply unit - , when a fixed number of switching-ons is
reached the number of power on with flat backup battery.
The user can force this condition as follows by the program PCTER:
• Stop the execution of all active tasks by pushing the keys Ctrl+Shift+Esc, then the Esc key
alone.
• Clear the variable FOR_PLC by typing the instructions:
0 FOR_PLC D! <enter>
Each time the PLC is started, the partial reset is executed to reset only not retentive variables.
This condition can be forced in the following way by using the program PCTER:
• Stop the execution of all active tasks by pushing the keys Ctrl+Shift+Esc, then only the Esc
key.
• Restart program execution by typing:
TASK <enter>
1.2.1 CTE300
In this way the PLC cycle is activated. If necessary, at first starting a total reset procedure is
executed. The RUN/STOP condition maintains its last active condition (unless after a total reset, a
When the PLC program is set, it must be stored in flash eprom (see correspondent chapter) and
made completely selfstarting by typing:
AUTOPLC <enter>
NOTE
If the PLC program is selfstarting, when the controller is switched on the PLC cycle will be activated but the
RUN/STOP condition will remain the same until turning off.
1.2.2 331CPU
For the 331CPU systems the program is normally selfstarting: at system starting, the keyword TASK
is automatically executed and the PLC starts, when necessary with a total reset. The RUN/STOP
condition maintains its last active condition (unless after a total reset, a flash eprom program is
loaded automatically).
For LCD and integrated keyboard systems(CTX618 and CTD913) also the user interface program is
activated.
To program this system by using a PC and the PCTER program, it is necessary to exit from the user
interface program in the LCD by pushing the key Esc on the integrated keyboard. When the system
gives the message:
Now PCPLC is enable.
press any key to resume.
In a not selfstarting system, after switching on make the PLC system active by typing:
TASK <enter>
When the PLC program is set, it must be stored in flash eprom (see correspondent chapter) and
made completely selfstarting by typing:
AUTOPLC <enter>
Please, note: for a better comprehension of this paragraph knowledge of the FORTH language
is necessary.
To develop a part of the application software in FORTH, the following rules are extremely
important:
- the source code program and the AWL object code on the standard version occupy the RAM
memory from 1C8000 to 1D7BFD for CTE300 series controllers and from 107000 to 13DFFD for
the CTX and CTD series controllers (331CPU card). The standard assignment can be modified
from the OPTIONS video page (later described) or by using the FORTH keyword PLC_CFG.
Note that changing the default memory assignments causes the complete clearing of the source
code program, of the object code program and of all the PLC internal variables (total reset).
- The PLC cycle runs on task 4 and needs at least 1 millisecond of waiting time at the end of the
cycle scan.
- The PLC user interface runs as a keyword (child process) of the calling task.
Some FORTH keywords provided in the system firmware enable to activate various sections of the
PLC program and to select some options. These keywords are:
PLC_CFG
It configures PLC memory areas and resets PLC internal variables. In case of total reset or when
PLC memory areas assignment are changed, the source code and AWL object code are cleared and
a source code program is searched first in the internal flash eprom, then in the external one (if
installed) starting from the bank 0. If the source code is found, it is loaded, compiled and set to
RUN. If more than one source code program are found, the newest is loaded.
The search modality of the source code program in flash eprom depends on the bank access mask.
STD_CNF
GO_PLC
It verifies that initialisation with PLC_CFG has been achieved. If so; all not retentive variables are
cleared and the PLC executor is activated. The cycle starts without changing the run/stop state or
AWL program in memory.
Syntax: ---
GO_EDIT
It starts PLC user interface. This word is usually called from a FORTH program by a special softkey.
The example below shows some words to enclose in FORTH sources for a proper PLC start.
( ---------------------------------------------------------------
( Starts PLC user interface to be hooked to a softkey
( of the FORTH user interface.
( This word can not be used for the CTE300 series systems.
( ---------------------------------------------------------------
: COLL_PLC
0 0 79 23 ( Screen co-ordinates
-1 ( Use current serial port
$ 17 $ 71 ( Screen colour
$ 70 $ 07 ( Windows colour
$ 30 $ 0F ( Softkey colour
GO_EDIT ( Launch user interface program.
AZP ( Repaint current video page
;
( ---------------------------------------------------------------
( Execute user application program total reset
( This word must execute all variables initialisation
( of the application program.
( ---------------------------------------------------------------
: ResetApp
( *** Initialise application program variables
...
...
( *** Set the total reset flag for the user application program
$ 12345678 ForApp D!
;
( ---------------------------------------------------------------
( System unconditional total reset.
( ---------------------------------------------------------------
: RESETT
RESETT ( Call reset procedure for basic library program
ResetApp ( Application program total reset
;
( ---------------------------------------------------------------
( System partial reset
( ---------------------------------------------------------------
: RESETP
RESETP ( Call partial reset procedure for basic library prog.
( ---------------------------------------------------------------
( TASK Start
( N.B. The addresses for PLC memory areas are valid only for systems
( with 331CPU
( ---------------------------------------------------------------
: TASK
The flash eprom is a non-volatile memory, whose content is not lost even if power is off. So when
the program debugging is finished, it has to be permanently stored in flash eprom.
The system has a flash eprom integrated on the CPU board (internal flash eprom) and an optional
card called SSDISK, which contains up to four memory banks (external flash eprom). SSDISK card
is not available for CTE300 systems because they only have an internal flash eprom.
The internal flash eprom is designed to contain FORTH programs and AWL source code. Instead,
each bank of the external flash eprom can contain only AWL source code or user program machine
parameters.
NOTE
We suggest to store AWL source programs only in the external flash eprom, because in case of CPU
substitution, it is not necessary to reload and compile the program and to reserve the internal flash eprom only
for program updating.
During operations on flash eprom the operative system can issue some information or error
messages; for their meaning see appendix G.
WARNING
As all operation on flash eprom disable interrupts, during their operation procedure programs
running on tasks and hooked to interrupts are momentarily suspended.
WARNING
Clearance of the internal flash eprom causes all tasks’ and all the interrupt routine service’s
automatic stop. Clearance requires user’s confirmation: when this operation is finished, the system
is restarted.
The use of flash eprom with CTE300 systems and 331CPU card based systems is slightly different.
1.4.1 CTE300
The CTE300 system only has the internal flash eprom (128 Kb) where both FORTH programs and
AWL source code are stored.
An AWL source code can be stored only in the flash eprom area enabled by the word PLC_CFG (if
FORTH and AWL programs are not coexisting the whole flash eprom is normally available for the
PLC).
When an AWL source program is stored in flash eprom, it is queued to the previous.
To read an AWL source program, the program number must be specified.
In case of total reset the last program stored is loaded and compiled from flash eprom.
Only by using the DOS program RIGEN.EXE it is possible to erase which erase all the AWL source
program in flash eprom.
1.4.2 331CPU
The systems based on 331CPU card have either the internal flash eprom or the optional external
one.
The flash eprom integrated on the 331CPU card has a capacity of 256Kb (or optionally 512Kb) and
is divided in 8 logical blocks. In each logical block, FORTH programs or AWL source programs can
be stored.
An AWL source code can only be stored in the flash eprom area enabled by the word PLC_CFG.
The limits set by the word PLC_CFG must match with the addresses of start and end block:
An AWL source program can only be stored in the external flash eprom in the banks enabled by the
mask defined with the word PLC_CFG.
When an AWL source program is stored in flash eprom, it is queued after the previous.
To read an AWL source program, first specify bank and program number.
In case of total reset, the last stored program is reached and compiled, starting from the internal flash
eprom in the those external one starting from bank 0.
It is possible to erase the external flash eprom from the PLC user interface only if the external bank
is enabled, while it is possible to erase the internal flash eprom only if all banks contain exclusively
AWL source programs and the word AUTOPLC has not been used.
1.5 FEATURES
NOTE
The following paragraphs refer to standard video pages generated for the PC in which the PCTER program is
running. instructions and information are the same if the PLC user interface runs on the integrated terminals of
the CTX618 and CTD913 systems or with non-standard video pages. For keyboard control of CTX618 and
CTD913 systems see the table in paragraph D.2.
The PLC user interface works when the PC is connected to the system by means of video pages
herein explained in detail. To enter these video pages type the word PCPLC from PC keyboard.
By typing PCPLC /C dimension and colours of the PLC user interfaces video pages can be
changed.
The first video page is the Main menu from where all other video pages can be entered.
F1 key is always active and present with the same meaning in all video pages. Its function is to set
the PLC in STOP or RUN state that is to stop or enable the PLC cycling. The state of actual system
is shown in the top right corner of the screen.
When the PLC cycle is not operative, switching from STOP to RUN is not possible.
F3 key enters the video page for I/O test and variables.
F9 key enters the OPTION video page, where some options can be selected: the length of the
memory buffer for editor program, the PLC cycling time and the flash eprom management.
Esc key exits the PLC user interface and returns to the FORTH environment or to the calling
The following video pages can be entered from the Main Menu’s function keys above described.
2.2 TEST
This video page can be entered from the main menu by pushing F3 key. From here it is possible to
verify and modify the state of all AWL variables. he same action and result can be achieved with the
function VIEW in the editor program.
The video page is as following:
To change from an input field to another, use arrow keys. To erase an input field just use the
Backspace key on it. Note that the less the number of fields is, the faster fields updating is.
To identify the variables see the rules explained in the paragraph 4.1.1. The following table lists
recognised variables.
When a variable is modified by the user, its effect might be temporary; the same when set by the
PLC program because its state is forced by the PLC cycle.
WARNING
If the PLC is set to STOP the input memory image is not updated. To verify the input state in this
condition, use the PEx variable rather than Ex.y, EBx, EWx or EDx.
F3 key resets the bit state on which the cursor is (only if visualised on the binary).
2.3 OPTION
The F9 key enters in the MAIN MENU this video page. Some standard values and parameters can
be changed.
F2 key enables modifications on the working area memory allocation. This function, which is
operative only if the address or length of the PLC memory area have been modified, sets the PLC
to STOP and erases the AWL source code from the memory.
F3 key reads AWL source program previously stored in flash eprom (see paragraph 1.4).
F4 key stores AWL source program in flash eprom (see paragraph 1.4).
F5 key erases the specified flash eprom bank. This function is not available on systems having only
the internal flash eprom (CTE300).
WARNING
Erasing the internal flash eprom causes the automatic stop of all tasks and of the interrupt routine
service. The flash eprom erasure requires for confirmation and. When this operation is finished, the
system is restarted.
F6 key selects hexadecimal or decimal base of input/output values for the working areas and length
PLC work area.
F7 key selects visualisation in continuous mode according to maximum cycling time (in the second
case to force calculation of the maximum value press F7 key twice).
The cycling time is the PLC cycle duration: it is obtained by inserting a time break of the PLC
TASK at the end of every cycle. The time break is given by the set cycling time less the measured
cycling duration. The default value is 20 ms and it cannot be less than the effective cycle duration.
However at least one millisecond is necessary to enable lower priority tasks to work. If PLC’s set
cycling time is close to the real cycle duration, the PLC program will run faster but other TASKs will
be slower.
The real cycle duration measured is updated only if the measured duration is higher than the one
currently visualised. To know the real cycle duration at every time, press F7 key. A new pressure of
F7 key will restore the maximum visualisation value, then the maximum value will be erased and
recalculated (whenever the OPTIONS video page is entered, the maximum cycle duration time is
visualised).
The editor priority enables to modify the editor priority to speed the user interface program.
Remember that the system is multitasking and the AWL control program runs on task number 4,
while the user interface program runs on task 0. Task 0 has the lowest priority, so if the AWL cycle
is very heavy (or there are other tasks running) the user interface program will not be very efficient.
By typing in this field a value other than zero (from 1 on) task 0’s priority is increased and the PLC
user interface program can run faster.
This option must be used only when necessary to modify the program and in all those cycle phases
where no maximum speed for program cycle is required.
WARNING
To increase task 0’s priority, the other tasks’ priorities must be contemporaneously decreased (also
the AWL program cycle execution task). It should be noted that in some operations the task 0 can
become very heavy (for example when the TEST video page has to show many fields or in the
VIEW function or disk operations) and the AWL cycle execution may be very slow and dangerous.
The editor priority must be reset to zero as soon as possible in order to guarantee the maximum
execution time for all other tasks.
The work area is composed by two fields that are respectively the initial and final address of the
memory buffer where the AWL program is stored (source+object).
The initial address (left field) must always be an even number, while the final address (right field)
must always be an odd number.
The input of one of these values updates the working area length.
The length PLC work area is the buffer memory size that is automatically calculated as the
difference between the initial address and final address. Also this new value can be inserted, in this
case the final address is updated in the working area.
WARNING
Once the working area memory allocation has been modified, the operation must be confirmed by
pressing key F2, in order to completely erase the source and the object program.
Note that the system performs no control on the exactness of the values inserted, so it is better not
to give addresses and/or lengths that can overlap RAM areas reserved to other application or
referring to not existing RAM areas (see the system memory map).
Language . When the cursor is in this field, you can select the language: ITALIAN or ENGLISH by
pressing any alphanumerical key.
Program number as read from flash eprom. You can choose which program stored in flash eprom
to move in the RAM memory.
Flash eprom access enables to choose which of the following operations is to be executed in the
internal flash eprom or in the external one. This parameter is not available for systems with internal
flash eprom only (CTE300).
The flash eprom bank number, shows flash eprom’s bank number (from 0 to 3) of in the SSDISK
card, to which all the following commands on flash eprom will refer. This parameter is not available
for systems with internal flash eprom only (CTE300).
3.1 DESCRIPTION
Enter the Editor program from the main menu by pressing key F2 (Edit). The video page appears
as in the following picture:
The first area, under the word Nseq, is the line number and is automatically generated by the PLC
editor program.
The second area, under the word Action, is the instructions’ mnemonic code. The cursor is normally
in this field.
An asterisk on the top left means that the text currently in memory does not match the running
AWL program (the source code has been modified from the last compilation).
The use of arrow keys is similar to that of other editors and allows the cursor movements.
The PgUp and PgDn keys scroll up and down the AWL source code on the screen.
The Home and End keys move the cursor at the beginning/end of the line if pressed once, at the
beginning/end of the page if pressed twice or at the beginning/end of the source code if pressed
thrice.
The BackSpace key erases one character on the left of the cursor and all the other characters in the
line move left. If the cursor is on the first character of a line, the other characters move up to the end
of the previous line.
The Del key erases the character on which the cursor is positioned and all the other characters in the
line move left. If the cursor is at the end of the line the following line moves up.
The Ins key enables to choose between characters introduction mode: insert mode (INS) and
overwrite mode (OVR), that appear on the top left of the screen.
The Shift+F1 key changes the Select text mode. Once the text has been selected, the cursor can be
moved to define the selected block that is highlighted in reverse. Note that only entire lines can be
selected, not just parts of them.
The Shift+F2 key deletes the selected block, the block deleting requires an user confirmation.
The Shift+F3 key deletes the selected block and copies it in a temporary area (positioned at the end
of the editor buffer). When the temporary area is full to contain the selected text, an error message is
issued and the operation is aborted.
The Shift+F4 key copies the selected block in a temporary area. When the temporary area is full to
contain the selected text an error message is issued and the operation is aborted.
The Shift+F5 key inserts the text stored in the temporary area at the cursor position.
At the end of the operation the instruction to erase the block contained on the temporary area must
be confirmed. If there is not enough memory to insert the block, an error message is issued and the
operation is aborted.
The Shift+F6 key enables to position the cursor on the desired row. At program request insert the
line number to reach included between 0 and the last text line.
The Shift+F7 key enables searching for a text string (20 characters length max.). The string search
starts from the cursor position. The cursor stops when it finds the string.
The Shift+F9 key enables to substitute the string with another (20 characters length max.). It is
possible to confirm every single substitution or to execute a global substitution in all the text.
The F1 key changes the PLC state from STOP to RUN or viceversa.
F2 key (TEST) enters the TEST video page described in the previous chapter.
F3 key (VIEW) enables to visualise, at the right of the instructions, a window with the operands’
logical state or numerical values of the AWL lines.
Note that this visualisation mode is asynchronous with the PLC cycle.
The VIEW function is similar to the TEST video page (see the paragraph 2.2 for the meaning of the
function keys and to modify the variables).
With F4 key (FILES) enables to enter the FILES video page that will be described in paragraph 3.2.
F5 key (ERROR) enables searching for the source code line where the RUN TIME error has
occurred.
F6 key (SINTAX) checks the syntax of the AWL source program. The syntax check detects the
errors made during the AWL source code editing (see appendix G for errors list). At the end of this
operation if no errors are found, the following window will be displayed:
This window shows the source code length, the object code length, the system memory area length
and the available memory (if the working area is not large enough an error message will be issued
indicating that memory is insufficient, the free memory value and a negative number that is the
amount of memory needed).
When an error is found, the corresponding error message will be displayed on the screen and the
cursor will go to the program line where the error was found.
F7 key (COMPIL) enables the compilation of the AWL source code to create the object the PLC
cycle will execute. The compilation first check the syntax then, if no errors are found, generates the
object code. Note that during the object code creation, the PLC is temporarily stopped then reset to
the previous state before compiling.
At the end of this operation the following window will be displayed:
This window shows the source code length, the object code length, the system memory area length
and the available memory.
F9 key (HELP) opens a window where the meaning of those function keys not described in the last
The FILES video page can be entered by pressing the F4 key from the EDITOR page. It disk
loading and saving operations of AWL programs. This page also shows the subroutines list stored in
memory. By moving the cursor on a subroutine name and pressing the key F4 (or Enter) it is
possible to edit only the selected subroutine (to edit the whole program, underline the file name).
On the top left of the screen the message "Disk:ON" or "Disk:OFF" indicates if the disk
management is enabled or not (Disk management is automatically enabled if the system is
connected to a PC with the program PCTER.EXE).
On the left side of the screen the message Memory indicates the amount of free editor memory
buffer(in percentage).
The current file name of the program in memory, its creation date and time and the current path are
also visualised.
The F2 key (SAVE) enables the programmer to save on disk the AWL program in memory, created
with the PLC editor or loaded in RAM from the flash eprom. The file is saved in ASCII format so it
can be modified with any other ASCII text editor. If no file extension is specified the editor
automatically adds the extension .AWL. To save a file without extension just add a point at the end
of its name.
The F4 key (EDITOR) enters the PLC editor that enables to write and modify the AWL programs.
When entering the first page of the AWL source code will always be displayed.
The F5 (DIR) or Shift+F5 keys (DIRW) can show the directory of the current path. After typing the
search mask (the default mask is *.*) the directory is shown in full format (F5 key) FILENAME,
LENGTH, DATE and TIME or in short format (Shift+F5 key) where only the file name is
displayed, as for the DOS command DIR/W. If the directory occupies more than a video page, press
a key to display the following.
The F6 key (ERASE) erases the whole editor buffer (but not the memory area for the object code).
Confirmation is always required.
The Shift + F6 key (DELETE) deletes a file from disk. The file name must be specified.
The F8 key (PATH) changes the current path. If there is a specified path, when operating on disk,
the file name (or the file mask if creating a directory) will be added to the current path only if the
first character is not '\' and the second is not ':' (in these cases the name already contains the path
specification). If no path is specified the operation will be dealt on the driver and current path. (All
DOS rules about path names are valid).
During disk operations some error or warning messages could be issued on the screen; for their
meaning see appendix G.
chapter 4. PROGRAMMING
The PLC Editor enables to write a program in instruction list, to compile it and correct syntax errors
or to modify it. Every character typed from the keyboard is stored in the editor buffer. It is not
necessary to press the Enter key to confirm. The editor buffer occupies the first part of the PLC
buffer.
NOTE
Even if the program can define the operand maximum value, form hereon the maximum operand value will
always be considered as the default one .
Before analysing how to edit a program in instructions list, the programming language will be
shortly introduced.
Every instruction is represented on the screen with a line number (automatically generated by the
editor), a mnemonic code indicating the kind of instruction and function, and an operand (if
necessary). Only the last two fields are stored in memory (the line number is not stored).
In the PLC program language the following operand code can be used:
K Constants Identifies a constant value during the data loading operations, in all
other cases it identifies a front panel key
D Data Memory for numerical data in a byte mode, word or double word.
The input E and the output A must be followed by the byte number (for byte is a group of 8 inputs
or 8 outputs) and the input or the output’s number in this byte.
The merker M must be followed by the byte number and the bit number (the byte number must
range between 0 and 255, while the bit number must range between 0 and 7). The PLC has a
maximum of 256 * 8 = 2048 merker.
NOTE
The first 64 merker’s bytes are retentive, that is they maintain their value when the system is turned off and on.
All other bytes are cleared.
The data D (the PLC has a maximum of 512 data byte) can be processed as byte, word or double
word and must be followed by one of these three letters B, W, D, which mean Byte, Word and
Double-word for the operand and by an integer number as identifier.
This number must be:
The following picture represents three different configurations of the first 8 bytes in the data area.
DD0 DD4
DD2 DD6
Pay special attention to avoid memory overlapping, as shown in the following picture, where DD2
shares a DD0 word and a DD4 word.
DD0 DD4
DD2
The timers T and the counters Z must be followed by a number between 0 and 127 (128 timers and
128 counters are available).
The Call C must be followed by the name of an ASSEMBER subroutine or a FORTH word in the
vocabulary. If the word does not exist, an error message is issued during program compilation.
As previously described an AWL program for PLC can be written on a PC by using any text editor
for ASCII files. The files stored in the disk must be loaded in PLC RAM memory using the
functions examined in paragraph 3.2. If the editor used is BRIEF by BORLAND ITALIA it is
possible to directly transfer the PLC source code without using the program PCTER for PC-PLC
connection (See the appendix in the BRIEF EDITOR CMZ manual with a the description of the
macros created for BRIEF connected to PCTER program).
Using the built-in PLC editor, that can be entered from the main menu by pressing F2, the source
program starting at the line 0 is shown on the screen. After a CPU total reset, this screen is usually
empty (if no programs are stored in eprom or flash eprom then load in RAM) and program editing
can start. If some unwanted instructions are in memory, they can be cleared with the command
previously described.
All syntax errors will be recognised only at the next compilation of the source code.
4.1.3 Comments
The comments are identified with the character * (asterisk). All the character written on the right of
the asterisk until the end of the line are considered comments and ignored by the compiler.
Example:
The structured programming makes the comprehension of an AWL program easier. This method
consists in subdividing the program in more subroutines, each of them with a particular aim. The
execution of every subroutine depends on its definition. For example some subroutines are
executed when recalled on the main program, others according to different procedures.
The subroutine definition begins typing the character # at the start of the line followed by the name.
In addition the subroutine name identify its execution mode. Every subroutine must be ended with
the instruction BE.
The type of subroutines accepted by the compiler will be now analysed.
#DEFPLC
It identifies the starting of a PLC configuration subroutine.. In this subroutine, which must be the
first to be defined, only configuration parameters and not AWL instructions can be inserted. See the
following syntax:
MERKER x y Define the total number of merker bytes (x parameter) and the total number of retentive
merker bytes (y parameter). The x parameter can have a value between 4 and 60000 while y
can have a value between 0 and x.
Default = MERKER 256 64
DATA x Define the total number of data bytes (between 4 and 60000).
Default = DATA 512
COUNTER x y Define the total number of counters (x parameter) and the total number of retentive
counters (y parameter). The x parameter can have a value between 2 and 2000 while y can
have a value between 0 and x.
Default = COUNTER 128 8
TIMER x y Define the total number of timers (x parameter) and the total number of retentive timers (y
parameter). The x parameter can have value between 2 and 5000 while y can have a value
between 0 and x.
Default = TIMER 128 32
INPUT x Define the number of input bytes processed by the system (between 4 and 64).
Default = INPUT 32
The default value 4 is the only value accepted for x parameter in CTE300.
OUTPUT x Define the number of output bytes processed by the system (between 4 and 64).
Default = OUTPUT 32
The default value 4 is the only value accepted for x parameter in CTE300.
USER x Define the maximum number of #USER processable (between 2 and 1000).
Default = USER 40
BE Close subroutine #DEFPLC.
If standard packages are compiled in the system (for example the CAN network program) the
maximum value of #DEFPLC can be different in order to allow a proper configuration of the
package compiled (see package manual).
The #DEFPLC can be omitted as for some parameter definitions. In this case the parameters will be
given their values before last configuration.
All defined parameters are allocated in a memory area on the PLC buffer. This memory area cannot
exceed 64 Kbyte. The maximum value limits for every parameter are valid if the others maintain
their default value (for example, 60000 merker bytes and 60000 data bytes cannot coexist).
When the value of each parameter is reduced to its minimum, there is a better system performance
as the memory for AWL program is larger and the process speed is faster due to the lowered
quantity of timer and I/O.
Example:
* PLC configuration
#DEFPLC
MERKER 100 0 * 100 merker bytes not retentive
DATA 5000 * 5000 data bytes
COUNTER 2 0 * No counters, minimum value = 2
TIMER 10 2 * 10 timer the first 2 retentive
INPUT 4 * 4 input bytes
OUTPUT 4 * 4 output bytes
USER 6 * 6 #USER
BE
#MAIN x
It identifies the beginning of the main program, that is the program executed cyclically.
It can be followed by a numerical value that is the PLC cycling time in milliseconds (from 1 to 500).
In compiling time this value is assumed as the new cycling time, if no value is specified, the time
remains unchanged.
Example:
#SUBTIMEx y
It identifies the beginning of a subroutine that has to be executed every y milliseconds. The
maximum number allowed of #SUBTIME is 4, identified by the values 0,1,2 and 3 (parameter x)
with time values from one millisecond to 32767 milliseconds (parameter y).
The programmer has to avoid inserting long instructions sequences in these subroutines (the
#SUBTIME duration cannot last more than one millisecond).
The instructions AST and DST (see paragraph 4.3.11) enable the execution of every #SUBTIME.
After each compilation, every defined #SUBTIME is always enabled if its state has not been
previously modified by these instructions, otherwise it remains in the state (enabled or disabled)
given by the last instruction AST or DST executed.
Example: Three #SUBTIME with different execution time are below shown.
*
* Increase the DW0 every second
*
#SUBTIME 0 1000
INC DW0
BE
*
* Increase the DW2 every two seconds
*
#SUBTIME 1 2000
INC DW2
BE
*
* Copy the state of E0.0 in A0.0 every millisecond
*
#SUBTIME 2 1
L PE0 * Read input byte number 0
T EB0 * Update memory image
U E0.0 * Read E0.0
= A0.0 * Copy to output image
T PA0 * Update output byte number 0
BE
#RUN
It identifies the beginning of a subroutine that has to be executed when the PLC state changes from
STOP to RUN.
This subroutine normally contains the initialisation operations of the application program.
If the block #RUN has not been programmed, the default operation after switching from RUN to
STOP consists in clearing all the outputs, otherwise they remain unchanged.
After its execution the control is up to #MAIN.
#START
It identifies the beginning of a subroutine that has to be executed at the start of the PLC cycle (word
GO_PLC or system power up).
If the block #START has not been programmed, the default operation at the PLC starting up is to
clear all the outputs, otherwise they remain unchanged.
After its execution the control is up to #MAIN while the subroutine #RUN is not executed.
#RESET
It identifies the beginning of a subroutine that has to be executed at every PLC total reset.
In case of total reset the program is moved from flash eprom to the RAM system and compiled so
the #RESET is executed.
If the block #RESET is not programmed, the default operation after the PLC total reset is to clear all
the outputs, otherwise they remain unchanged.
After its execution the control is given to #MAIN while the subroutines #START and #RUN are
not executed.
Example: At every PLC program starting up (all types) the DW0 and DW2 must be set to 100.
*
* Start after STOP->RUN
*
#RUN
JSR 0
BE
*
* Start after power up
*
#START
JSR 0
BE
*
* Start after total reset
*
#RESET
JSR 0
BE
*
* Program initialisation
*
#USER 0
L KZ100
T DW0
T DW2
L KZ0 * Reset all outputs
T AD0
BE
#STOP
It identifies the beginning of a subroutine that has to be executed when the PLC state changes from
RUN to STOP. After the execution of this subroutine the PLC is stopped, no other subroutines are
processed.
If the block #STOP is not programmed, the default operation after switching from RUN to STOP is
to clear all the outputs.
Example: When the PLC stops also the exe number 0 has to be immediately stopped (for more details on axes control,
see the manual Controlling axes with AWL).
#STOP
L KZ0
C w.asse
C cm-lock
#BATTERY x
It identifies the beginning of a subroutine that has to be executed at every system switching on
(before #START) if the backup battery state is flat.
After executing x system switching-ons with a flat battery, the operative system executes a TOTAL
RESET.
The system variables DS48 and DS49 enable to know the number of system switching-ons done
with flat battery and the maximum number of system switching-ons to be done with flat battery (x
parameter).
If the parameter x is not specified the maximum number of system switching-ons remains
unchanged (default value is 100).
Note: The #BATTERY subroutine works correctly only with systems having a power supply unit UNIPOW19 (for
CTE300) or UNIPOW60 (for CTX618 or CTD913).
Example: If more than 20 system switching-ons have been executed with a flat battery, the A1.2 output must be set to
indicate this error condition.
#ERROR
It identifies the beginning of a subroutine that has to be executed at the following PLC starting up
after a PLC RUN TIME error.
When a PLC RUN TIME error is issued, the system is stopped. At the following starting up (if the
program is selfstarting this operation is instantaneous) this subroutine is executed before the
program launch, at the end of this subroutine the PLC remains in STOP until there is a manual
intervention.
The DS30÷DS36 enables to know the error number, while the DS46, after having corrected the
error, sets PLC to RUN.
If the block #ERROR is not programmed, the default operation at the starting up after a RUN TIME
error is clearing up all the outputs and the PLC remains in STOP.
Example: The output A0.0 indicates that the program is running correctly, if an error is detected this output must be
turned off, and a manual intervention is requested to fix this error condition.
* Main program
#MAIN
S RLC * Forces A0.0 turning on
S A0.0
...
...
BE
* RUN TIME errors handling routine
#ERROR
#USER x
It identifies the beginning of an user subroutine that can be called from #MAIN or from any other
subroutine with the instruction JSR. Each user subroutine is identified by a number, the maximum
number is 40 #USER numbered from 0 to 39.
After the execution of this subroutine the control goes back to the instruction immediately following
JSR which has called the #USER.
A subroutine can recall itself and allow a recursive programming.
The maximum nesting level is limited by the return stack depth that can be different according to the
instructions or functions called. (It is normally possible to reach a depth of 100 nesting levels).
#USER 1
#MAIN
...
JSR 1
BE
...
BE
Example: The input E0.0 determines the functioning way (0=manual, 1=automatic). The manual cycle is managed by
#USER 10, the automatic cycle by #USER 11.
*
* Main program 20 milliseconds
#MAIN 20
UN E0.0 * Test if manual
= JSR 10 * Call #USER 10
U E0.0 * Test if automatic
= JSR 11
BE
*
* Manual managing
#USER 10
...
...
BE
*
* Automatic managing
#USER 11
...
...
BE
#INT x
It identifies the beginning of a subroutine which is executed by the FORTH word Exeint or by the
assembler subroutine exeint that respectively need on the stack or on D0 register the number of
#INT to execute. A maximum of four #INT (from 0 to 3) are allowed. Calling a not existing
subroutine #INT does not generate errors because the default programming of every #INT is BE.
If a task calls an #INT while the PLC is in STOP this subroutine is not executed.
Example: When pressing F1 key, the user interface must start the zero search in axe 0.
*
* Zero positioning
*
#INT 0
U M100.0 * Zero positioning started exit from #INT
= BEA
L KZ0
C w.asse
C cm-rtac
UN M100.0
S M100.0
BE
In FORTH the following word must be written and hooked to the F1 key (the name of the word is an example).
: F1Q1 0 Exeint ;
#SUBCHECK
It identifies the beginning of a subroutine whose execution is conditioned by a particular bit of the
CONDITION CODE REGISTER inside the CPU, tested by the instruction CHK.
Within the #SUBCHEK subroutine it is possible to know by means of DS52 and DS53 the kind of
test and the value of a particular identifier given with the instruction CHK.
...
L DD100
CHK EQ 123 * Test Equal to the identifier 123
...
#SUBCHECK
L DS53
L KZ123
=F * SUBCHECK call from test with identifier 123
IF
L KZ1 * Put 1 in DD100
T DD100
ENDIF
BE
Note that for a correct use of the instructions the PLC works with a memory image of all the inputs,
which is updated at the beginning of each scanning, while the state of all the outputs is updated at
the end. In addition the operative system refreshes the outputs’ state every 10 milliseconds to enable
the output updating set by FORTH programs.
Update
inputs image
Program
execution
Outputs
updating
The combining-logical result of a sequence of instructions is stored in a memory cell called RLC. It
is normally loaded with the result from the first instruction; while during further instructions the
operands are combined in AND or OR with the RLC state and their value is modified if necessary.
There are two 32 bit-wide memories called ACC1 and ACC2 that can be used with many
instructions (see counters, timers, arithmetical operations and so on).
The following instructions list show belonging classes, possible operands and connections to the
RLC. In particular:
RLC Limits: during the following logical-combining instruction, the RLC is reloaded (YES) or
combined (NO) with the operand logical state.
The logical-combining instructions can enquire on the state of the specified operand and combine it
(AND or OR) to the RLC.
The U instruction enquires the operand on the logical state 1 and stores the result in combination
with an AND and RLC operation. If this enquiring instruction is the first of a series, the operand
value is copied in the RLC.
Example: Turn on the output A0.0 only if the inputs E0.0 and E0.1 are on together.
UN
The UN instruction enquires the operand on the logical state 0 and stores the result in combination
with an AND and RLC operation. If this enquiring instruction is the first of a series, the operand
value is denied then copied in the RLC.
Example: Turn on the output A0.0 only when the input E0.0 is on and the timer T15 is not finished .
The O instruction enquires the operand on the logical state 1 and stores the result in combination
with an OR and RLC operation. If this enquiring instruction is the first of a series, the operand value
is copied in the RLC.
Example: Turn on the output A0.0 only when at least one of the inputs E0.0 , E0.1 and E0.2. is on
E0.0 A0.0
E0.1
E0.2
ON
The ON instruction enquires the operand on the logical state 0 and stores the result in combination
with an OR and RLC operation. If this enquiring instruction is the first of a series, the operand value
is denied and then copied in the RLC.
Example: Turn on the output A0.0 only when the input E0.0 is on or the input E0.1 is off.
E0.0 A0.0
E0.1
O (without operands)
The instruction O (without operands) allows to achieve the OR combination among groups of
logical-combining operations. That is, each group generates a partial RLC then combined with OR
and the previously calculated RLC. This instruction cannot be the first of an instructions series.
Example: Turn on the output A0.0 if the inputs E0.0 and E0.1 are on, or the inputs E0.2 and E0.3 are on or the inputs
E0.4 and E0.5 are on.
E0.2 E0.3
E0.4 E0.5
O(
The O( instruction is equivalent to the instruction O (without operands). It is better to use this
instruction in case of complex programming sequences and when groups of not logical-combining
operations have to be OR combined.
Example: Turn on the output A0.0 when both the inputs E0.0 and E0.1 are on or when the Data Word 20 contains the
value 100.
U(
The instruction U( enables to execute the logical AND combination between instructions groups not
including only logical-combining operations. This instruction works as the instruction O( but its
partial result is AND combined with the previous.
Example: Turn on the output A0.0 when both the inputs E0.0 and E0.1 are on or when the Data Word 20 contains the
value 100.
The instruction ) closes an instructions group opened by the instructions U( and O(.
A maximum of 8 parenthesis levels can be used in other words and a maximum of 8 groups of
instruction can be nested.
If the number of opened groups does not match with the number of parenthesis, an error message is
This group (composed only by the instruction D) enables to detect the RLC’s leading edge.
The instruction D stores the intermediate result and so enables to simplify the operations aimed at
detecting the RLC’s leading edge. The operand of this instruction shall not be used in any other of
the program to avoid errors and unwanted results.
Example: The PLC should test only the leading edge of the logical combination between the E0.0 input and the M4.2
merker. The result must be stored to the M64.3 merker and the auxiliary merker is M255.0.
These instructions - no matter the RLC value - allow to modify the operand state.
Example: Copy E0.0 input in the A0.0 output and in the merker M4.3.
E0.0 A0.0
M4.3
Example: Set the merker M5.0 as soon as the input E0.0 takes the logical state 1. Any other change in E0.0 input’s value
will not modify merker M5.0.
E0.0 M5.0
S
Example: Further to the previous example, the merker M5.0 should be reset in case the input E0.1 takes the logical value
1.
E0.0 M5.0
S
E0.1 M5.0
R
S (RLC)
The instruction S with the operand RLC unconditionally sets to 1 the value of RLC.
R (RLC)
The instruction R with the operand RLC unconditionally sets to 0 the RLC value.
NOTE
It is not possible to start the same timer more than once within an AWL program, because the PLC cannot detect
the leading edge of the logical operation starting the timer, so it does not work correctly.
SI
The instruction SI starts an impulse timer. The time counting begins with the RLC‘s leading edge;
the timer output is set when the timer starts and is reset when the time counting is over or reset or if
the RLC goes back to zero. The timer’s counting value must be expressed in hundredths of seconds
and stored on ACC1 when the timer starts.
Example: The output A0.0 must follow the state of input E0.0 but it cannot be activated for more than 40 seconds. (See
following diagram). If the input E0.1 goes to 1, the output A0.0 must be reset in any case.
SIGNAL STATE
E0.0
E0.1
A0.0
Timer
40 seconds
T0
E0.0
SI
S
KT400.1 K
E0.1 A0.0
R OUT
SV
The instruction SV starts a timer as an extended impulse. The time counting begins with the RLC
leading edge, the timer output is set when the timer starts and is reset when the time counting is over
or when the timer is reset. The time counting value must be expressed in hundredths of seconds and
stored on ACC1 when the timer starts.
Example: The output A0.0 must be set for 40 seconds each time the input E0.0 goes to 1 (even if less than 40 seconds).
Anyway the output A0.0 must be cleared by the input E0.1.
SIGNAL STATE
E0.0
E0.1
A0.0
Time
40 seconds 40 seconds
T0
E0.0
SV
S
KT400.1 K
E0.1 A0.0
R OUT
SE
The instruction SE starts a timer as a delay in insertion. The timer count begins with the RLC
leading edge, the timer output is settled when the timer is over and the output is reset when the RLC
goes back to zero, or when the timer is reset. The RLC starting the timer must last longer than the
preset timer. The time counting value must be expressed in hundreds of seconds and stored in
ACC1 when the timer starts.
Example: The output A0.0 must be set 40 seconds after the input E0.0 was activated and must be reset when the input
E0.0 goes to zero. Anyway the output A0.0 must be reset by the input E0.1. If the input E0.0 is active for less than 40
seconds the output A0.0 cannot be set.
SIGNAL STATE
E0.0
E0.1
A0.0
Time
40 seconds 40 seconds
T0
E0.0
SE
S
KT400.1 K
E0.1 A0.0
R OUT
SA
The instruction SA starts a timer as a delay in disinsertion. The timer counting begins with the RLC
falling edge, the timer output is set with the RLC leading edge and reset when the timer is over or
reset. The time counting value must be expressed in hundreds of seconds and stored in ACC1 when
the timer starts.
Example: The output A0.0 must be settle every time the input E0.0 goes on and must be high at least 40 seconds.
Anyway the output A0.0 must be reset by the input E0.1.
SIGNAL STATE
E0.0
E0.1
A0.0
Time
40 seconds
T0
E0.0
SA
S
KT400.1 K
E0.1 A0.0
R OUT
SS
The instruction SS starts a timer as a delay in insertion with self memorisation. The timer counting
begins with the RLC leading edge, the timer output is set when the timer is over, and is reset only
when also the timer is reset. The difference with the SE instruction is that SS enables delays in
insertion also with starting timer impulses lasting less than the preset timer. The timer counting value
must be expressed in hundreds of seconds and stored in ACC1 when the timer starts.
Example: The output A0.0 must be reset 40 seconds after the input E0.0 is set and must be reset whenever the input
E0.1 is set. The input E0.0 can have a less than 40 seconds impulse.
SIGNAL STATE
E0.0
E0.1
A0.0
Time
40 seconds 40 seconds
T0
E0.0
SS
S
KT400.1 K
E0.1 A0.0
R OUT
Example: See examples in the instructions SV, SA, SE, SI and SS.
These instructions permit to increase or decrease the value of one of the 128 available counters (the
first 8 counters are retentive).
Each counter has an internal relay which can be used as operand in the logical instructions with the
form: U Z0, etc... The internal relay has a logical value 1 if the counter value is different from zero.
ZV
The instruction ZV increases the counter value specified in the operand; the counter increases its
value only with the RLC leading edge.
Example: Count the number of leading edge (0 1) of the input E0.0. The input E0.1 is the counter reset . The output
A0.0 is set if the counter has a value other than zero.
Z0
E0.0
UP
DOWN
E0.1 A0.0
R OUT
ZR
The instruction ZR decreases the counter value specified in the operand; the counter increases its
value only with the RLC leading edge.
Allowed operands: Z
RLC dependent: YES
Modify RLC: NO
Limits RLC: YES
See also: S R ZV
Example: Reset the 'output A0.0 after 1000 leading edges of the input E0.0. The input E0.1 initialises the counter at the
value 1000.
Z0
UP
E0.0
DOWN
E0.1
S
KZ1000 K
A0.0
R OUT
The instruction S initialises the counter specified as operand with the value stored in ACC1.
Modify RLC: NO
Limits RLC: YES
See also: ZV ZR S
These instructions permit to load or transfer the accumulators’ value. If the operand specifies a byte
or word loading or transfer, its value is justified on the right, that is in the less relevant byte or word
and the sign is extended to 32 bits.
The instruction L copies in ACC2 the value stored in ACC1 and transfers the value specified in the
operand to ACC1. This instruction is independent from RLC and does not affect its value. The
original value of ACC2 goes lost.
L KZ
Load in ACC1 a value in decimal basis. Example:
Since the accumulators (ACC1 and ACC2) are 32 bit-wide, the loading value must be between -2147483648 and
+2147483647.
L KH
Load in ACC1 a value on hexadecimal basis. Example:
L KM
Load in ACC1 a value on binary base. Example:
L KT
Load in ACC1 a value calculated as following:
L KT XXX.Y
where XXX is the numerical value (from 0 to 999) and Y is the power of 10 (from 0 to 4). Example:
This is the best instruction to set the timer counting values. See examples in instructions SI, SV, SE, SA and SS.
L T
Load in ACC1 the value of the specified timer. The value is expressed in hundredth of seconds.
Example: Reset the output A4.3 after 10 of the 25 seconds preset for the timer T15.
L Z
Load in ACC1 the value of the specified counter. For example (as in the example of instruction ZV) set the output A0.1
when the counter is bigger than 500.
L PE
Load in ACC1 the value of the specified input byte. It is not read from the memory input image but directly from the
peripheral. The instruction is useful to read inputs within very fast #SUBTIME.
L DS
Load in ACC1 the value of the specified system variable. For variables index see the table in appendix F.
The instruction T transfers on the specified operand the value stored in ACC1. This instruction is
not RLC dependant and does not modify it.
Example:
T (PA)
The instruction T with PA operand transfers the image of the specified output byte directly to the
peripheral output byte. The accumulators ACC1 and ACC2 are not modified. This instruction is
RLC independent and does not modify it.
Example:
TAK
The instruction TAK exchanges the values stored in ACC1 and ACC2.
These instructions allow to load or transfer the value stored in ACC1 in an indexed way. The
instructions are the same as for L and T, but here the address of the wanted value is calculated by an
index register.
The instruction B loads the index register with the value of the DATA WORD or MERKER
WORD specified in the operand.
The following instructions LI and TI calculate the address according to the value loaded with this
instruction.
LI
The instruction LI transfers the value stored in ACC1 to ACC2, whose original value is lost. It
transfers the value of the operand number + index register to ACC1.
Example:
TI
The instruction TI transfers the value stored in ACC1 to the operand whose number is calculated as
Example: Transfer the DWs from 0 to 98 to the DWs from 100 to 198 on the leading edge of M10.0.
UW
The instruction UW executes the bitwise AND between the values of ACC1 and ACC2. The result is
stored in ACC1 and its original value is lost.
31 23 15 7 0
ACC2 1 0 1 1 0 1 0 0 0 0 1 0 1 0 1 0 0 1 0 0 1 1 1 1 0 0 1 1 0 0 0 0
UW
31 23 15 7 0
ACC1 0 0 1 0 1 1 0 0 1 0 1 1 0 0 1 0 1 1 0 1 0 1 0 0 0 1 0 1 0 1 0 0
31 23 15 7 0
ACC1 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 RESULT
Belonging class: Logical/arithmetical instructions
Allowed operands: No operands allowed
RLC dependent: NO
Modify RLC: NO
Limits RLC: NO
See also: OW XOW
Example: Output A0.0 must become the series for E0.0 and E2.0., output A0.1 the series for E0.1 and E2.1, output
A0.2 the series for E0.2 and E2.2 and so on until output A1.7, series for E1.7 and E3.7.
OW
The instruction OW executes the bitwise OR between the values in ACC1 and ACC2. The result is
stored in ACC1 and its original value is lost.
31 23 15 7 0
ACC2 1 0 1 1 0 1 0 0 0 0 1 0 1 0 1 0 0 1 0 0 1 1 1 1 0 0 1 1 0 0 0 0
OW
31 23 15 7 0
ACC1 0 0 1 0 1 1 0 0 1 0 1 1 0 0 1 0 1 1 0 1 0 1 0 0 0 1 0 1 0 1 0 0
31 23 15 7 0
ACC1 1 0 1 1 1 1 0 0 1 0 1 1 1 0 1 0 1 1 0 1 1 1 1 1 0 1 1 1 0 1 0 0 RESULT
Belonging class: Logical/arithmetical instructions
Allowed operands: No operands allowed
RLC dependent: NO
Modify RLC: NO
Limits RLC: NO
See also: UW XOW
Example: The output A0.0 must be the parallel between E0.0 and E2.0, A0.1 the parallel between E0.1 and E2.1, A0.2
the parallel between E0.2 and E2.2, etc until A1.7 is the parallel between E1.7 and E3.7
XOW
The instruction XOW executes the bitwise EXCLUSIVE OR between the values of ACC1 and
ACC2, the result is stored in ACC1 and its original value is lost.
31 23 15 7 0
ACC2 1 0 1 1 0 1 0 0 0 0 1 0 1 0 1 0 0 1 0 0 1 1 1 1 0 0 1 1 0 0 0 0
XOW
31 23 15 7 0
ACC1 0 0 1 0 1 1 0 0 1 0 1 1 0 0 1 0 1 1 0 1 0 1 0 0 0 1 0 1 0 1 0 0
31 23 15 7 0
ACC1 1 0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 1 0 0 1 1 0 1 1 0 1 1 0 0 1 0 0 RESULT
Belonging class: Logical/arithmetical instructions
Allowed operands: No operands allowed
RLC dependent: NO
Modify RLC: NO
Limits RLC: NO
See also: UW OW
Example: Store in the merker word 0 the leading edges of the first 16 inputs.
+F
The instruction +F adds the ACC1 value to the ACC2 content, the result is stored in ACC1 and its
original value is lost.
Example: Add DW2 with MW4 and store the result in DW0
-F
The instruction -F subtracts the ACC1 value from the ACC2 content, the result is stored in ACC1
and its original value is lost..
Example: Subtract 5000 from DD4 and store the result in DD0
ADD
The instruction ADD increases the value stored in ACC1 according to the value specified in the
operand.
SUB
The instruction SUB decreases the value stored in ACC1 according to the value specified in the
operand.
Modify RLC: NO
Limits RLC: NO
See also: ADD
INC
DEC
XF
It multiplies ACC1 by ACC2, the result is stored in ACC1 (ACC1 ACC2 ACC1). The operands are
considered as being 32 bit wide and are signed.
:F
It divides ACC2 by ACC1, the result is stored in ACC1 (ACC2/ACC1 ACC1) and the remainder in
ACC2. The operands are considered as being 32 bit wide and are signed.
XFS
It multiplies ACC1 by ACC2, the result is stored in ACC1 (ACC1 ACC2 ACC1). The operands are
considered as being 16 bit wide and are signed.
:FS
It divides ACC2 by ACC1, the result is stored in ACC1 (ACC2/ACC1 ACC1) and the remainder on
ACC2. The operands are considered as being 16 bit wide and are signed.
XFX
It multiplies ACC1 by ACC2 (both have 32 bit). The result of 64 bit is stored in ACC1 and also in a
temporary memory called ACC3 (ACC1 ACC2 ACC3:ACC1).
Since ACC3 is not accessible by AWL standard instructions, this instruction should be used only
together with the instruction :FX (see example).
:FX
It divides ACC3:ACC2 by ACC1, the result is stored in ACC1 (ACC2/ACC1 ACC1) and the
remainder in ACC2. The dividend is 64 bit wide while the divisor is 32 bit, the result and the
It is correct 14285714 to be stored in DD0, if the same operation would be executed with normal instructions XF and :F
even these instructions work 32 bit data the result would be completely wrong.
ASS
The instruction ASS calculates ACC1’s absolute value, the result is stored n ACC1 and its original
value is lost.
KEW
The instruction KEW calculates ACC1’s complement at 1, the result is stored in ACC1 and its
original value is lost.
31 23 15 7 0
ACC1 0 0 1 0 1 1 0 0 1 0 1 1 0 0 1 0 1 1 0 1 0 1 0 0 0 1 0 1 0 1 0 0
KEW
31 23 15 7 0
ACC1 1 1 0 1 0 0 1 1 0 1 0 0 1 1 0 1 0 0 1 0 1 0 1 1 1 0 1 0 1 0 1 1 RESULT
Belonging class: Logical/arithmetical instructions
Allowed operands: No operands allowed
RLC dependent: NO
Modify RLC: NO
Limits RLC: NO
See also: KZW
Example: Make the outputs from A0.0 to A1.7 opposite to the input from E0.0 to E1.7.
KZW
The instruction KZW calculates ACC1’s complement at 2, the result is stored in ACC1 and its
original value is lost.
31 23 15 7 0
ACC1 0 0 1 0 1 1 0 0 1 0 1 1 0 0 1 0 1 1 0 1 0 1 0 0 0 1 0 1 0 1 0 0
KZW
31 23 15 7 0
1 1 0 1 0 0 1 1 0 1 0 0 1 1 0 1 0 0 1 0 1 0 1 1 1 0 1 0 1 0 1 1
+1
31 23 15 7 0
ACC1 1 1 0 1 0 0 1 1 0 1 0 0 1 1 0 1 0 0 1 0 1 0 1 1 1 0 1 0 1 1 0 0 RESULT
SLB
The instruction SLB executes the left shift of the less relevant byte in ACC1. The shift is executed
as many times as the value content specified in ACC2, the result is stored in ACC1 and its original
value is lost.
ACC2 KZ1
31 23 15 7 0
ACC1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 1
SLB 0
31 23 15 7 0
ACC1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 1 0 1 0 1 1 0 0 0 RESULT
SRB
The instruction SRB executes the right shift of the less relevant byte in ACC1. The shift is executed
as many times as the value content specified in ACC2, the result is stored in ACC1 and its original
value is lost.
ACC2 KZ1
31 23 15 7 0
ACC1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 1
SRB 0
31 23 15 7 0
ACC1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 RESULT
SLW
The instruction SLW executes the left shift of the less relevant 16 bits in ACC1. The shift is
executed as many times as the value content specified in ACC2, the result is stored in ACC1 and its
original value is lost.
SRW
The instruction SRW executes the right shift of the less relevant 16 bit in ACC1. The shift is
executed as many times as the value content specified in ACC2, the result is stored in ACC1 and its
original value is lost.
SLD
The instruction SLD executes the left shift in ACC1. The shift is executed as many times as the
value content specified in ACC2, the result is stored in ACC1 and its original value is lost.
SRD
The instruction SRD executes the right shift in ACC1. The shift is as many times as the value
content specified in ACC2, the result is stored in ACC1 and its original value is lost.
These instructions allow to compare data loaded on the accumulators. With their result they affect
the RLC and therefore can be used in a program with the logical-combining instructions. In this case
the comparison operation must be the first among the enquiring series or combined with the
instructions U( and O(.
=F
The instruction =F compares ACC1 to ACC2 and sets RLC if ACC1 is equal to ACC2.
Example: Set the output A0.0 if the input word 0 is equal to $ 1234.
<>F
The instruction <>F compares ACC1 to ACC2 and sets RLC if ACC1 is different from ACC2.
>F
The instruction >F compares ACC1 to ACC2 and sets RLC if ACC2 is bigger than ACC1.
<F
The instruction <F compares ACC1 to ACC2 and sets RLC if ACC2 is lower than ACC1.
>=F
The instruction >=F compares ACC1 to ACC2 and sets RLC if ACC2 is bigger than or same as
ACC1.
<=F
The instruction <=F compares ACC1 to ACC2 and sets RLC if ACC2 is lower than or same as
ACC1.
Example: Invert the state of output A0.0 on every leading edge of input E0.0.
I (RLC)
Example: Activate output A0.0 at the same time with E0.0 and E0.1. Activate A0.1 when one of the two inputs is at low
level. (A0.0 and A0.1 are opposites).
STP
The instruction STP, when executed unconditionally puts the PLC in STOP at the end of the cycle.
It is useful when there is a dangerous situation. The RUN state must be set manually.
= STP
The instruction = STP, executed only if RLC=1, puts the PLC in STOP at the end of the cycle. It is
useful when there is a dangerous situation. The RUN state must be set manually.
Example: The E1.7 input must always be active. If not the cycle must be aborted.
STI
The instruction STI, executed unconditionally, immediately puts the PLC in STOP and all further
instructions are not processed anymore. It can be used as the previous instruction or to insert
breakpoints within the program during the program set-up. The RUN state must be set manually.
Example: The input E1.7 must always be active. If not the cycle must be aborted..
IF
The instruction IF opens a block of instructions to be executed only if RLC is 1. The instruction
ENDIF closes the block.
The instructions block allows a faster execution of the program (The instructions within the block
are not executed if the condition is not true). It also allows to adapt to the RLC all the instructions
(for example loading or transferring instructions) that are not RLC dependant.
Example:
ELSE
The instruction ELSE closes a block of instructions opened by instruction IF and opens a new
block to be executed if the RLC previous to instruction IF is equal to 0. The instructions IF, ELSE
and ENDIF do not modify the RLC, therefore the conditioned instructions following the instruction
ELSE must be preceded by instruction S RLC to be executed.
Example: DW0 must be increased if the input E0.0 is 1, or decreased when this input is 0. The output A0.0 must
represent the state of E0.0.
ENDIF
BEGIN
The instruction BEGIN opens an instructions block to be executes cyclically. The instructions block
must be closed by the UNTIL instruction that repeats the cycle if RLC is zero or exits the cycle if
RLC is 1.
Example: Set value 1 to the DATA BYTE from 0 to 99 on E0.0 leading edge.
U E0.0 * Testing edge
D M0.0
IF
L KZ0 * Clear index
T MW2
BEGIN
B MW2 * Update the variable
L KZ1
TI DB0
INC MW2 * Update index
L KZ100
>=F * Exit from BEGIN...UNTIL if MW2>=100
UNTIL
ENDIF
UNTIL
The instruction UNTIL closes an instructions block opened by the BEGIN instruction. When
UNTIL is executed, the cycle re-starts from the instruction following BEGIN if RLC=0 or it
continues with the instruction following UNTIL if RLC=1.
CASE
The instruction CASE permits to execute only one instructions block included between the
instructions CASE and ENDCASE, according to the comparison between ACC1 and a list of
constants declared at the beginning of each block. Every instructions block is defined with one of
the following couples of instructions:
OF ... ENDOF
TOF ... ENDOF
MOF ... ENDOF
COF ... ENDOF
ELSEOF ... ENDOF
Example:
L DW0 * Read index
CASE * Open block CASE
OF 1
... * Instructions to execute if DW0=1
...
ENDOF * Close block opened with OF and go to ENDCASE
OF 2
... * Instructions to be executed if DW0=2
...
ENDOF
TOF 3 10
... * Instructions to be executed if DW0 contains a value
MOF 5 20 30 40 50 60
... * Instructions to be executed if DW0 contains one of the
... * past 5 values (20, 30, 40, 50 or 60)
ENDOF
U M30.0
U M30.1
COF
... * Instructions to be executed if tests fail
... * and if RLC=1 (if M30.0=1 and M30.1=1)
ENDOF
ELSEOF
... * Instructions to be executed if tests fail
...
ENDOF
ENDCASE
OF
It opens an instructions block to be executed only if the value stored in ACC1, before the instruction
CASE, is equal to the parameter given to the instruction OF.
TOF
It opens an instructions block to be executed only if the value stored in ACC1, before the instruction
CASE, is within the two values (extremes included) given to the instruction TOF. The two limits to
be tested must be given increasingly.
MOF
It opens an instructions block to be executed only if the value stored in ACC1, before the instruction
CASE, is equal to one of the values given to the instruction MOF. The first value among the past
ones contains the number of values to be tested.
COF
It opens an instructions block to be executed only if all previous tests have failed and RLC=1.
ELSEOF
It opens an instructions block to be executed only if all previous tests have failed.
ENDOF
It closes an instructions block opened by the instructions OF, TOF, MOF, COF and ELSEOF.
The execution of the instruction ENDOF causes skipping to the instruction that follow ENDCASE.
BE
The instruction BE closes the current subroutine, but the program process continues in the
subroutine that has recalled the current block, or in case of #MAIN it goes back to the first
instruction. Since this instruction is also used by the compiler to close the compilation, it must be
present at the end of each subroutine.
Example:
INSTRUCTION 1
INSTRUCTION 2
. . .
. . .
INSTRUCTION n
BE * End of program
BEA
Example: If the input E0.0 is zero, DW10 must be set to 100 and the following instructions must be skipped.
...
...
UN E0.0 * Test if E0.0 = 0
IF
L KZ100
T DW10
BEA
ENDIF
... * Instructions that must be processed only if E0.0=1
...
BE * End of program and compilation
= BEA
JSR
= JSR
It recalls the #USER whose number is specified in the operand only if RLC = 1.
Example: Call the #USER0 if MW0=0, the #USER1 if MW0=1 and the #USER2 if MW0=2.
AST
It enables the execution of the #SUBTIME whose number is specified in the operand. Note that if a
#SUBTIME has never been affected by the instructions AST and DST it is enabled (default
condition) after each compilation. Otherwise it remains in its current condition.
Belonging class: System instructions
Allowed operands: Number of #SUBTIME to enable
RLC dependent: NO
Modify RLC: NO
Limits RLC: NO
Example: The #SUBTIME 0 must be executed only if the input E1.5 is on.
DST
It disables the execution of the #SUBTIME whose number is specified in the operand.
AIN
It enables the execution of the #INT whose number is specified in the operand.
Note that if a #INT has never been affected by the instructions AIN and DIN it is enabled (default
condition) after each compilation. Otherwise it remains in its current state.
Example: The #INT 0 must be executed only if the input E1.5 is on.
DIN
It disables the execution of the #INT whose number is specified in the operand.
CHK
The instruction CHK permits to test a particular bit in the CPU CONDITION CODE REGISTER
and eventually jump to the subroutine #SUBCHECK.
The instruction must be followed by the code identifying the bit and the test type to be performed
and by a numerical value (from 0 to 32767) useful to asses in which point of the #SUBCHECK the
call was made.
It is possible to know the type of test and the value of the past identifier in the subroutine
#SUBCHECK by means of DS52 and DS53.
Example: Store the resulting sum of DD0 and DD4 in DD8 (DD8=DD0+DD4). If the result is bigger than 32 bit DD8
must be contain the hexadecimal value 7FFFFFFF. Moreover if the result is 0, DD8’s value must be 1000.
...
...
L DD0
L DD4
+F
CHK VS 1 * Test if there is overflow
CHK EQ 2 * Test if the result is 0
T DD8
...
...
#SUBCHECK
L DS53
CASE
OF 1 * Overflow
L KH7FFFFFFF
ENDOF
OF 2 * ACC1=ACC2
L KZ1000
ENDOF
ENDCASE
BE
These instructions allow to execute functions, written by FORTH or ASSEMBLER languages and
stored in memory. RLC can be modified by these instructions.
The instruction C executes a function previously defined in the vocabulary. The function call is
independent from RLC , its value can be modified by the function called.
Example: Execute the function "cm-start" that initialises the axis controller program. It requires the number of axis to be
controlled in ACC1.
=C
The instruction =C is similar to instruction C and its function is executed only if RLC is 1.
Example: Execute the function "cm-restot" that performs a total parameters reset of the axis controller program (the
function requires in ACC1 the number of axis) only if the merker M0.0 is 0, then the merker M0.0 is set in order to avoid
other calls.
UC
The instruction U C calls the specified function. When this function modifies the RLC, the latter is
put in an AND condition with the previous RLC. If this instruction is the first of a series, the RLC
returned from the function is copied in the RLC.
Limits RLC: NO
Example: Set the merker M10.0 if the input E0.0 is active and the axes 0 is not running.
UN C
The instruction UN C calls the specified function. When this function modifies the RLC, the latter is
NEGATED and then put in an AND condition with the previous RLC. If this instruction is the first
of a series, the RLC returned from the function is copied in the RLC.
OC
The instruction O C calls the specified function. If this function modifies the RLC, the latter is ORed
with the previous RLC. If this instruction is the first of a series, the RLC returned from the function
is copied in the RLC.
ON C
The instruction ON C calls the specified function. If this function modifies the RLC, the latter is
NEGATED and then ORed with the previous RLC. If this instruction is the first of a series, the RLC
returned from the function is copied in the RLC.
5.1 INPUT
At the beginning of each PLC cycle all inputs are copied in a memory area called input image.
During the PLC cycle every reference to an input will be relative to its memory image. By using the
storing instructions it is possible to modify also the input state. For instance, if the input E0.0 is the
emergency button that should always be on, though it is not yet connected, bypass it by producing a
program run anyway and put at the head of the program the following instructions:
U M10.0 *
= E0.0 * Assign to the input E0.0 the value of the merker M10.0
. . * From here on the input E0.0 will be the same as the merker
M10.0
. .
BE
5.2 OUTPUTS
The outputs updating is done at the end of the #MAIN execution. Since the system is multitasking
the operative system performs an outputs updating every 10 milliseconds in order to update the
outputs set by others tasks. It is possible the outputs updating (executed by the operative system) to
occur during the PLC cycle, as shown in the following picture where the PLC cycle runs every 3
milliseconds.
(1) (2) (1) (1) (1) (2) (1) (1) (1) (1) (2)
3 ms 3 ms 3 ms 3 ms 3 ms 3 ms 3 ms
10 ms 10 ms
We suggest not to instruct an output in more points of the program to avoid impulses on it.
Consider the following program as an example:
A button (normally opened) connected to the input E0.0 activates the output A0.0, another button
(normally closed) connected to the input E0.1 turns it off.
U E0.0
S A0.0
UN E0.1
R A0.0
This program is correct, but if both the buttons are simultaneously pressed the image of output
A0.0 is set and immediately then reset. If between SET and RESET the operative system is updated,
an impulse to A0.0 is issued which persists until the end of the PLC cycle.
U(
O E0.0
O A0.0
)
U E0.1
= A0.0
U E0.0
S M0.0
UN E0.1
R M0.0
U M0.0
= A0.0
In this case the merker M0.0 is an image representing the output A0.0. This solution allows to test
the program without the activating the output by simply erasing the last two instructions.
5.3 TIMER
Since the timers’ functioning is independent from the program execution, it is necessary to the timer
test to happen within the same instructions block, as analysed in the following program:
U E0.0
IF
U E0.1
L KT100.1
SE T60
ENDIF
U T60
= A0.0
If the inputs E0.0 and E0.1 are active, timer T60 starts. As soon as it starts, both E0.0 and E0.1 inputs
go off, the instructions block is not processed anymore and timer T60 continues decreasing because
the instruction SE T60 is not processed. When the timer finishes its performance, the output A0.0 is
however set, even if the program conditions to do so are not present. If the last two instructions
would have been within the block, the program could have worked correctly.
It is better to set an eventual reset timer instruction before the test timer instruction, because if the
start timer and the reset timer instructions are contemporaneously present, when the timer time is
over its test will give an RLC = 1, even with a the reset condition still present. The following
instruction sequence is wrong:
U E0.0
L KT100.0
SE T0
U T0
= A0.0
U E0.1
R T0
After a second from the activation of input E0.0, the output A0.0 is set independently from the state
of E0.1 input.
After a second from the activation of input E0.0, the output A0.0 is set only if the input E0.1 is low.
The functions callable from AWL by the instruction C (and the others = C, U C, UN C, O C and
ON C) must be written with FORTH or ASSEMBLER languages.
The definition mode for these functions and some rules to correctly approach ACC1, ACC2, RLC
etc will now be explained. See the correspondent manual for the FORTH and ASSEMBLER
languages’ syntax.
The definition of a FORTH written function callable from AWL has the following format:
where type is a value between 0 and 2 that determines the impact of the function on the RLC
limitation when the function is called by the instruction C and allows the compiler to recognise any
improper use of the function. If the function is called by the instructions = C, U C, UN C, O C and
ON C the RLC limitation is not imposed by type but by instruction itself (which limits the RLC in
case of = C, but does not limit RLC in all other cases).
0 The function limits the RLC, the following enquiring will set a new value to RLC.
The 0 type functions cannot be used by the instructions U C, UN C, O C and ON C.
1 The function does not limit the RLC, the following enquiring will combine its operand
with the RLC and will set a new value to RLC.
The 1 type functions cannot be used by the instruction = C.
2 The function does not consider the RLC limitation.
The 2 type functions can be called by any instruction.
The definition for the ASSEMBLER written function is similar to the FORTH function definition:
All the rules explained for the definition of the FORTH function are valid for ASSEMBLER too.
The following table shows the main parameters used by the PLC.
This list of FORTH words can help the interfacing with the AWL program.
Example: Store in the variable Var1 the state of the merker M62.3
...
62 3 m ( Read the merker
Var1 ! ( Memorisation
...
MS
Example: If the variable Var1 is 1 set the merker M62.4 otherwise it must be reset.
...
Var1 @ ( Test condition
IF
62 3 MS ( Set merker
ELSE
62 3 MR ( Reset merker
THEN
...
MR
AS
See also: AR MS MR
AR
ein
A.1 PCTER
This program enables the PC to become the terminal of the controller. It is useful for programming
and as user for application programs. It is connected to the controller by the serial communication
port COM1, as shown in the picture below.
5 SG GND 5
GND 5
RD 3 RS232 Controller
TD 2
7 SG DSUB 9 MALE
COM1 PC
DSUB 25 FEMALE
The format for the default transmission protocol is: 9600 bauds, 8 data bits, even parity, one stop bit.
The command PCTER /? shows the various program options.
A.2 BLOAD
This program permits to transfer the content of memory areas from the PC to the controller and
viceversa. It can be used to transfer or read AWL programs. The command BLOAD without
parameters shows the various program options.
A.3 RIGEN
This program erases all AWL programs stored in flash eprom. In case of a sudden interruption of
the operation (i.e. no power supply), by calling again RIGEN the operation interrupted can be
successfully completed. The command RIGEN /? shows all program options. This program can be
used only in systems with internal flash eprom (CTE300).
CTE300 331CPU
0 0
Firmware EPROM area Firmware EPROM area
$ 3FFFF $ FFFFF
$ 100000
$ 100000
RAM area used
FLASH EPROM area
by the firmware
$11FFFF
$ 104FFF
$ 1C0000 $ 105000
RAM area used Free RAM area
$ 106FFF
by the firmware $ 107000
$ 1C5FFF
$ 1C6000
Free RAM area Free RAM area
$ 1C7FFF for the PLC (relocable)
$ 1C8000
$ 13DFFD
$ 13DFFE
Free RAM area Pointers area
for the PLC (relocable)
$ 13FFFF
$ 140000
$ 1D7BFD
$ 1D7BFE Free RAM area
T_MOT RAM area (expansion)
and pointers
$ 1DFFFF
$ 17FFFF
$ 300000
$ 3FFFFF
The memory areas used by the merker, timers, counters etc. are allocated at the end of the PLC’s
reserved buffer. To know the real address of these areas type in FORTH ì the following commands:
Parameters Command
Merker Mapmer D@ H.
Data word Mapdat D@ H.
Timers Maptim D@ H.
Counters Mapcnt D@ H.
Input Mapein D@ H.
Output OUT-TAB H.
Inside the operative system EPROM there is a basic library with general functions to recall by the
instruction C.
S1LED
It turns on the front panel LED, whose code is specified in ACC1. See appendix D for the LED code
table.
Example: Turn on the LED n 0 when the input E0.0 is active. The operations of turning on and off the LED are executed
only by the changing the state edge of E0.0 to avoid unnecessary overloading of the cycle execution.
S0LED
It turns off the front panel LED whose number is specified in ACC1. See appendix D for the LED
code table.
SFLED
It enables the flashing mode for the LED whose number is specified in ACC1. Use the function
S0LED to disable the flashing mode.
R.QD
Return in ACC1 the screen number (video page) of the running user interface program, specify in
ACC1 the TASK number where the user interface program is running.
Example: Set the merker M10.0 when the current video page of TASK 1 is equal to 2.
R.PVPE
It returns in ACC1 the line number and in ACC2 the column number of the current input field,
specify in ACC1 the TASK number where the user interface program is running.
abiwd
It enables controlling the watch dog circuit that resets and restarts the system when an error
condition is detected (see appendix G).
diswd
comwd
It is a complement to the watch dog control bit. The function must be called at each #MAIN cycle.
D.1 CTE300
(9) (8) (15) (14) (13) (20) (4) (26) (3) (25)
1 2 3 4 5 - CLEAR CTRL ESC
(44) (23)
(1) (0) (7) (6) (5) (12) (18) (10) (2) (24)
6 7 8 9 0 . ENTER
D.2 CTX618
A D G
F1 F6 7 B 8 E 9 H ESC EXT X+ Y+ Z+
+ C F I Ctrl-Z
J M P
F2 F7 4 K 5 N 6 Q
X- Y- Z-
- L O R Del
S V Y
F3 F8 1 T 2 W 3 Z E
U X [SP] N
T
F4 F9 0
(
)
. =
$ - *
+ E
R
% / Ins
"
F5 Fn O
Home PgUp PgDw End
1
0 25 41 27 11 28 31 29 5 46
3
32 33 1 35 43 12 15 13 61 6
0 2 4 5
16 17 26 2 51 55 53 21 14
56 57 34 42 19 52 7 63 62 22
/6 6
8 40 18 58 36 44 39 54
This table shows the meaning of each key when pressed alone or after pressing key Fn (within 5
seconds).
Meaning
Symbol Aline After key Fn (Rolling codes)
F1 F1 Shift+F1
F2 F2 Shift+F2
F3 F3 Shift+F3
F4 F4 Shift+F4
F5 F5 Shift+F5
F6 F6 Shift+F6
F7 F7 Shift+F7
F8 F8 Shift+F8
F9 F9 Shift+F9
ESC Esc Ctrl+Z
Backspace Del
ENTER Enter Insert
Left Home
Up PageUp
Down PageDown
Right End
7 7 A B C a b c
8 8 D E F d e f
9 9 G H I g h i
4 4 J K L j k l
5 5 M N O m n o
6 6 P Q R p q r
1 1 S T U s t u
2 2 V W X v w x
3 3 Y Z space y z _
0 0 ( ) " [ ] ' { } ` < >
. . = $ % # & | ! @ ?
- - + * / \ ^ , : ; ~
D.3 CTD913
F1 A B C D E F
+ ! @ # $ % ^ 0 5 21 38 31 39 63
F2 G H I J K L
- & * ( ) [ ] 32 37 61 46 62 55 47
F3 M N O P Q R
{ } : ; " ' 16 45 53 30 22 15 23
F4 S T U V W X
, < > ? / \ 56 13 29 14 54 7 4
F5 Y Z Back
Space TAB space
| _ 8 24 6 10 50 12
F6 7 8 9 -
E Ins
~ = ` +
N
25 41 27 11 19 60
T
F7 E
4 5 6 0 R Del
33 1 35 43 34 52 20
F8 1 2 3 . é Esc
PgUp 17 26 2 51 42 58 28
F9 ê
F11
Alt Ctrl ç è 57 3 59 18 36 44
Home PgDw End
F10 Fn
F12 9 40
Shift
49
The CTD913 keyboard is completely similar to a standard PC keyboard. Keys’ alternative codes
can be obtained by pressing and releasing (within 5 seconds) Fn key.
(1) The instruction modifies or not the RLC depending on the called function.
(2) The instruction limits or not the RLC depending on the type of function called.
(3) The RLC is not modified by the instruction, but its state depends on the relative subroutine execution.
In the following table there is a list of system variables that can be entered by the instructions L DS
and T DS. Some variables are only for reading, if during the program execution a writing instruction
is found, it will be ignored.
appendix G. ERRORS
The following table shows the error messages that can appear during flash eprom operations.
No source program An attempt to save in flash eprom was done with empty
editor buffer.
Insufficient memory An attempt to load or save a too big program was done
Illegal PLC program number An attempt to load a not existing program from flash
eprom was done.
Write error A flash eprom writing error has occurred.
Read error A flash eprom reading error has occurred.
Flash Eprom chip not present An attempt to execute an operation in a not existing flash
eprom bank has occurred.
Erasure error An error has occurred during flash eprom erasure.
The object code will be lost. An attempt to load a source code from flash eprom was
Confirm ? done but due to its dimension the current object code will
be overwritten. By answering YES the PLC will be
stopped and the new source code will be loaded.
FORTH source in the F.E. An attempt to save a program has occurred, but due to its
dimension or the number of programs previously stored,
it will overlap the flash eprom used by the FORTH.
F.E. erasable only by FORTH An attempt to erase the flash eprom was done when the
compilation of a FORTH source code has overwritten the
AWL reserved area.
WARNING Internal Flash Eprom This warning message is issued when the instruction
will be not erasable from PLC AUTOPLC is executed, and the selfstarting mark is
stored in the PLC reserved area.
G.2 DISK
G.3 COMPILING
First the program compilation executes a syntax check in order to find errors in the AWL file.
Possible error messages are:
MESSAGE CAUSE
No source program Compilation or syntax check of a not existing
program
Insufficient memory Compilation of a source too large program. Note
that the PLC memory buffer has to contain the
source program, the object program and the
system area.
Extend the length of the editor buffer or reduce
the length of the source program.
Syntax error The instruction is incorrectly written.
Odd number The instruction accepts only even numbers.
Number not admitted The number written in the instruction is not
within the limits allowed.
Unknown operative code The written mnemonic is not recognised as an
allowed instruction.
Block not closed An IF instruction has not been closed by the
instruction ENDIF before the program end.
No opened block A block closure instruction ENDIF has been
issued even if the block was not previously
opened by the instruction IF.
Max block level reached Too many blocks have been nested IF...ENDIF
or BEGIN...UNTIL or CASE...ENDCASE.
Brackets not closed In the program the instructions U( or O( were
used without brackets .
No opened brackets In the program the instruction ) was used
without ever opening the bracket with the
instructions U( or O(.
Max brackets level reached Too many instructions sequences U( ... ) or O(
... ) have been nested together.
Function not found or enabled A non-existing or not defined function has been
called with CALL_PLC or :PLC.
Error function call The function type is not compatible with the
instruction used for its call. Ex., a type 0
function called by the instruction U C xxx or a
type 1 function called by the instruction = C.
Subroutine not closed with BE The subroutine beginning with #... has not been
closed with the instruction BE.
Unknown subroutine code The name of the subroutine after the character #
is not allowed.
Unknown SUBTIME An instruction AST or DST referred to a not
defined #SUBTIME. has been used.
Unknown INT An instruction AIN or DIN referred to a not
defined #INT has been used.
Unknown USER An instruction JSR or =JSR referred to a not
defined #USER has been used..
Wrong prog. sequence The instruction sequence typed is not correct.
Subroutine already defined A subroutine has been defined more than once.
Insufficient system area More than 64 Kbyte are requested for the
system area on #DEFPLC . Otherwise the
available memory is not sufficient to contain the
system area.
DEFPLC first block only The block #DEFPLC is not the first block of the
program.
G.4 RUN-TIME
During the program execution some errors can stop the program from running.
In these cases, the operative system stops all running tasks and all programs on interrupt (same as a
keyboard break, pressing the keys Ctrl+Shift+Esc and Esc), then it restarts the operative system
and also the user application program (if selfstarting).
At the restarting of the user program, the PLC is set to STOP and the subroutine #ERROR is
executed which can test the error condition by DS, correct the error and eventually set to RUN the
PLC.
When the PLC user interface is activated, a window containing an error identification message is
issued.
Operative system error The system has been restarted after a run-time error. The message
gives the task number of where the error was issued or says if the
error was on interrupt.
Watch dog intervention The system has been restarted after a CPU reset due to the watch
dog circuit intervention.
PLC total reset done A PLC total reset of the memory area has been executed, after
losing memory or after a memory reallocation by the user.
Low battery Total reset A PLC total reset of the memory area has been executed because
the counter’s maximum level of system power was achieved with
flat battery.
Only for systems equipped with UNIPOW19 or UNIPOW60
Low battery The system was turned on with a flat battery state.
Only for systems equipped with UNIPOW19 or UNIPOW60.
The last three messages are not run time errors but are shown when at PLC’s user interface starting, that error condition
is found.
In case of Operative system error it is possible to find the error cause by using the task number
given with this message.
TASK 4 The error has been generated within the PLC cycle. The error is surely due to
AWL program.
TASK 0 The error has been generated by the debugger task. The error is due to the AWL
program only if a subroutine #INT has been called from the keyboard by the
instruction Exeint.
TASK x The error has been issued within task x. The error is due to the AWL program
only if a subroutine #INT has been called within this task.
IRQ The error has been issued within a program hooked to interrupt. The error is due
to the AWL program only if there are some #SUBTIMEs or if some #INT
subroutine are hooked to interrupt.
If the error is due to the AWL program, it is possible by the editor’s F5 key to execute a false
compilation in order to recognise the AWL row that issued the error (the operation is valid only if
the source AWL program has not been modified).
If the error search line issues the following message:
Error is not in the AWL object code
it means that the error is due to the AWL program or that the error has been generated by a function
called in the AWL program by the instruction C.
In the subroutine #ERROR it is possible to read all these information and to store them in variables
in order to go back to the error cause.
To interpret these DSs a good acknowledge of the operative system is required.
By the DS30 it is possible to enable or disable to control the run time errors. When this function is
disabled, if there is an error, the system goes to the debugger program.
On the subroutine #ERROR, it is possible to set to RUN the PLC clearing the DS46.
The watch dog is a circuit placed on the power supply unit with the aim of watching a continuos
change in a particular line. If within a certain time the state of this line does not change, the power
supply unit sends a reset to the CPU, the operative system is restarted and eventually also the user
program - if selfstarting. (After a watch dog intervention the function is the same as after a run time
error, so the notes in paragraph G.4 are still valid).
The watch dog circuit is normally disabled. To enable it use the function abiwd, then the program
will call cyclically the function comwd that will complement the watch dog control line.
The watch dog enabling instruction (abiwd) must be placed in the starting subroutine, while the
complementing watch dog control line instruction (comwd) must be placed in #MAIN.
#RESET * Start after a total reset
... * Various initialisations
C abiwd * Enable watch dog
BE
Since the program starting the watch dog always stays enabled. So if the PLC is set to STOP
manually or a program compilation is made (that stops the PLC cycle momentarily) the function
comwd is no more executed: this fact causes a watch dog intervention. To solve this problem the
subroutine #STOP must be programmed to disable the watch dog circuit.
#STOP * Change to STOP
C diswd * Disable the watch dog
... * Other operations
BE
The given example is suggested for abiwd, comwd and diswd and is good in many AWL
programming situations. There is no limit in the use of this instruction, in fact the instruction comwd
can be called more than once within the program to get through the critical part of the program or to
disable and enable the watch dog in certain situations.
In the following appendix the fundamental phases for building an AWL program are explained.
E1.0
A3.0
2. At DOS prompt type the command that starts the communication program:
PCTER <enter>
3. Turn on the controller. On the screen the number of the operative system version will appear.
Verify that the connection is activated by pressing the Enter key, the message ok shall be
issued.
4. If the controller is the CTX618 or the CTD913 and on the LCD the main menu is shown, it is
necessary to exit from it by pressing the key Esc from the controller front panel keyboard; on
the LCD the following message will appear:
Now PCPLC is enabled.
press any key to resume.
8. Save the program on disk using the function in the video page FILES.
9. Press F6 to verify eventual syntax errors on the program. Correct the errors then go to the next
step.
10. Press F7 to compile the program. Correct eventual errors (appendix G) and repeat this step.
11. Set to RUN the PLC, if it was in STOP, press key F1.
12. Verify the program functioning, by using the function SHOW (paragraph 3.3.1) and/or TEST
(paragraph 2.2). If some program modifications are needed make them by using the EDITOR
and repeat the procedure from step 8.
13. During the program testing phase, it can be useful to enable or disable the program’s selfstarting
condition. To do it exit from the FORTH interpreter and type:
1 FSTART C! <enter> To enable the selfstarting condition
0 FSTART C! <enter > To disable the selfstarting condition
14. Save the program in the flash eprom in the video page OPTIONS, after choosing the flash eprom
bank, press the key F4 and confirm.
15. Set the program as completely selfstarting, exit from the FORTH interpreter and type:
AUTOPLC <enter>
ANALYTIC INDEX
Warning: The reset command from the keyboard can be executed with any communication
parameters. After this operation the communication parameters of the system are setted as in the
PC.
Warning: The reset command from the keyboard can be executed with any communication
parameters. After this operation the communication parameters of the system are setted as in the
PC.
VREG
The Forth word VREG allows to verify the CPU status at the moment of the last start-up. This word
simplifies the interpretation of the debugger messages described at chapter 5.
VREG prints all the information memorised by operating system. The message interpretation is
showed at chapter 5.
Note that the datas memorised are relative to the last start-up of the operating system, therefore if
the system restarts for a run-time error and then it is turn-off and on again, VREG prints the
informations about the last turn-on operation, and the run-time informations are losted.
The system is not self-starting (FSTART=0), see the paragraph 1.2.1 CTE300
KS Identifies a front panel key. It must be used with the instruction: U, UN, O, ON
For example if you want to test the key F3 (code 4) you must write
U KS4
0 Firmware EPROM
$ FFFFF
$ 100000 RAM area used by the firmware
$ 106FFF
$ 107000 Free RAM area
$ 109FFF
$ 10A000 Free RAM area RAM for the PLC (relocable)
$ 11DFFB
$ 117BFE T_MOT RAM area and pointers
$ 11DFFF
$ 300000 Flash-EPROM area
$31FFFF /
$37FFFF
All the functions that manage the LEDs finish with a ‘S’:
A D
1 B E
C
2 F
ERROR
G J
FAULT
3 H 4 K
I L
RUN
M P
5 N 6 Q
O R
F1 F2 F3 ALT - =
$ 7
S
T 8
V
W
+ - PgUp % U X
F4 F5 F6 Fn
. +
* 9
Y
Z 0
(
)
Home End Del / [SP]
"
PgDw
F7 F8 F9 ESC ENTER
Ctrl-Z Ins
11 7
2
1
23 27
0
15 19
32 28 4 24 20 12 35 31
33 29 5 25 21 17 13 9 10 18
34 30 6 26 22 14