CMZ CAN Net (En SW nf0)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 62

CMZ software

CAN network
management
Doc. MS269806
Ed. 01 - English - 26 June 1998
CAN management

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 exclusively for its customers to provide them with the most 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 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 in particular for imperfections, incomplete information and/or operative
difficulties.

2 Doc. MS269806 - Ed. 01 -26 June 1998


SUMMARY

SUMMARY

SUMMARY...................................................................................................................................3
AIM OF THE MANUAL..............................................................................................................4
INTRODUCTION.........................................................................................................................5
chapter 1. NETWORK TEST AND CONFIGURATION ............................................................6
1.1 NETWORK TEST................................................................................................................6
1.1.1 Other messages..............................................................................................................7
1.2 MAXIMUM CONFIGURATION OF THE NETWORK .......................................................8
chapter 2. CAN NETWORK MANAGEMENT IN FORTH .....................................................10
2.1 CAN CONFIGURATION IN FORTH.................................................................................10
2.2 FORTH MANAGEMENT OF THE DIGITAL I/O.............................................................12
2.2.1 Digital inputs management...........................................................................................12
2.2.2 Digital outputs management.........................................................................................13
2.2.3 Activation of the digital inputs/outputs management .....................................................16
2.3 FORTH MANAGEMENT OF THE ANALOG INPUTS .....................................................18
2.3.1 Analog inputs management with module PM8AIA ........................................................18
2.3.2 Analog inputs management with module PM4TIA ........................................................20
2.3.3 Analog inputs management with module PMACQA .....................................................24
2.4 FORTH MANAGEMENT OF THE ANALOG OUTPUTS .................................................24
2.4.1 Analog outputs management with free-standing module PM4ANA ...............................24
2.5 FORTH MANAGEMENT OF THE SPECIAL PERIPHERALS OF THE CAN NETWORK 29
2.5.1 PMVBRA management................................................................................................30
2.5.2 Management of the communication with terminals PMTERM ......................................35
2.6 MALFUNCTIONING FORTH MANAGEMENT ...............................................................36
2.6.1 Probable causes of node alarm ......................................................................................36
chapter 3. CAN NETWORK MANAGEMENT IN AWL .........................................................38
3.1 CAN CONFIGURATION IN AWL.....................................................................................38
3.2 EXAMPLE OF CAN CONFIGURATION IN AWL ............................................................44
3.3 AWL MANAGEMENT OF THE DIGITAL I/O.................................................................46
3.4 AWL MANAGEMENT OF THE ANALOG INPUTS .........................................................48
3.5 AWL MANAGEMENT OF THE ANALOG OUTPUTS .....................................................49
3.6 AWL ACCESS TO OTHER PARAMETERS OF THE NETWORK ...................................50
3.7 MALFUNCTIONING AWL MANAGEMENT ...................................................................52
3.7.1 Probable causes of node alarm
......................................................................................52
3.8 AWL MANAGEMENT OF PERIPHERALS CONFIGURATION CHANGES ...................53
chapter 4. CAN MANAGEMENT SOFTWARE COMPILATION ..........................................56
4.1 INSTALLATION WITH MAKEPRJ
...................................................................................56
4.2 INSTALLATION WITHOUT MAKEPRJ ...........................................................................58
appendix A. PRIMITIVES OF THE COMMANDS
..................................................................59
appendix B. PROGRAM FOR THE COMPLETE TEST OF THE NETWORK
....................61
BIBLIOGRAPHY........................................................................................................................62

Doc. MS269806 - Ed. 01 -26 June 1998 3


CAN management

AIM OF THE MANUAL

This manual supplies general information about software management of the CAN (Control Area
Network), employed in some of the systems projected by CMZ.
Particularly the manual is divided in three sections:

1. Usage of the configuration page and networktest.

2. Configuration and management of the CAN network for applications written in Forth.

3. Configuration and management of the CAN network for applications written in AWL.

The software for the management of the CAN network is not present in the basic vocabulary of all
the CMZ systems and thus must be compiled. The chapter 4 gives directions for the compilation of
the software package “CAN NETWORK” (see also [6]).

4 Doc. MS269806 - Ed. 01 -26 June 1998


INTRODUCTION

INTRODUCTION

The CAN network projected by CMZ is a field network which allows to manage digital and/or
analog I/O directly in the field by connecting some nodes, so-called PCCDIN nodes, connected
among themselves and with the controller (master node) by mean of a cable with 3 or 4 conductors
(CAN_L, CAN_H, CAN_GND and/or CAN_SHLD).

For more detailed information on the network hardware features, see the hardware manuals of the
single systems and hardware manual of the network [1].

For each system there can be connected several nodes, in particular, the maximum capacity of the
network in terms of number of nodes is reported in the following table:

Maximum number of nodes per system


System N° nodes Note
CTE158 6 One 3 conductors CAN network (CAN_L, CAN_H, CAN_GND)
CTE300/308 6 One 3 conductors CAN network (CAN_L, CAN_H, CAN_GND)
CTN350 6 One 3 conductors CAN network (CAN_L, CAN_H, CAN_GND)
CTN560 12 Two 4 conductors CAN networks (6+6) (CAN_L, CAN_H, CAN_GND, CAN_SHDL)
Series 331CPU 32 One 3 conductors CAN network (CAN_L, CAN_H, CAN_GND)1)(
(1) The systems using a 331CPU (CTX618, CTD913, TST900, UNIMAX331, PLCX5/10/18) have two networks
CAN, only one of which can be actually used and thus the number of managed nodes is limited to 32 even if the
hardware capacity of the network is higher.

To each node can be connected one or more of functional modules used for management of signals
towards or from the field. The number of functional modules that can be connected to the same node
is limited by the management capacity of the node itself which is 64 bits for data reading and 64
bits for data writingand anywaycan not exceed 8 modules per node .

The currently managed modules and the number of bits of information which each of them is using is
reported in the following table. For each module the number of bits of information in write mode
(output) is indicated with wdw (Write Data Word), whereas the number of bits of information in
read mode (input) is indicated withrdw (Read Data Word).

Description of functional modules


Module wdw rdw Description
PM8IOA 8 8 8 digital inputs and 8 digital outputs
PM8INA 0 8 8 digital inputs
PM8POA 8 0 8 digital power outputs
PM8ROA 8 0 8 relay outputs implemented with electromechanical components
PM8ROB 8 0 8 relay outputs implemented with solid state components
PM8AIA 16 16 8 digital inputs with resolution 12 bits
PM4TIA (1) 64 64 4 inputs for thermocouples (or TP100 probes) with resolution 16 bits
PMACQA (2) 64 64 1 input for strain gauge with actual resolution 16 bits
PM4ANA.n (1) 64 64 4 analog outputs ± 10 Vdc with resolution 12 bits
PMVBRA 8 8 shutting of current flow (for vibrator)
PMTERM (3) 64 64 interface terminal TLC80
(1) The module saturates completely the node and in this case the node and the module are integrated in the
same board, named “free standing module”.
(2) The module saturates completely the node.
(3) The node is integrated in the terminal. At the moment its software management is not available.
Doc. MS269806 - Ed. 01 -26 June 1998 5
CAN management

chapter 1. NETWORK TEST AND CONFIGURATION

This chapter provides the necessary information for testing and configuring the CMZ CAN network.

The nodes PCCDIN provided in the network have to be numbered from 1 to 32 using the dip-
switches present on the board (see [1]). Obviously it is necessary to remember about the limitations
on number of nodes for each system described in the introduction. The nodes are numbered as
follows:

IMP.1 IMP.2 IMP.3 IMP.4 IMP.5 IMP.6 IDENTIFYING NUMBERING


ON ON ON ON ON ON not allowed: state reserved for master
ON ON ON ON ON OFF 1
ON ON ON ON OFF ON 2
... ... ... ... ... ... ...
ON OFF OFF OFF OFF OFF 32

1.1 NETWORK TEST

Besides the hardware configuration, also a software configuration of the network is necessary.
The program TST_CAN, which is present in the basic firmware of the system or can be compiled as
additional package (see [6]), allows to verify the functioning of the network, its configuration and
the maximum reachable limit of transmission speed.
It is necessary to specify that this program can be used only in phase of test and that the
configuration of the network in application program, must be realised using the tools described in the
chapter 2 or in the chapter 3, respectively for application programs written in Forth and AWL.
After connecting the master (controller) and different network nodes and the different modules
within the nodes, it is possible to feed the network and the system. From Forth ambient, typing the
command TST_CAN on the PC monitor should appear the following page:

6 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 1. NETWORK TEST AND CONFIGURATION

The upper part of the page shows the max. number of nodes that can be connected to that system,
(in the page there are 12 nodes which can be connected to the CTN560) and gives prominence to the
nodes shown in details in the lower part (in this page, the nodes 1,2 and 3).
The lower part shows in details some nodes (in groups of 3): the number of the node, its scanning
time (expressed in msec), the state of the node (active or inactive) and the type of peripherals
connected to the node.

If communication is non active at the centre of the screen will appear the message:

" NETWORK SOFTWARE NOT RUNNING ! "

In this case it is necessary to activate the communication by pushing the key


F1.

The program recognises the nodes present in the network and the modules connected to each node
(for example the drawing shows only node 1 to which no module is connected). The presence of
communication between the system and the different nodes is identified also by the active
communication LED (Data Flow LED) present on the nodes.

With the function key F2 it is possible to confirm the configuration of the network even if the
configuration has to be done later within the final application program like it is described in the
following chapters.

The keys PGUP and PGDN allow to increment and decrement the communication speed within the
range of the minimum value 10 KHz and the maximum value 1 MHz with 9 different steps.

The keys CTRL+PGUP and CTRL+PGDN allow to visualise the 3 nodes, previous or next to those
selected currently.

The key ESC goes back to the interpreter Forth.

The program TST_CAN allows thus to verify the functioning of the network and moreover to
change the communication speed, by evaluating the maximum reachable limit. It will be sufficient to
verify up to which speed the communication stays active with all the nodes. If even one of the nodes
is not able to communicate any more, this means that the limit has been overcame and it is necessary
to select a lower speed. Obviously the maximum speed limit is influenced by the distance between the
master (control system) and the different nodes and also by the quality of the connections.

1.1.1 Other messages

Besides the message“NETWORK SOFTWARE NOT RUNNING !“there may appear other messages:

1. "ERROR ON START-UP PROCEDURE"


The HPC microprocessor does not respond (only for 331CPU)

2. “ERROR ON CONFIGURATION PROCEDURE"


The HPC microprocessor was configured with invalid values (only for 331CPU)

3. "CONFIGURATION LOADING"
It informs the user that the configuration is being loaded

Doc. MS269806 - Ed. 01 -26 June 1998 7


CAN management

4. "CHANGING FREQUENCY"
Informs the user that the speed is changing.

5. "RE-LOAD CONFIGURATION ! <F2>"


Warns the user that a parameter of configuration was changed and that the configuration has to be
re-loaded by pushing the function key F2.

6. "NETWORK SOFTWARE STARTING"


Confirms the user that after pushing the function key F1 the CAN management software has been
started.

1.2 MAXIMUM CONFIGURATION OF THE NETWORK

As mentioned in the introduction, for each system, the CAN network can manage a limited number
N of nodes PCCDIN, which in their turn can manage at most M=8 peripheral modules. The number
of modules which can be managed by a single node is mainly limited by the fact that there is a
maximum number of bits (64) of information managed in write mode (wdw) as well as in read mode
(rdw).

The table proposed in the introduction (and repeated here for convenience) shows the number of bits
used in write and read mode for each type of peripheral module.

Description of functional modules


Module wdw rdw Description
PM8IOA 8 8 8 digital inputs and 8 digital outputs
PM8INA 0 8 8 digital inputs
PM8POA 8 0 8 digital power outputs
PM8ROA 8 0 8 relay outputs implemented with electromechanical components
PM8ROB 8 0 8 relay outputs implemented with solid state components
PM8AIA 16 16 8 digital inputs with resolution 12 bits
PM4TIA (1) 64 64 4 inputs for thermocouples (or TP100 probes) with resolution 16 bits
PMACQA (2) 64 64 1 input for strain gauge with actual resolution 16 bits
PM4ANA.n (1) 64 64 4 analog outputs ± 10 Vdc with resolution 12 bits
PMVBRA 8 8 shutting of current flow (for vibrator)
PMTERM (3) 64 64 interface terminal TLC80
(1) The module saturates completely the node and in this case the node and the module are integrated in the
same board, named “free standing module”.
(2) The module saturates completely the node.
(3) The node is integrated in the terminal. At the moment its software management is not available.

To test the configuration of the network it is necessary to take in account:

1. The sum of the wdws of each module connected to the node must not exceed 64.
2. The sum of the rdws of each module connected to the node must not exceed 64.
3. The number of modules connected to the node has to be at most 8.

8 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 1. NETWORK TEST AND CONFIGURATION

Examples:

1) PCCDIN + 2PM8IOA + 2PM8AIA + PM8INA + PM8ROA M=6


Configuration valid, because: WDW = 2x8 + 2x16 + 8 = 56 < 64 RDW = 2x8 + 2x16 + 8 = 56 < 64

2) PCCDIN + PM8IOA + 2PM8INA + 3PM8POA + 3PM8ROA M = 9>8


Configuration NON valid
, in spite of: WDW = 8 + 3x8 + 3x8 = 56 < 64 RDW = 8 + 2x8 = 24 < 64

3) PCCDIN + 3PM8AIA + 2PM8INA + 2PM8POA + PM8ROB M=8


Configuration NON valid
, because: WDW = 3x16 + 2x8 + 8 = 72 > 64 RDW = 3x16 + 2x8 = 64≤ 64

It is given prominence to the conditions which make a configuration not allowed.


Besides the constraints given by the maximum value of the wdw and rdw, there are also the
following constraints, depending on the type of controller, which restricts the usage of a certain type
of module within the same network.

Maximum number of modules in a network


System Type of module Max. N° of modules Max. N° of inputs Max. N° of outputs
CTE158 PM8IOA 48 384 384
CTE300/308 PM8INA 48 384 --
CTN350 PM8POA 48 -- 384
PM8ROA 48 -- 384
PM8ROB 48 -- 384
PM8AIA 8 64 --
PM4TIA 6 24 --
PMACQA 6 6 --
PM4ANA.n 6 -- 24
PMVBRA 32 -- 32
PMTERM 6 -- 6

CTN560 PM8IOA 96 768 768


PM8INA 96 768 --
PM8POA 96 -- 768
PM8ROA 96 -- 768
PM8ROB 96 -- 768
PM8AIA 8 64 --
PM4TIA 6 24 --
PMACQA 6 6 --
PM4ANA.n 6 -- 24
PMVBRA 32 -- 32
PMTERM 6 -- 6

331CPU PM8IOA 128 1024 1024


PM8INA 128 1024 --
PM8POA 128 -- 1024
PM8ROA 128 -- 1024
PM8ROB 128 -- 1024
PM8AIA 16 128 --
PM4TIA 16 64 --
PMACQA 16 16 --
PM4ANA.n 16 -- 64
PMVBRA 32 -- 32
PMTERM 16 -- 16

Doc. MS269806 - Ed. 01 -26 June 1998 9


CAN management

chapter 2. CAN NETWORK MANAGEMENT IN FORTH

This chapter is addressed to the programmers, who are going to manage the CAN network with
application programs written in Forth. For a better understanding of this chapter, the user is advised
to consult also the manual [2].
The users of AWL language can go directly to the next chapter.

2.1 CAN CONFIGURATION IN FORTH

The program TST_CAN should be used for the final test of the network and for the determination of
the maximum communication speed, but, after the tests are finished, the network should be
configured in the application program as well.
In the application program written in Forth must be specified: the network speed; the structure of
each node, indicating the number of inputs banks (byte_in) and of outputs banks (byte_out)
associated to each module connected to it; scanning time; node address.
The following Forth words are available:

NODO_CAN

This word allows to configure a single node.:

Syntax: byte_out byte_in ... ... ... ... mod time node ---
Fields:

• byte_out byte_in: couples of numbers which indicate respectively the banks of output and the
banks of input of each single node. It has to be specified a couple of values for each module
connected to the node. For those modules where input or output bank have no sense, it must be
passed anyway the value 0. For the maximum number of managed banks see the paragraph
1.2.

• mod: number of modules connected to the node.

• time: scanning time of the node in milliseconds.

IMPORTANT
The scanning time of a node is always a multiple of 5 milliseconds, and the passed values are
automatically approximated to the upper multiple of 5.
The minimum scanning time of a node is 5 milliseconds.

• node: number of the node.

Examples.

Example 1
Let 2 modules PM8IOA (8 inputs + 8 outputs) be connected to the node number 1. To associate the input bank 0
(inputs 0÷7) and the output bank 0 (outputs 0÷7) to the I/O of the first module, and the input bank 1 (inputs 8÷15) and
the output bank 1 (outputs 8÷15) to the second module, with scanning time 15 msec., it is necessary to write:

10 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 2. CAN NETWORK MANAGEMENT IN FORTH

N° bank inputs 1° module PM8IOA Scanning time of the node


N° bank outputs 1° module PM8IOA Numer of the node

0 0 1 1 2 15 1 NODO_CAN
N° bank outputs 2° module PM8IOA
N° bank inputs 2° module PM8IOA N° modules connected to the node

Example 2
Let 3 modules PM8IOA (8 inputs + 8 outputs) and 1 module PM8AIA (8 analog inputs, 12 bits) be connected to the
node number 4. To associate:
- the input bank 2 (inputs 16÷23) and the output bank 2 (outputs 16÷23) to the I/O of the first module PM8IOA
- the input bank 3 (inputs 24÷31) and the output bank 3 (outputs 24÷31) to the I/O of the second module PM8IOA
- the input bank 7 (inputs 56÷63) and the output bank 7 (outputs 56÷63) to the I/O of the third module PM8IOA
- the input bank 0 (inputs 0÷7) to the module PM8AIA (the number of the output bank of the module PM8AIA has no
meaning and thus is set to zero)
it is necessary to write:
N° bank outputs for 5° module PM8IOA
N° bank inputs for 5° module PM8IOA

N° bank inputs for 3° module PM8OIA Scanning time of the node


N° bank outputs for 3° module PM8OIA

2 2 3 3 0 0 7 7 4 15 4 NODO_CAN
N° bank outputs for 4° module PM8OIA Number of the node

N° bank inputs for 4° module PM8OIA N° of modules connected to the node


N° bank inputs for module PM8AIA
On the module PM8AIA bank of output has no sense

VEL_CAN

It allows to set the network speed:

Syntax: speed ---


Fields: speed: Speed code

The following table reports the correspondence between code and speed in KHz.

Speed codes
Baud Rate [KHz] Speed code
10 0
25 1
50 2
100 3
125 4
250 5
500 6
800 7
1000 8

Doc. MS269806 - Ed. 01 -26 June 1998 11


CAN management

GO_CAN

It enables the communication within the CAN network. It returns an error flag (0 if the network was
activated correctly, 1 if an error occurred).

Syntax: --- fl
Fields: fl: error flag

IMPORTANT
The command GO_CAN must be called only once each time the system is started, within the TASK
word, or in order to re-activate the network after it was disactivated with the command STP_CAN.

STP_CAN

It disables the communication.

Syntax: ---
Fields:

2.2 FORTH MANAGEMENT OF THE DIGITAL I/O

This paragraph describes the Forth commands for the management of digital inputs and outputs
(modules PM8IOA, PM8INA, PM8POA, PM8ROA, PM8ROB) of the network.

2.2.1 Digital inputs management

INPC

It allows to test the state of the inputn; it returns the state of the input.

Syntax: n --- fl
Fields: n: number of input to test
fl: input state

F-INC

It allows to test the raising edge of the input n; it returns 1 if a raising edge was detected, or 0
otherwise. The test clears the condition .

Syntax: n --- fl
Fields: n: number of input to test
fl: input state

IMPORTANT
The function is available only if the command
Str8IOA was previously launched.

12 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 2. CAN NETWORK MANAGEMENT IN FORTH

NF-INC

It allows to test the falling edge of the input n; it returns 1 if a falling edge was detected and 0
otherwise. The test clears the condition .

Syntax: n --- fl
Fields: n: number of input to test
fl: input state

IMPORTANT
The function is available only if the command
Str8IOA was previously launched.

2.2.2 Digital outputs management

OUTC-SET

It allows to set the output n.

Syntax: n ---
Fields: n: number of input to set

OUTC-RES

It allows to reset the output n.

Syntax: n ---
Fields: n: number of input to reset

OUTC-CFG

It allows to toggle the state of the outputn.

Syntax: n ---
Fields: n: number of output to toggle

OUTC

It allows to test the state of the outputn. It returns 1 or 0 according to the output state.

Syntax: n --- fl
Fields: n: number of output to test
fl: output state flag

OUTC-PUL

It allows to set the output n for a determined period of time t expressed in hundredths of second
(Off-On-Off impulse).

Doc. MS269806 - Ed. 01 -26 June 1998 13


CAN management

Syntax: n t ---
Fields: n: number of output to set
t: time in hundredths of second

IMPORTANT
The function is available only if the command Str8IOA was previously launched.
Moreover, since the synchronisation is realised through 16 internal timers which have to be assigned
dynamically, before using the command OUTC-PUL it is necessary to check the availability of
timers, at least in those cases when more than 16 time managements of the outputs are going to be
used within the application program. For this purpose it is possible to use the command PULSEC-
SP described subsequently.

NOUTC-PUL

It allows to reset the output n for a determined period of time t expressed in hundredths of second
(On-Off-On impulse).

Syntax: n t ---
Fields: n: number of output to reset
t: time in hundredths of second

IMPORTANT
The function is available only if the command Str8IOA was previously launched.
Moreover, since the synchronisation is realised through 16 internal timers which have to be assigned
dynamically, before using the command NOUTC-PUL it is necessary to check the availability of
timers, at least in those cases when more than 16 time managements of the outputs are going to be
used within the application program. For this purpose it is possible to use the command NPULSEC-
SP described subsequently.

PULSEC-SP

It allows to test the availability of timers for the management of Off-On-Off impulses at the outputs
(see OUTC-PUL). It returns a flag = 1 if there are timers available and 0 otherwise.

Syntax: --- fl
Fields: fl: timer availability flag

IMPORTANT
The function is available only if the command Str8IOA was previously launched or after the
commands of reset of the outputsINI-IOC and INI-IOT.

NPULSEC-SP

It allows to test the availability of timers for the management of On-Off-On impulses at the outputs
(see NOUTC-PUL). It returns a flag = 1 if there are timers available and 0 otherwise.

Syntax: --- fl
Fields: fl: timer availability flag

14 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 2. CAN NETWORK MANAGEMENT IN FORTH

IMPORTANT
The function is available only if the command Str8IOA was previously launched or after the
commands of reset of the outputsINI-IOC and INI-IOT.

AZZ-OUT

It allows to reset all the outputs either standard (present in the system) either of the CAN network.

Syntax: ---
Fields:

INI-IOC

It allows to reset all the outputs of the CAN network, to initialize the image of the inputs in the
inactive state and the variables for the management of the outputs as impulsive and inputs as edge-
sensed.

Syntax: ---
Fields:

INI-IOT

It allows to reset all the standard outputs (present in the system) and of the CAN network, to
initialize the image of the standard inputs (present in the system) and of the CAN network in the
inactive state and to initialize the variables for the management of the outputs as impulsive and inputs
as edge-sensed.

Syntax: ---
Fields:

NOTE
The command INI-IOT is analogue to the command INI-IOC, differently it aff
ects all the I/O and not only the
I/O within CAN network.

Str8IOA

It allows to initialize the variables for the management of the I/O of the CAN network (see INI-IOC)
and activate the routine of management of the outputs as impulsive and the inputs as edge-sensed.

Syntax: ---
Fields:

NOTE
The analogue command for the standard inputs and outputs (present in the systems) is
SBK-OUT.

Doc. MS269806 - Ed. 01 -26 June 1998 15


CAN management

OUTC-TAB

It returns the address of the image table of the digital outputs of the CAN network.

Syntax: --- addr


Fields: addr: image table address

Example
To read the state of the bank (byte_out) 7 of the digital outputs (within a Forth word):

...
...
OUTC-TAB 7 + C@
...
...

NOTE
The command OUTC-TAB cannot be used directly from Forth interpreter. In this case it is necessary to use
the command (OUTC-TAB) which returns the address of the vector containing the address of the image table
of the digital outputs of the CAN network. Thus to read from terminal the state of the bank 7 it is necessary to
write:

(OUTC-TAB) D@ 7 + C@

INPC-TAB

It returns the address of the image table of the digital inputs of the CAN network.

Syntax: --- addr


Fields: addr: image table address

Example
To read the state of the bank (byte_in) 3 of the digital inputs (within a Forth word):

...
...
INPC-TAB 3 + C@
...
...

NOTE
The command INPC-TAB cannot be used directly from Forth interpreter. In this case it is necessary to use the
command (INPC-TAB) which returns the address of the vector containing the address of the image table of
the digital inputs of the CAN network. Thus to read from terminal the state of the bank 3 it is necessary to
write:

(INPC-TAB) D@ 3 + C@

2.2.3 Activation of the digital inputs/outputs management

For an application program written in Forth, the various functions for the activation of the
procedures of management of the outputs as impulsive and inputs as edge-sensed (Str8IOA), for the
initial reset of the outputs (AZZ-OUT), etc. have to be present within the word TASK of start of the
application program.
16 Doc. MS269806 - Ed. 01 -26 June 1998
chapter 2. CAN NETWORK MANAGEMENT IN FORTH

As explained in [6] the word TASK, the total reset (RESETT) and the partial reset (RESETP) must
be structured like in the following example:

NOTE
The variable ForApp is a double word which the programmer must foresee for the forced total reset of his
own application program.

( ---------------------------------------------------------------
( Application program total reset
( This word must execute the initialization of the application
( program variables.
( ---------------------------------------------------------------
: ResetApp
( Initialize variables belonging to the application
...
( Set the application program reset flag
$ 12345678 ForApp D!
;

( ---------------------------------------------------------------
( Management of the total unconditioned reset of the whole system
( ---------------------------------------------------------------
: RESETT
RESETT ( Call the basic programs reset
ResetApp ( Application program reset
;

( ---------------------------------------------------------------
( Management of the partial reset of the whole system
( ---------------------------------------------------------------
: RESETP
RESETP ( Call the basic programs partial reset
( Initialize variables belonging to the application
...
;

( ---------------------------------------------------------------
( Start TASK
( ---------------------------------------------------------------
: TASK
1000 %WAIT ( Wait for possible interrupt from keyboard

( Test if to execute total reset


ForApp D@ $ 12345678 <> ( Test application program total reset flag
?RESETT OR ( Test operating system reset flag
IF
RESETT ( Execute the total reset of all the programs
...

!RESETT ( Set total reset flag


THEN
RESETP ( Execute the partial reset

GO_CAN DROP ( Starts CAN management


AZZ-OUT ( Digital outputs reset
INI-IOT ( Initialize I/O variables and timers
SBK-OUT ( Enable the management of the digital outputs as impulsive
Str8IOA ( Enable the management of the outputs as impulsive and of
( the inputs as edge sensed in the CAN network.
Doc. MS269806 - Ed. 01 -26 June 1998 17
CAN management

( Operations at the start of the program and thus start of the tasks
( and/or interrupt routines
...
...
;

NOTE
If the management of the outputs as impulsive and of the inputs as edge-sensed is not going to be used, it is
convenient not to enable it by inserting the commandStr8IOA, in order to save system resources.

2.3 FORTH MANAGEMENT OF THE ANALOG INPUTS

This paragraph describes the Forth commands for the management of analog inputs connected to the
CAN network (modules PM8AIA, PM4TIA, PMACQA).

2.3.1 Analog inputs management with module PM8AIA

IMPORTANT
Notice that in this case wdw=16 and rdw=16; thus only 4 modules can be used per each node
PCCDIN and however the maximum number of modules in the whole network is reported in the
table of the paragraph 1.2.

The Forth management of the analog inputs of the module PM8AIA is implemented through a
routine which executes on time base the scanning of all enabled input channels and makes available
to the user the converted value directly in the RAM. Thus it is necessary to provide read enabling
commands and write commands for themask enabling the inputs which should be acquired.

Str8AIA

It allows to enable reading of the analog inputs.

IMPORTANT
It must be called only once at each start and thus has to be inserted within the TASK word (see
paragraph 2.1.3)

Syntax: ---
Fields:

Cfg8AIA

It allows to configure the enabling maskmsk of the bank byte_in.

Syntax: msk byte_in ---


Fields: msk: inputs enabling mask
byte_in: input bank.

WARNING
This command must be called after start of the management done with the command Str8AIA.

18 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 2. CAN NETWORK MANAGEMENT IN FORTH

Example
In a CAN network are present two modules PM8AIA to which are associated respectively the banks 0 and 1. To enable
the acquisition of the inputs 0, 3 and 5 of the bank 0 (corresponding to the first module PM8AIA) and the inputs 1, 3
and 7 of the bank 1 (corresponding to the second module PM8AIA) the instructions to use within the TASK word are
the following:

: TASK
1000 %WAIT ( Wait for possible interrupt from keyboard

( Total reset conditioned by a test


...

( Partial reset
...

( Other enable
...

Str8AIA ( Enable the analog acquisition


% 00101001 0 Cfg8AIA ( Select inputs 0, 3 and 5 of the bank 0
% 10001010 1 Cfg8AIA ( Select inputs 1, 3 and 7of the bank 1

( Operations at the start of the program and thus start of the tasks
( and/or interrupt routines
...
;

Read8AIA

It allows to read the input n of the bank byte_in. It returns the 12 bits value of the inputs, with the
following meaning (according to the type of input selected directly on the module hardware):

+ 10 Vdc + 2047
- 10 Vdc - 2048
+ 5 Vdc + 2047
- 5 Vdc - 2048
+ 20 mA + 2047
- 20 mA - 2048
.
Syntax: n byte_in --- value
Fields: n: input number
byte_in: input bank.
value: analog value of the input

Example
To read the input 3 of the bank 1:

3 1 Read8AIA

Val8AIA

It returns the address of the variable which contains the image (word) of the input n of the bank
byte_in of the module PM8AIA.

Syntax: n byte_in --- addr


Doc. MS269806 - Ed. 01 -26 June 1998 19
CAN management

Fields: n: input number


byte_in: inputs bank.
addr: image address in memory

Example
To read the image in memory of the input 3 of the bank 1:

3 1 Val8AIA @

NOTE
The address returned on the stack belongs to the RAM buffer (named mval8aia); each channel occupies one
word. Thus this buffer can be accessed with index calculated as follows:

(byte_in * 8 + n) * 2.

2.3.2 Analog inputs management with module PM4TIA

The module PM4TIA and the node PCCDIN are integrated on the same board since the module
saturates completely the node (wdw=64 and rdw=64)
.

IMPORTANT
The module PM4TIA and the node PCCDIN are integrated on the same board since the module
saturates completely the node (wdw=64 and rdw=64)
.
However, the maximum number of modules in the whole network is reported in the table of the
paragraph 1.2.

The Forth management of the analog inputs of the module PM4TIA is implemented trough a routine
that executes on time base the scanning of all enabled input channels and makes available to the user
the converted value directly in the RAM. Thus it is necessary to provide: read enabling commands,
write commands for the mask enabling the inputs which should be acquired and for the module
configuration parameters.

Str4TIA

It allows to enable reading of the analog inputs.

IMPORTANT
It must be called only once at each start and thus has to be inserted within the TASK word (see
paragraph 2.1.3)

Syntax: ---
Fields:

Set4TIA

It allows to configure the enabling maskmsk of the bank byte_in and the module parameters.

Syntax: buff_e type freq gain msk byte_in ---


Fields:

20 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 2. CAN NETWORK MANAGEMENT IN FORTH

• buff_e: converter input buffer enable flag:

0 input buffer of the converter disabled Default


1 input buffer of the converter enabled

• type: converter functioning mode:

0 unipolar 0 ÷ FSR (Full Scale Range) Default


1 bipolar ± FSR

• freq: update frequency and cut-off frequency of the digital filter:

0 50 Hz / 13,1 Hz Default
1 60 Hz / 15,7 Hz
2 250 Hz / 65,5 Hz
3 500 Hz / 131 Hz

• gain: input amplifier gain:

0 FSR=2,5 V
1 FSR=1,25 V
2 FSR=80 mV Default
3 FSR=20 mV

• msk: input enable mask

• byte_in: input bank number

WARNING
This command must be called after starting the channel scanning with Str4TIA.

The configuration data are stored in a table with address


mcfg4tia.
The information of each bank is stored in a single byte; the address of this variable is calculated as
follows:

mcfg4tia + (byte_in * Ldat4tia)

The meaning of the bits in the byte are the following:

Used bits Value Description


0 buff_e: Input buffer of the converter enable:
0 - Disabled
1 - Enabled
1 type: Converter functioning mode:
0 - Unipolar 0 ÷ FSR
1 - Bipolar ± FSR

Doc. MS269806 - Ed. 01 -26 June 1998 21


CAN management

2,3 freq: Updating frequency and cut-off frequency of the digital filter:
00 - 50 Hz \ 13.1 Hz
01 - 60 Hz \ 15.7 Hz
10 - 250 Hz \ 65.5 Hz
11 - 500 Hz \ 131 Hz
4,5 gain: Conversion gain:
00 - FSR = 2.5 V
01 - FSR = 1.25 V
10 - FSR = 80 mV
11 - FSR = 20 mV

As for the direct usage of the Forth command Set4TIA, in order to store the parameters directly into
memory (according to the previous directions), it is necessary to force the setting of the parameters
(the Forth command does it automatically) writing the value 1 on the 1 byte variable which address
should be calculated in a following way, starting from the initial address
fasi4tia:

fasi4tia + byte_in

When updating of the peripheral parameters is completed, the byte value is cleared to 0.

Example 1
To force the setting of the parameters of the bank 2:

1 fasi4tia 2 + C!

Example 2
In a CAN network are present two modules PM8AIA to which are associated respectively the banks 0 and 1. To enable
the acquisition of the inputs 0, 1 of the bank 0 (corresponding to the first module PM4TIA) and the inputs 2, 3 of the
bank 1 (corresponding to the second module PM4TIA) the instructions to use within the TASK word are the
following:

: TASK
1000 %WAIT ( Wait for possible interrupt from keyboard

( Total reset conditioned by a test


...
( Partial reset
...
( Other enable
...

Str4TIA ( Enable the analog acquisition


0 0 0 2 % 1001 0 Set4TIA ( Select inputs 0 and 3 of the bank 0
0 0 0 2 % 1010 1 Set4TIA ( Select inputs 1 and 3 of the bank 1

( Operations at the start of the program and thus start of the task and/or
( interrupt routines
...
;

Cfg4TIA

It allows to configure the enable mask msk of the bank byte_in. For this purpose it can be used in
place of the commandSet4TIA.

22 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 2. CAN NETWORK MANAGEMENT IN FORTH

Syntax: msk byte_in ---


Fields: msk: inputs enable mask
byte_in: input bank.

WARNING
This command must be called after starting the channel scanning with Str4TIA.

Example
In a CAN network are present two modules PM4TIA to which are associated respectively the banks 0 and 1. To enable
the acquisition of the inputs 0, 1 of the bank 0 (corresponding to the first free-standing module PM4TIA) and the
inputs 2, 3 of the bank 1 (corresponding to the second free-standing module PM4TIA) the instructions within the
TASK word are the following:

: TASK
1000 %WAIT ( Wait for possible interrupt from keyboard

( Total reset conditioned by a test


...

( Partial reset
...

( Other enable
...

Str4TIA ( Enable the analog acquisition


% 0011 0 Cfg4TIA ( Select inputs 0 and 1 of the bank 0
% 1100 1 Cfg4TIA ( Select inputs 2 and 3 of the bank 1

( Operations at the start of the program and thus start of the task and/or
( interrupt routines
...
;

Read4TIA

It allows to read the input n of the bank byte_in. It returns a 16 bits without sign value of the input
(0÷ +65535) which has to be interpreted as follows:

÷+FSR):
- if the unipolar mode was selected (0

0 0
+FSR 65535

- if the bipolar mode was selected±FSR):


(

-FSR 0
+FSR 65535
Syntax: n byte_in --- value
Fields: n: input number
byte_in: inputs bank.
value: analog value of the input
Example
To read the input 3 of the bank 1:

Doc. MS269806 - Ed. 01 -26 June 1998 23


CAN management

3 1 Read4TIA

Val4TIA

It returns the address of the variable which contains the image of the input
n of the bank byte_in.

Syntax: n byte_in --- addr


Fields: n: input number
byte_in: input bank.
addr: image memory address

Example
To read the image in memory of the input 3 of the bank 1:

3 1 Val4TIA @

It is returned a16 bits without sign value.

NOTE
The address returned on the stack belongs to the RAM buffer named mval8aia; each channel occupies one
word. Thus this buffer can be accessed with index calculated as follows:

(byte_in * 8 + n) * 2.

2.3.3 Analog inputs management with module PMACQA

At the moment general usage software for this peripheral is not available.

2.4 FORTH MANAGEMENT OF THE ANALOG OUTPUTS

This paragraph describes the Forth commands for the management of analog outputs connected to
the CAN network (PM4ANA).

2.4.1 Analog outputs management with free-standing module PM4ANA

IMPORTANT
The module PM4ANA and the node PCCDIN are integrated on the same board since the module
saturates completely the node (wdw=64 and rdw=64)
.
However, the maximum number of modules in the whole network is reported in the table of the
paragraph 1.2.

The Forth management of the analog inputs of the module PM4ANA is implemented trough a
routine that executes on time base the scanning of all enabled input channels and allows the user to
input the value directly from RAM. Thus it is necessary to provide: write enabling commands, write
commands for the mask enabling the outputs which should be managed and for the module
configuration parameters.

Str4ANA

It allows to enable the analog outputs management.


24 Doc. MS269806 - Ed. 01 -26 June 1998
chapter 2. CAN NETWORK MANAGEMENT IN FORTH

IMPORTANT
It must be called only once at each start and thus has to be inserted within the TASK word (see
paragraph 2.1.3)

Syntax: ---
Fields:

Set4ANA

It allows to configure the enabling maskmsk of the bank byte_out and the module parameters.

Syntax: n1 n2 n3 n4 n5 n6 n7 n8 msk byte_out ---


Fields:

• n1 ÷ n8: value of increment and decrement for the ramps of the 4 analog outputs. In particular:

n1 increment for output channel 0 ÷ 255


0÷ s/100
n2 increment for output channel 1 ÷ 255
0÷ s/100
n3 increment for output channel 2 ÷ 255
0÷ s/100
n4 increment for output channel 3 ÷ 255
0÷ s/100
n5 decrement for output channel 0 ÷ 255
0÷ s/100
n6 decrement for output channel 1 ÷ 255
0÷ s/100
n7 decrement for output channel 2 ÷ 255
0÷ s/100
n8 decrement for output channel 3 ÷ 255
0÷ s/100

• msk: outputs enabling mask

• byte_out: output bank number

WARNING
This command must be called after starting the channels scanning with Str4ANA.

The constants of increment and decrement are stored in a table with address mcfg4ana. Each data is
stored in a single byte, thus the initial address of the buffer of each single outputs bank is calculated
as follows:

mcfg4ana + (byte_out * Ldat4ana)

The memory is organised as follows starting from the initial address of each bank:

Offset Dimension Description


0 Byte Increment for the ramp of the channel 0
1 Byte Increment for the ramp of the channel 1
2 Byte Increment for the ramp of the channel 2
3 Byte Increment for the ramp of the channel 3
4 Byte Decrement for the ramp of the channel 0
5 Byte Decrement for the ramp of the channel 1
6 Byte Decrement for the ramp of the channel 2
7 Byte Decrement for the ramp of the channel 3

Doc. MS269806 - Ed. 01 -26 June 1998 25


CAN management

Example 1
To set to the value 100 as increment and decrement for the ramp of the channel 2 of the bank 1:

100 mcfg4ana 1 Ldat4ana * + 2 + C!


100 mcfg4ana 1 Ldat4ana * + 6 + C!

As for the direct usage of the Forth command Set4ANA, in order to store the parameters directly
into memory (according to the previous directions), it is necessary to force the setting of the
parameters (the Forth command does it automatically) writing the value 1 on the 1 byte variable
which address should be calculated in a following way, starting from the initial address
fasi4ana:

fasi4ana + byte_out

When the updating of the peripheral parameters is completed, the byte value is cleared to 0.

Example 2
To force the setting of the parameters of the bank 2:

1 fasi4ana 2 + C!

Example 3
In a CAN network are present two modules PM4ANA to which are associated respectively the banks 0 and 1. To
enable the management of the outputs 0 and 3 of the bank 0 (corresponding to the first module PM4ANA) and the
outputs 1 and 3 of the bank 1 (corresponding to the second module PM4ANA) the instructions to use within the TASK
word are the following:

: TASK
1000 %WAIT ( Wait for possible interrupt from keyboard
( Total reset conditioned by a test
...
( Partial reset
...
( Other enables
...
Str4ANA ( Enable

( Set ramps and select outputs 0, 3 of the bank 0


100 100 100 100 100 100 100 100 % 1001 0 Set4ANA

( Set ramps and select outputs 1, 3 of the bank 1


50 50 50 50 50 50 50 50 % 1010 1 Set4ANA

( Operations at the start of the program and thus start of the task and/or
( interrupt routine
...
;

Cfg4ANA

It allows to configure the enable mask msk of the bank byte_out. For this purpose it can be used in
place of the commandSet4ANA.

Syntax: msk byte_out ---


Fields: msk: outputs enabling mask
byte_out: output bank.

26 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 2. CAN NETWORK MANAGEMENT IN FORTH

WARNING
This command must be called after starting the channel scanning with Str4ANA.

Example
In a CAN network are present two modules PM4ANA to which are associated respectively the banks 0 and 1. To
enable the management of the outputs 0, 1 of the bank 0 corresponding to the first module PM4ANA) and the outputs
2, 3 of the bank 1 (corresponding to the second module PM4ANA) the instructions within the TASK word are the
following:

: TASK
1000 %WAIT ( Wait for possible interrupt from keyboard
( Total reset conditioned by a test
...
( Partial reset
...
( Other enable
...

Str4ANA ( Enable
% 0011 0 Cfg4ANA ( Select output 0 and 1 o
f the bank 0
% 1100 1 Cfg4ANA ( Select output 2 and 3 of the bank 1

( Operations at the start of the program and thus start of the task and/or
( interrupt routine
...
...
;

Write4ANA

It allows to write the output n of the bank byte_out. Remembering that the analog value ± 10 Vdc is
represented with 11 bits with sign, the written data has to be coded as follows:

-10 Vdc -2048


+10 Vdc +2047

Syntax: value n byte_in ---


Fields: value: analog value to write to the output
n: output number
byte_out: output bank.

Example
To set the value +5 Vdc (+1024) to the output 3 of the bank 1:

1024 3 1 Write4ANA

Read4ANA

It allows to read the value of the output n of the bank byte_out. Remembering that the analog value
± 10 Vdc is represented with 11 bits with sign, the returned data has to be interpreted as follows:

-10 Vdc -2048


+10 Vdc +2047
Doc. MS269806 - Ed. 01 -26 June 1998 27
CAN management

Syntax: n byte_in --- value


Fields: n: output number
byte_out: output bank.
value: analog value

Example
To read the value of the output 3 of the bank 1:

3 1 Read4ANA

Val4ANA

It returns the address of the variable which contains the image of the output
n of the bank byte_out.

Syntax: n byte_out --- addr


Fields: n: output number
byte_out: outputs bank.
addr: image memory address

Example
To set the value -5 Vdc (-1024) at the output 3 of the bank 1:

-1024 3 1 Val4ANA !

To read the value of the output 2 of the bank 2:

2 2 Val4ANA @

it is returned an 11 bits with sign value.

NOTE
The address which is returned on the stack, belongs to RAM buffer named mval4ana; each channel occupies
one word. Thus this buffer can be accessed with index calculated as follows:

( byte_out * 4 + n ) * 2.

Sr4ANA

It allows to set the relay of the outputn of the bank byte_out.

Syntax: n byte_out ---


Fields: n: output number
byte_out: output bank.

NOTE
It is possible to modify or test the state of the relays also by reading the information in the table with address
reed4ana. Each byte corresponds to a bank, thus the index should be calculated adding to the basic address
the number of the affected bank:

reed4ana + byte_out

Within the byte the bits have the following meaning:

28 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 2. CAN NETWORK MANAGEMENT IN FORTH

Bit Description
0 Enable relay channel 0
1 Enable relay channel 1
2 Enable relay channel 2
3 Enable relay channel 3

Example
To enable the relay of the channel 1 of the bank 2: reed4ana 2 + 1 BSET

Rr4ANA

It allows to reset the relay of the output n of the bank byte_out (see also the note of the command
Sr4ANA).

Syntax: n byte_out ---


Fields: n: output number
byte_out: output bank.

?r4ANA

It allows to test the relay of the output n of the bank byte_out. It returns a flag =1 if the relay is
enabled and 0 otherwise (see also the note of the command Sr4ANA).

Syntax: n byte_out --- fl


Fields: n: output number
byte_out: output bank.
fl: relay state flag

2.5 FORTH MANAGEMENT OF THE SPECIAL PERIPHERALS OF THE CAN


NETWORK

This paragraph describes the Forth commands for the management of special peripherals connected
to a CAN network. In particular:

1. PMVBRA whichallows partitioning of the current flux in a circuit fed by 220 Vac 50 or 60 Hz.
2. PMTERM for the management of terminals.

Doc. MS269806 - Ed. 01 -26 June 1998 29


CAN management

2.5.1 PMVBRA management

IMPORTANT
The module has rdw=8 and wdw=8, and thus it is possible to use up to 8 modules PMVBRA per
each node PCCDIN, and however the maximum number of modules in the whole network is
reported in the table of the paragraph 1.2.

The Forth management of the analog outputs of the module PMVBRA is implemented trough a
routine that executes on time base the scanning of the output channel and allows the user to input the
value directly from RAM. Thus it is necessary to provide: outputs management enable commands,
write commands for the enablemask and for the module configuration parameters.

WARNING
Each module PMVBRA has only one time shutter output and thus the value assigned to the
enabling mask will always be 1 and the number of the output channel 0. This is done in order to
keep for the commands corresponding to this module the same syntax as for the commands used for
the other modules that have more than one input or output.

StrVBRA

It allows to enable the management of the analog output of the modules PMVBRA.

IMPORTANT
It must be called only once at each start and thus has to be inserted within the TASK word (see
paragraph 2.1.3)

Syntax: ---
Fields:

SetVBRA

It allows to configure the enable mask msk of the bank byte_out of the module PMVBRA and the
module parameters.

Syntax: n1 n2 n3 n4 n5 msk byte_out ---


Fields:

• n1: type of management with the following meaning:

0 half-wave variable phase time shutter. default


1 half-wave solid state switch
2 half-wave solid state switch on zero crossing
3 half-wave special time shutter (ratiometric)
8 full-wave variable phase time shutter.
9 full-wave solid state switch
10 full-wave solid state switch on zero crossing
11 full-wave special time shutter (ratiometric)

30 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 2. CAN NETWORK MANAGEMENT IN FORTH

• n2: partitioning value (0÷ 32767). Default value is 0.

• n3: duration of the activation (0 ÷ 255) expressed in hundredth of second. The value 0 indicates
that the activation is continuous. Default value is 0.

• n4: resonance frequency for special time shutter (0 ÷ 600) expressed in tenths of Hz. Default
value is 0.

• n5: inhibition threshold of the TRIAC (0÷ 16383). Default value is 16383.

• msk: output enable mask (the board PMVBRA has only one output and thus this value will
always be 1; it was inserted for uniformity with the commands of the other modules)

• byte_out: output bank number

WARNING
This command must be called after starting the channel scanning with StrVBRA.

The data is stored in a table with address mcfgvbra. The initial address of the buffer of each single
bank has to be calculated as follows:

mcfgvbra + (byte_out * Ldatvbra)

The data are organised as follows:

Offset Dimension Description


0 Byte Functioning mode
1 Byte Activation duration
2 Word TRIAC inhibition threshold
4 Word Test on the TRIAC functioning inhibition threshold
6 Word Resonance frequency for the special time shutter
9 Byte Numbers of half-waves on which the activation cycle for special time
shutter is repeated. Calculated internally.
10 20 Byte Table of each half-wave phases for special time shutter. Calculated
internally.

Example 1
To read the minimum value for trigger of the TRIAC of the bank 2:

mcfgvbra 2 Ldatvbra * + 2 + @

As for the direct usage of the Forth command SetVBRA, in order to store the parameters directly
into memory (according to the previous directions), it is necessary to force the setting of the
parameters (the Forth command does it automatically) writing the value 1 on the 1 byte variable
which address should be calculated in a following way, starting from the initial address
fasivbra:

fasivbra + byte_out

When the updating of the peripheral parameters is completed, the byte value is cleared to 0.

Doc. MS269806 - Ed. 01 -26 June 1998 31


CAN management

Example 2
To force the setting of the parameters of the bank 2:

1 fasivbra 2 + C!

Example 3
In a CAN network are present two modules PMVBRA to which are associated respectively the bank 0 and 1: the
instructions to use are the following:

: TASK
1000 %WAIT ( Wait for possible interrupt from keyboard

( Total reset conditioned by a test


...

( Partial reset
...

( Other enables
...

StrVBRA ( Enable

( Set configuration data of the bank 0


0 0 0 0 2000 1 0 SetVBRA

( Set configuration data of the bank 1


0 0 0 0 2000 1 1 SetVBRA

( Operations at the start of the program and thus start of the task and/or
( interrupt routine
...
;

CfgVBRA

It allows to configure the enable mask msk of the bank byte_out. For this purpose it can be used in
place of the commandSetVBRA.

Syntax: msk byte_out ---


Fields: msk: outputs enabling mask
byte_out: output bank.

WARNING
This command must be called after starting the channel scanning with StrVBRA.

NOTE
The module PMVBRA has only one output, thus the enable mask is always 1.

Example
In a CAN network are present two modules PMVBRA to which are associated respectively the banks 0 and 1. To
enable the management of the outputs the instructions are the following:

: TASK
1000 %WAIT ( Wait for possible interrupt from keyboard

32 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 2. CAN NETWORK MANAGEMENT IN FORTH

( Total reset conditioned by a test


...

( Partial reset
...
( Other enables
...

StrVBRA ( Enable
% 0001 0 CfgVBRA ( Select output of the bank 0
% 0001 1 CfgVBRA ( Select output of the bank 1

( Operations at the start of the program and thus start of the task and/or
( interrupt routine
...
;

WriteVBRA

It allows to write the output n (with n=0 always because the module PMVBRA provides only one
output) of the bank byte_out. Remembering that the partitioning value 0÷100 % is represented with
15 bits with sign, the written data has to be coded as follows:

0% 0
100 % +32767

IMPORTANT
The value to write should be always 16 bit with sign ( 0 > 32767), the negative values are ignored by
clamping them to 0.

Syntax: value n byte_in ---


Fields: value: partitioning value to assign to the output
n: output number (always 0)
byte_out: output bank.

Example
To set the value +50% (+16383) to the output of the bank 1:

1024 0 1 WriteVBRA

ReadVBRA

It allows to read the value of the output n (with n=0 always because the module PMVBRA provides
only one output) of the bank byte_out. Remembering that the partitioning value 0÷100 % is
represented with 15 bits with sign, the returned data has to be interpreted as follows:

0% 0
100 % +32767

Syntax: n byte_in --- value


Fields: n: output number (always =0)
byte_out: output bank.
value: partitioning value
Doc. MS269806 - Ed. 01 -26 June 1998 33
CAN management

Example
To read the partitioning value of the output of the bank 1:

0 1 ReadVBRA

ValVBRA

It returns the address of the variable which contains the image of the output n (with n=0 always
because the module PMVBRA provides only one output) of the bank byte_out of the module
PMVBRA.

Syntax: n byte_out --- addr


Fields: n: output number (always = 0)
byte_out: outputs bank.
addr: image address in memory

Example
To set the partitioning value 10% (3267) to the output of the bank 1:

3267 0 1 ValVBRA !

To set the partitioning value of the output of the bank 2:

0 2 ValVBRA @

it is returned a 15 bits with sign value.

NOTE
The address which is returned on the stack, belongs to RAM buffer named mvalvbra; each channel occupies
one word. Thus this buffer can be accessed with index calculated as follows:

byte_out * 2

Regarding this module other information about its working state is available. It is stored in a table of
RAM with address stsvbra and each bank occupies one byte, thus the access should be done with
index calculated by summing to the basic address the bank number:

stsvbra + byte_out

Within the byte the bits have the following meaning:

Bit Description
0 Mains power supply absence. If for 80 msec is not detected the signal of
synchronism, it is given this signalling which is non-static
1 The driver (TRIAC) does not activate: probable malfunctioning. If after 10
consecutive commands the driver doesn’t activate, it is given this signalling
which is non-static

A further information from the peripheral is the network frequency, measured at the start and at each
insertion of the load, the data is stored in a table with address frqvbra, each bank occupies one byte,
thus the addressing should be done as follows:

34 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 2. CAN NETWORK MANAGEMENT IN FORTH

frqvbra + byte_out

The read value can be 0 if the network frequency has not been determined yet, otherwise 50 or 60
according to the mains frequency.

SrVBRA

It allows to set the relay of the outputn (n=0 always) of the bankbyte_out.

Syntax: n byte_out ---


Fields: n: output number (always 0)
byte_out: outputs bank.

NOTE
It is possible to modify or test the state of the relays also by reading the information in the table with address
reedvbra. Each byte corresponds to a bank, thus the index should be calculated adding to the basic address
the number of the affected bank:

reedvbra + byte_out

Within the byte the bits have the following meaning:

Bit Description
0 Enable relay channel 0

Example
To enable the relay of the bank 2: reed4ana 2 + 0 BSET

RrVBRA

It allows to reset the relay of the output n (n=0 always) of the bank byte_out (see also the note of
the command Sr4VBRA).

Syntax: n byte_out ---


Fields: n: output number (always 0)
byte_out: outputs bank.

?rVBRA

It allows to test the relay of the output n (n=0 always) of the bank byte_out. It returns a flag =1 if
the relay is enabled and 0 otherwise (see also the note of the command SrVBRA).

Syntax: n byte_out --- fl


Fields: n: output number (always 0)
byte_out: outputs bank.
fl= relay state flag

2.5.2 Management of the communication with terminals PMTERM

The software for the management of this module at the moment is not available.

Doc. MS269806 - Ed. 01 -26 June 1998 35


CAN management

2.6 MALFUNCTIONING FORTH MANAGEMENT

In case of communication error or malfunctioning of a node, this node is excluded (this condition is
signalled by the LEDs on the node PCCDIN).
In the application program the condition of error is tested by mean of the Forth word ?NALR_CAN
(Node Alarm CAN).

?NALR_CAN

It returns a flag which signals the condition of error (=1) of the node specified in the stack.
The format of the command is following:

Syntax: n --- fl
Fields: n: node number
fl: error flag.

In particular if the returned flag is equal to 1, it means that the node n is not in a network or had lost
the communication.
In presence of a node alarm, the first operation is to try to recover the communication by changing
speed, using the Forth command VEL_CAN (even when the speed is reset to a current one, this must
be considered a speed change), since this operation re-starts the whole network..
If the malfunctioning persists, the problem can be of hardware nature. It is suggestible to check the
connections of the network and possibly attempt to communicate again with a lower speed.
For example suppose a CAN network with 3 nodes (node 1, 2 and 3): in order to test the occurrence
of an alarm in the network, should be foreseen a Forth structure for check up and recovery (for
example on the supervisor task of the application program):

...
4 1
DO
I ?NALR_CAN
IF
( signalling alarm, for example
." Alarm node " I .
( Attempt of recovering with a speed change
5 VEL_CAN
200 %WAIT ( Wait network re-initialization
ENDIF
LOOP
...

NOTE
It is important that the test of the network alarm condition is excluded for 0,2 ÷ 0,3 seconds after the system
starts.

2.6.1 Probable causes of node alarm

This paragraph lists the most common causes of alarm in a node PCCDIN:

• Absence of power supply of the node.

36 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 2. CAN NETWORK MANAGEMENT IN FORTH

• Hardware damage of the node.

• Damage of the cable connecting the nodes.

• Overload of the network.

• Malfunctions caused by the modules connected to the node. The causes for each module are
reported in the following table:

Module Description
PM8IOA Absence of power supply for the digital outputs (24 Vdc).
PM8INA No cause of error.
PM8POA Absence of power supply for the digital outputs (24 Vdc).
PM8ROA Absence of power supply for the digital outputs (24 Vdc).
PM8ROB Absence of power supply for the digital outputs (24 Vdc).
PM8AIA Absence of power supply for the module (18 Vac, 24 Vdc).
PMVBRA No cause of error.

NOTE
For the free standing modules PM4TIA and PM4ANA there is no sense in indicating causes of error of the
node depending on the module since in these two cases module and node are integrated.

NOTE
For the module PMACQA there is no sense in indicating causes of error of the node depending on the module
since in this case only one module can be connected to the node PCCDIN and the power supply of the
PMACQA is the same of the node.

Doc. MS269806 - Ed. 01 -26 June 1998 37


CAN management

chapter 3. CAN NETWORK MANAGEMENT IN AWL

This chapter is addressed to the programmers, who are going to manage the CAN network with
application programs written in Forth. For a better understanding of this chapter, the user is advised
to consult also the manual [4]. This chapter contains directions on the network configuration and on
the management of the inputs and outputs on the different functional modules.

3.1 CAN CONFIGURATION IN AWL

In ambient AWL the network CAN should be configured within the #DEFPLC block (see [4]) using
some configuration parameters described in this chapter. These parameters are added to the already
known ones (DATA; MERKER; etc.).

NODO node time mod

It defines the features of the node and opens the definition of the peripheral modules connected to it.

Parameters node time mod

• node: node number. It can assume a value between 1 and 32 compatible with the constraints
given by the type of system.

• time: scanning time of the node in milliseconds.

IMPORTANT
The scanning time of the node is always a multiple of 5 milliseconds and input values are
approximated to the upper multiple of 5.
The minimum scanning time of a node is 5 milliseconds.

• mod: number of modules connected to the node. It can be a number from 1 and 8 compatible
with the constraints given by the saturation of the wdw and rdw and those given by the maximum
number of modules of the same type which can be connected to a network according to the table
of the paragraph 1.2 (repeated here for convenience).

Maximum number of modules in a network


System Type of module Max. N° of modules Max. N° of inputs Max. N° of outputs
CTE158 PM8IOA 48 384 384
CTE300/308 PM8INA 48 384 --
CTN350 PM8POA 48 -- 384
PM8ROA 48 -- 384
PM8ROB 48 -- 384
PM8AIA 8 64 --
PM4TIA 6 24 --
PMACQA 6 6 --
PM4ANA.n 6 -- 24
PMVBRA 32 -- 32
PMTERM 6 -- 6

38 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 3. CAN NETWORK MANAGEMENT IN AWL

CTN560 PM8IOA 96 768 768


PM8INA 96 768 --
PM8POA 96 -- 768
PM8ROA 96 -- 768
PM8ROB 96 -- 768
PM8AIA 8 64 --
PM4TIA 6 24 --
PMACQA 6 6 --
PM4ANA.n 6 -- 24
PMVBRA 32 -- 32
PMTERM 6 -- 6

331CPU PM8IOA 128 1024 1024


PM8INA 128 1024 --
PM8POA 128 -- 1024
PM8ROA 128 -- 1024
PM8ROB 128 -- 1024
PM8AIA 16 128 --
PM4TIA 16 64 --
PMACQA 16 16 --
PM4ANA.n 16 -- 64
PMVBRA 32 -- 32
PMTERM 16 -- 16

ENDNODO

It closes the definition of the peripheral modules of the node.

Parameters

INPCAN byte_in

It defines the total number of banks of digital inputs managed by the network.

Parameters byte_in

• byte_in: number of digital inputs banks of the network. It can assume at most the value defined in
the table Maximum number of modules in a network reported at the beginning of the chapter and
must be alwaysmultiple of 4. Default value is 0.

OUTCAN byte_out

It defines the total number of digital outputs banks managed by the network.

Parameters byte_out

• byte_out: number of digital outputs banks of the network. It can assume at most the value
defined in the table Maximum number of modules in a network reported at the beginning of the
chapter and must be alwaysmultiple of 4. Default value is 0.

Doc. MS269806 - Ed. 01 -26 June 1998 39


CAN management

AINPCAN byte_in

It defines the total number of analog inputs banks.

Parameters byte_in

• byte_in: number of analog inputs banks of the node. It can assume at most the value defined in
the table Maximum number of modules in a network reported at the beginning of the chapter.
Default value is 0.

AOUTCAN byte_out

It defines the total number of analog outputs banks.

Parameters byte_in

• byte_out: the number of analog outputs banks of the node. It can assume at most the value
defined in the table Maximum number of modules in a network reported at the beginning of the
chapter. Default value is 0.

VELCAN n

It defines the speed code of the CAN network.

Parameters n

n: speed code. The following table reports the correspondence between code and speed in KHz.

Speed codes
Baud Rate [KHz] Speed code
10 0
25 1
50 2
100 3
125 4
250 5
500 6
800 7
1000 8

PM8IOA byte_in byte_in byte_out

It defines the number of the input bank byte_in and number of the output bank byte_out of the
module PM8IOA connected to the node.

Parameters byte_in byte_out

This parameter must be inserted within NODO...ENDNODO.

40 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 3. CAN NETWORK MANAGEMENT IN AWL

PM8INA byte_in byte_in

It defines the number of the input bankbyte_in of the module PM8INA connected to the node.

Parameters byte_in

This parameter must be inserted within NODO...ENDNODO.

PM8POA byte_in byte_out

It defines the number of the output bankbyte_out of the module PM8POA connected to the node.

Parameters byte_out

This parameter must be inserted within NODO...ENDNODO.

PM8ROA byte_in byte_out

It defines the number of the output bankbyte_out of the module PM8ROA connected to the node.

Parameters byte_out

This parameter must be inserted within NODO...ENDNODO.

PM8ROB byte_in byte_out

It defines the number of the output bankbyte_out of the module PM8ROB connected to the node.

Parameters byte_out

This parameter must be inserted within NODO...ENDNODO.

PM8AIA byte_in msk

It defines the number of the analog input bank byte_in and the mask of the enabled inputs msk of
the module PM8AIA connected to the node.

Parameters byte_in msk

This parameter must be inserted within NODO...ENDNODO.

PM4TIA byte_in msk buff_e type freq gain

It defines the module PM4TIA.

Parameters byte_in msk buff_e type freq gain

Doc. MS269806 - Ed. 01 -26 June 1998 41


CAN management

This parameter must be inserted within NODO...ENDNODO and, since it saturates the node,
there cannot be present other modules.

• byte_in: input bank number

• msk: inputs enable mask

• buff_e: converter input buffer enable flag, with the following meaning:

0 input buffer of the converter disabled Default


1 input buffer of the converter enabled

• type: converter functioning mode, with the following meaning:

0 unipolar 0 ÷ FSR (Full Scale Range) Default


1 bipolar ± FSR

• freq: updating frequency and cut-off frequency of the digital filter with the following meaning:

0 50 Hz / 13,1 Hz Default
1 60 Hz / 15,7 Hz
2 250 Hz / 65,5 Hz
3 500 Hz / 131 Hz

• gain: input amplifier gain:

0 FSR=2,5 V
1 FSR=1,25 V
2 FSR=80 mV Default
3 FSR=20 mV

PMACQA byte_in

The software management of this module is not available.

PM4ANA byte_in byte_out msk n1 n2 n3 n4 n5 n6 n7 n8

It defines the free-standing module PM4ANA.

Parameters byte_out msk n1 n2 n3 n4 n5 n6 n7 n8

This parameter must be inserted within NODO...ENDNODO and, since it saturates the node,
there cannot be present other modules.

• byte_out: output bank number

• msk: outputs enable mask

• n1 ÷ n8: value of increment and decrement for the ramps of the 4 analog outputs. In particular:
42 Doc. MS269806 - Ed. 01 -26 June 1998
chapter 3. CAN NETWORK MANAGEMENT IN AWL

n1 increment for the output channel 0 ÷ 255


0÷ s/100
n2 increment for the output channel 1 ÷ 255
0÷ s/100
n3 increment for the output channel 2 ÷ 255
0÷ s/100
n4 increment for the output channel 3 ÷ 255
0÷ s/100
n5 decrement for the output channel 0 ÷ 255
0÷ s/100
n6 decrement for the output channel 1 ÷ 255
0÷ s/100
n7 decrement for the output channel 2 ÷ 255
0÷ s/100
n8 decrement for the output channel 3 ÷ 255
0÷ s/100

PMVBRA byte_in byte_out msk n1 n2 n3 n4 n5

It defines the module PMVBRA connected to the node.

Parameters byte_out msk n1 n2 n3 n4 n5

This parameter must be inserted within NODO...ENDNODO.

WARNING
Each module PMVBRA has only one time shutter output and thus the value assigned to the
enabling mask will always be 1 and the number of the output channel 0. This is done in order to
keep for the commands corresponding to this module the same syntax as for the commands used for
the other modules that have more than one input or output.

• byte_out: output bank number

• msk: output enabling mask (the board PMVBRA has only one output and thus this value will
always be 1; it was inserted for uniformity with the commands of the other modules)

• n1: type of management with the following meaning:

0 half-wave variable phase time shutter. default


1 half-wave solid state switch
2 half-wave solid state switch on zero crossing
3 half-wave special time shutter (ratiometric)
8 full-wave variable phase time shutter.
9 full-wave solid state switch
10 full-wave solid state switch on zero crossing
11 full-wave special time shutter (ratiometric)

• n2: partitioning value (0÷ 32767). Default value is 0.

• n3: duration of the activation (0 ÷ 255) expressed in hundredths of second. The value 0 indicates
that the activation is continuous. Default value is 0.

• n4: resonance frequency for special time shutter (0 ÷ 600) expressed in tenths of Hz. Default
value is 0.

• n5: inhibition threshold of the TRIAC (0÷ 16383). Default value is 16383.

Doc. MS269806 - Ed. 01 -26 June 1998 43


CAN management

PMTERM byte_in byte_outbyte_in

The software management of this module is not available.

GOCAN

It starts the CAN communication protocol.

Parameters

IMPORTANT
This word has to be the last in the definition of the CAN parameters (see the example of the
following paragraph).

STPCAN

It stops CAN communication protocol.

Parameters

NOTE
This word is alternative to GOCAN and should be the last in the definition of the parameters corresponding
to the CAN. It was foreseen in order to allow the allocation of the RAM areas for the CAN without obligatory
activation of the communication.

3.2 EXAMPLE OF CAN CONFIGURATION IN AWL

For better understanding the definitions given in the previous paragraph refer to the following
example.
To configure a CAN network composed of 5 nodes PCCDIN respectively defined as nodes 1, 2, 3,
4, 5.

• PCCDIN+PM8IOA+PM8IOA+PM8IOA
To the node 1 are connected 3 modules PM8IOA (8 digital inputs + 8 digital outputs) to which
are associated respectively the banks 0, 1 and 2 for the inputs (EC0.0÷EC0.7 - EC1.0÷EC1.7 -
EC2.0÷EC2.7) and 0, 1 and 2 for the outputs (AC0.0 ÷AC0.7 - AC1.0÷AC1.7 - AC2.0÷AC2.7).

• PCCDIN+PM8AIA+PMPOA
To the node 2 are connected a module PM8POA (8 digital power outputs) to which is assigned
the output bank 3 (AC3.0÷AC3.7) and a module PM8AIA (8 analog inputs) to which is assigned
the input bank 0 (AEC0.0÷AEC0.7). In particular should be enabled only the acquisition of the
channels 0, 1, 2, and 3.

• PCCDIN+PM4TIA
To the node 3 is connected a module PM4TIA (4 inputs thermocouples), that saturate the node,
to which is assigned the input bank 1 (AEC1.0÷AEC1.3). In particular should be enabled only the
acquisition of the channels 0, and 2.
• PCCDIN+PM4ANA

44 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 3. CAN NETWORK MANAGEMENT IN AWL

To the node 4 is connected a module PM4ANA (4 analog outputs) that saturate the node, to
which is assigned the output bank 0 (AAC0.0÷AAC0.3). In particular should be managed only the
outputs 1 and 3.

• PCCDIN+PMVBRA+PMVBRA
To the node 5 are connected two modules PMVBRA to which are assigned the output banks 1
(AAC1.0) and 2 (AAC2.0).

For all the nodes thescanning time is 10 msec., whereas the network speed is 500 KHz(code 6).

In the whole network the configuration constraints are respected:

On the node 1: wdw=8+8+8=24 which is <= 64


rdw=8+8=8=24 which is <= 64
M=3 which is <=8

On the node 2: wdw=8+16=24 which is <= 64


rdw=16 which is <= 64
M=2 which is <=8

On the node 3: wdw=64 which is <= 64


rdw=64 which is <= 64
M=1 which is <=8

On the node 4: wdw=64 which is <= 64


rdw=64 which is <= 64
M=1 which is <=8

On the node 5: wdw=8+8=16 which is <= 64


rdw=8+8=16 which is <= 64
M=1 which is <=8

Moreover there are 3 banks of digital inputs, 4 of digital outputs, 2 of analog inputs and 3 of analog
outputs.

Within the application program written in AWL this configuration is translated in the following list:

#DEFPLC
....
....
INPCAN 4 * N° banks for the digital inputs multiple of 4
OUTCAN 4 * N° banks for the digital outputs multiple of 4
AINPCAN 2 * N° banks for the analog inputs
AOUTCAN 3 * N° banks for the analog outputs

VELCAN 6 * Speed 250 KHz

* Definition if the nodes


NODO 1 10 3 * Node 1 - scanning time 10 msec. - 3 peripherals
PM8IOA 0 0 * PM8IOA - bank of input 0 and output 0
PM8IOA 1 1 * PM8IOA - bank of input 1 and output 1
PM8IOA 2 2 * PM8IOA - bank of input 2 and output 2
ENDNODO

Doc. MS269806 - Ed. 01 -26 June 1998 45


CAN management

NODO 2 10 2 * Node 2 - scanning time 10 msec. - 2 peripherals


PM8AIA 0 00001111 * PM8AIA - bank of input 0 - inputs 0,1,2,3
PM8POA 3 * PM8POA - bank of output 3
ENDNODO

NODO 3 10 1 * Node 3 - scanning time 10 msec. - 1 peripherals


* PM4TIA on the bank 0 with inputs 0 and 2 and default parameters
PM4TIA 1 0101 0 0 0 2
ENDNODO

NODO 4 10 1 * Node 4 - scanning time 10 msec. - 1 peripherals


* PM4ANA on the bank 0 with outputs 1 and 3 and ramps = 1 sec
PM4TIA 1 1010 100 100 100 100 100 100 100 100
ENDNODO

NODO 5 10 2 * Node 4 - scanning time 10 msec. - 2 peripherals


* PMVBRA on the bank of output 1 and default parameters
PMVBRA 1 1 0 0 0 0 16383
* PMVBRA on the bank of output 2 and default parameters
PMVBRA 2 1 0 0 0 0 16383
ENDNODO

GOCAN * Start of the communication protocol


....
BE

NOTE
Remember that the definition of peripheral modules must be done within NODO...ENDNODO and the word
GOCAN (or STPCAN) should be the last of the definitions regarding CAN. Otherwise an error will be
signalled in a compilation phase.

3.3 AWL MANAGEMENT OF THE DIGITAL I/O

Regarding the management of the CAN digital I/O, stay valid the AWL instructions used for the
management of the system standard I/O (see [4]), and are added the new operands described later
on.

NOTE
In the following descriptions changes the method of description of the instruction in respect with the one used
in the manuals AWL [4] and [5] of the system. In facts, in this contest, are described the new operands
related to the CAN network I/O and for each one of them is provided only the list of instructions which can be
used. Remember that in the manual [4] on the contrary it is used the method of providing for each described
instruction the list of allowed operands.

NOTE
In the following definitions it is used the expression "Operand test"; if the operand test is allowed this means
that it is possible to test the operand from the TEST page of the PLC (see[4]).

... EC x.y

It identifies the digital inputy (0÷7) of the bank x.

Allowed instructions:U UN O ON S R = I
Operand test: Allowed

46 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 3. CAN NETWORK MANAGEMENT IN AWL

Example:

U EC0.0 * Test input 0 of the bank 0


UN EC4.1 * Test input 1 of the bank 4
= AC0.7 * Conditions the output 7 of the bank 0

... AC x.y

It identifies the digital outputy (0÷7) of the bank x.

Allowed instructions:U UN O ON S R = I
Operand test: Allowed

... ECB x

It identifies the input bankx.

Allowed instructions:L LI T TI
Operand test: Allowed

Example:

L ECB2 * Load input bank 2


T ACB0 * Transfers on the output bank 0

... ECW x

It identifies the word of input composed by the bank


x and x+1.

Allowed instructions:L LI T TI
Operand test: Allowed

... ECD x

It identifies the double word of input composed by the bank


x, x+1, x+2 and x+3.

Allowed instructions:L LI T TI
Operand test: Allowed

... ACB x

It identifies the output bankx.

Allowed instructions:L LI T TI
Operand test: Allowed

... ACW x

It identifies the word of output composed by the bank


x and x+1.

Doc. MS269806 - Ed. 01 -26 June 1998 47


CAN management

Allowed instructions:L LI T TI
Operand test: Allowed

... ACD x

It identifies the double word of output composed by the bank


x, x+1, x+2 and x+3.

Allowed instructions:L LI T TI
Operand test: Allowed

... PEC x

It identifies the input bankx by reading it directly from the peripheral.

Till now the reference was done always to the image of digital inputs which the PLC updates at each
scanning cycle. To access directly to the peripheral is necessary to use this operand.

Allowed instructions:L
Operand test: Allowed

Example:

L PEC1 * Load in ACC1 the state of the inputs of the bank 1 of the
* ÷ 1.7, reading them directly
CAN network, i.e. inputs 1.0
* from the peripheral.
T MB100 * Transfers the image in the MB 100

Then each single input can be tested making reference to the merker corresponding to MB100.

3.4 AWL MANAGEMENT OF THE ANALOG INPUTS

Also for the AWL management of the analog acquisition modules are foreseen the new operands. In
particular it is necessary to pay attention since the number of the bank identifies the type of module
to which the command is addressed, thus the number of the input must be opportunely indicated.

... AEC x.y

It identifies the analog inputy of the bank x and in particular:

Value of y Type of module Read value Physical value


0÷7 PM8AIA -2048 ÷ +2047 -10 Vdc ÷ +10Vdc
-2048 ÷ +2047 -5 Vdc ÷ +5Vdc
-2048 ÷ +2047 0 mA ÷ 20mA
0÷3 PM4TIA 0 ÷ 65535 0 ÷ +FSR (unipolar)
0 ÷ 65535 -FSR ÷ +FSR (bipolar)
0 PMACQA (1) --- ---
(1) Currently not managed by the software

Allowed instructions:L LI T TI
Operand test: Allowed

48 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 3. CAN NETWORK MANAGEMENT IN AWL

Example:

L AEC0.3 * Read analog channel 3 of the bank 0


T DW100 * Transfer in DW100

... MEC x

It identifies the mask of the bank of inputx.

Allowed instructions:L T
Operand test: Allowed

Example:

L KM10101010 * Load in ACC1 the mask


T MEC1 * Transfer the mask to the bank

3.5 AWL MANAGEMENT OF THE ANALOG OUTPUTS

Also for the AWL management of the modules with analog outputs are foreseen new operands. In
particular it is necessary to pay attention since the number of the bank identifies the type of module
to which the command is addressed, thus the number of the output must be opportunely indicated.
The module PMVBRA is considered like a module of analog outputs.

... AAC x.y

It identifies the analog outputy of the bank x.

Value of y Type of module Written value Physical value


0÷3 PM4ANA -2048 ÷ +2047 -10 Vdc ÷ +10Vdc
0 PMVBRA 0 ÷ 32767 0 ÷ 100%

Allowed instructions:L LI T TI U UN O ON S R =
Operand test: Allowed

The Boolean operations (U UN O ON S R =) allow to operate on the relay or simulated relay of


output foreseen in the modules PM4ANA and PMVBRA. For default at the start of the program the
relay is always assumed active.

Example:

L DW100 * Transfer the DW100 to the output 2 of the bank 0


T AAC0.2

U M0.0 * Copy the merker state on the relay of output


= AAC0.2

... MAC x

It identifies the mask of the bank of outputsx.

Doc. MS269806 - Ed. 01 -26 June 1998 49


CAN management

Allowed instructions:L T
Operand test: Allowed

Example:

L KM1010 * Load in ACC1 the mask


T MAC1 * Transfer the mask at the bank 1

3.6 AWL ACCESS TO OTHER PARAMETERS OF THE NETWORK

Also for the access to the other CAN network parameters there were introduced new functions.

... NT n

It identifies the scanning time of the node


n.

Allowed instructions:L T
Operand test: Allowed

Example: To change run time the scanning time of the node 4, setting it to 15 msec.

L KZ15 * Load in ACC1 the value 15


T NT4 * Transfer in NT of the node 4

... DSC x

It identifies other parameters of the network. The value x identifies the CAN system variable
according to the following table.

Index Access Description


0 R/W Network speed code
1 R/W Image of network speed code
2 R Counter incremented on interrupt
3 R Step management CAN
4 Not used
5 Not used
6 Not used
7 Not used
8 Not used
9 Not used
10 R Address of the digital inputs map
11 R Address of the digital outputs map
12 R Address RAM for modules PMACQA
13 R Not used
14 R Address RAM for modules PM8AIA
15 R Address RAM for modules PM4ANA
16 R Address RAM for modules PM4TIA
17 R Address RAM for modules PMVBRA
18 Not used
19 Not used
20 Not used
21 Not used
22 Not used
50 Doc. MS269806 - Ed. 01 -26 June 1998
chapter 3. CAN NETWORK MANAGEMENT IN AWL

23 Not used
24 R Address RAM for terminals PMTERM
25 Not used
26 Not used
27 Not used
28 Not used
29 Not used
30 R Address of nodes scanning time
31 Not used
32 Not used
33 Not used
34 Not used
35 R Address of the module PM8AIA channels map
36 R Address of the module PM4ANA channels map
37 R Address of the module PM4TIA channels map
38 R Address of the module PMVBRA channels map
39 Not used
40 Not used
41 Not used
42 Not used
43 Not used
44 Not used
45 R Address PM4ANA ramps table (see mcfg4ana)
46 R Address PM4ANA updating phase table (see fasi4ana)
47 R Length of the data table for a PM4ANA bank
48 Not used
49 Not used
50 R Address PM4TIA configuration data table (see mcfg4tia)
51 R Address PM4TIA updating phase table (see fasi4tia)
52 R Length of the data table for a PM4TIA bank
53 Not used
54 Not used
55 R Address PMVBRA configuration data table (see mcfgvbra)
56 R Address PMVBRA updating phase table (see fasivbra)
57 R Address of peripherals state table
58 R Address of measured network frequency table
59 R Length of the data table for a PMVBRA bank

Allowed instructions:L T
Operand test: Allowed

Example: To change run time the network speed, setting it to 1000 KHz (code 8)

L KZ8 * Load in ACC1 the value 8 which is code corresponding to


* 1000 KHz
T DSC0 * Transfer in DSC with index 0

... NA x

It identifies the alarm condition of the node


x.
If the operand assumes the value 1 it means that the node is in alarm.

Allowed instructions:U UN O ON
Operand test: Allowed

Doc. MS269806 - Ed. 01 -26 June 1998 51


CAN management

3.7 MALFUNCTIONING AWL MANAGEMENT

In case of communication error or malfunctioning in a node, this node is automatically excluded


(condition signalled by the LEDs on the node PCCDIN).
From the revision 1.00 of the local software of the node PCCDIN, in case of communication error,
the node itself tries to re-enter in network automatically by prompting a speed change.

In the application program the condition of error is signalled by the operand NAx (where x is the
number of the node to test); in conditions of correct functioning of the CAN network no node has to
be in alarm and thus the operand NA of every node should be 0.

In presence of a node alarm, the first operation is to try to recover the communication by changing
speed (even when the speed is reset to a current one, this must be considered a speed change), since
this operation re-starts the whole network.

If the malfunctioning persists, the problem can be of hardware nature. It is suggestible to check the
connections of the network and possibly attempt to communicate again with a lower speed.

Example

...
...
O NA1 * Test alarm conditions of the nodes
O NA2
O NA3
IF
U T0 * To avoid continuos changes of speed
IF
L KZ-1 * Alters the speed code image
T DSC1
R M0.0 * Re-starts the timer T0
ENDIF

ENDIF
UN M0.0 * Timer management to avoid continuos changes of speed
L KT20.0
SE T0
U T0
S M0.0
...
...

NOTE
The test of the network alarm conditions has to be excluded for 0,2÷ 0,3 seconds after starting of the system.

3.7.1 Probable causes of node alarm

This paragraph lists the most common causes of alarm from a node PCCDIN:

• Absence of power supply of the node.

• Hardware damage of the node.

• Damage of the cable connecting the nodes.


52 Doc. MS269806 - Ed. 01 -26 June 1998
chapter 3. CAN NETWORK MANAGEMENT IN AWL

• Overload of the network.

• Malfunctions caused by the modules connected to the node. The causes for each module are
reported in the following table:

Module Description
PM8IOA Absence of power supply for the digital outputs (24 Vdc).
PM8INA No cause of error.
PM8POA Absence of power supply for the digital outputs (24 Vdc).
PM8ROA Absence of power supply for the digital outputs (24 Vdc).
PM8ROB Absence of power supply for the digital outputs (24 Vdc).
PM8AIA Absence of power supply for the module (18 Vac, 24 Vdc).
PMVBRA No cause of error.

NOTE
For the free standing modules PM4TIA and PM4ANA there is no sense in indicating causes of error of the
node depending on the module since in these two cases module and node are integrated.

NOTE
For the module PMACQA there is no sense in indicating causes of error of the node depending on the module
since in this case only one module can be connected to the node PCCDIN and the power supply of the
PMACQA is the same of the node.

3.8 AWL MANAGEMENT OF PERIPHERALS CONFIGURATION CHANGES

In some cases it may be of use to be able to change run-time the configuration of the peripherals.
Therefore here are reported some examples for the devices for which this operation has sense and in
particular for the modules PM4TIA, PM4ANA and PMVBRA.

Example 1
Configuration change for PM4TIA:

....

* SETTING OF PARAMETERS FOR PM4TIA BANK 0


U M10.0 * Updating command
IF
L DSC51 * Test if procedure of parameters sending is free
LAB
L KZ0
=F
IF
L DB100 * Configuration data
L DSC50
TAB

L KZ1 * Start the procedure of parameters transmission


L DSC51
TAB
R M10.0
THEN
THEN

Doc. MS269806 - Ed. 01 -26 June 1998 53


CAN management

Example 2
Configuration change for PM4ANA:

...
* SETTING OF VALUES FOR THE RAMPS PM4ANA BANK 0
U M10.0 * Updating command
IF
L DSC46 * Test if procedure of parameters sending is free
LAB
L KZ0
=F
IF
L DW100 * Channel 0 raising ramp
L DSC45 * Table address
TAB
L DW102 * Channel 1 raising ramp
L DSC45 * Table address
ADD KZ1 * Sum variable offset
TAB * Write byte
L DW104 * Channel 2 raising ramp
L DSC45 * Table address
ADD KZ2
TAB
L DW106 * Channel 3 raising ramp
L DSC45 * Table address
ADD KZ3
TAB
L DW108 * Channel 0 falling ramp
L DSC45 * Table address
ADD KZ4
TAB
L DW110 * Channel 1 falling ramp
L DSC45 * Table address
ADD KZ5
TAB
L DW112 * Channel 2 falling ramp
L DSC45 * Table address
ADD KZ6
TAB
L DW114 * Channel 3 falling ramp
L DSC45 * Table address
ADD KZ7
TAB
L KZ1 * Start the procedure of parameters transmission
L DSC46
TAB
R M10.0
ENDIF
ENDIF
....

Example 3
Configuration change for PMVBRA:

....
* SETTING OF CONFIGURATION PARAMETERS FOR PMVBRA BANK 1
U M10.0
IF
L DSC56 * Test if procedure of parameters sending is free

54 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 3. CAN NETWORK MANAGEMENT IN AWL

ADD KZ1 * Sum offset for second bank


LAB
L KZ0
=F
IF
L DSC55 * Parameters table address
L DSC59 * Offset table parameters for second bank
+F
T DD120 * Calculated address

L DW100 * Mode of functioning


L DD120
TAB
L DW102 * Activation duration in number of periods
L DD120
ADD KZ1 * Offset sum of the parameter
TAB
L DW104 * Minimum value for trigger
L DD120
ADD KZ2
TAW
L DW106 * Threshold of exclusion test TRIAC damaged
L DD120
ADD KZ4
TAW
L DW108 * Resonance frequency
L DD120
ADD KZ6
TAW

L KZ1 * Activate procedure of data sending


L DSC56
ADD KZ1
TAB
R M10.0
ENDIF
ENDIF

...

Doc. MS269806 - Ed. 01 -26 June 1998 55


CAN management

chapter 4. CAN MANAGEMENT SOFTWARE COMPILATION

4.1 INSTALLATION WITH MAKEPRJ

To use the CAN management library, first of all it is necessary to install it in the libraries directory.
Insert the disk ‘CAN NETWORK’ in the drive, launch the program INSTALL and follow directions.
After this operation, in the libraries directory there will be a new sub-directory:

C:\CMZ ( Basic programs )

LIB ( Libraries directory )

RETE CAN ( CAN network Library )

331CPU ( CAN management for 331CPU )


331SYS ( CAN management for systems 331 )
PM4ANA ( PM4ANA management )
PM4TIA ( PM4TIA management )
PM8AIA ( PM8AIA management)
PM8IOA ( PM8IOA management)
PMACQA ( PMACQA management)
PMTERM ( PMTERM management)
PMVBRA ( PMVBRA management)

... ( Other libraries for example PLC, ASSI ...


( Other CMZ software )

When the program MAKEPRJ is used to begin a new job, there will be a new section ‘RETE CAN’
with the following possible options:

CAN
[ ] CAN network, basic software management
[ ] PM8IOA module driver
[ ] PM8IOA test program
[ ] PM8AIA module driver
[ ] PM8AIA test program
[ ] PM4ANA module driver
[ ] PM4ANA test program
[ ] PM4TIA module driver
[ ] PM4TIA test program
[ ] PMACQA module driver
[ ] PMACQA test program
[ ] PMVBRA module driver
[ ] PMVBRA test program
[ ] CAN network terminals driver
[ ] CAN network terminals test program
[ ] CAN network test program
[ ] CAN network management in AWL

56 Doc. MS269806 - Ed. 01 -26 June 1998


chapter 4. CAN MANAGEMENT SOFTWARE COMPILATION

CAN network, basic software management It is the package core; when managing the CAN network
this package has to be always selected.

PM8IOA module driver Select to manage the modules PM8IOA, PM8INA,


PM8POA, PM8ROA, PM8ROAB.

PM8IOA test program Select to compile the test program for the modules PM8IOA,
PM8INA, PM8POA, PM8ROA, PM8ROAB.

PM8AIA module driver Select to manage the module PM8AIA

PM8AIA test program Select to compile the test program for the module PM8AIA.

PM4ANA module driver Select to manage the module PM4ANA

PM4ANA test program Select to compile the test program for the module PM4ANA.

PM4TIA module driver Select to manage the module PM4TIA

PM4TIA test program Select to compile the test program for the module PM84TIA.

PMACQA module driver Select to manage the module PMACQA

PMACQA test program Select to compile the test program for the module PMACQA.

PMVBRA module driver Select to manage the module PMVBRA

PMVBRA test program Select to compile the test program for the module
PMVBRA.

CAN network terminals driver Select to manage the terminal of the CAN network.

CAN network terminals test program Select to compile the test program for the CAN network
terminal PM8AIA.

CAN network test program Select to compile the complete test of the CAN network.

CAN network management in AWL Select to manage the CAN network in a AWL program.

NOTE
The software management of the modules PMACQA and PMTERM at the moment is not available.

WARNING
The CAN management is already present in some systems. In this case it is not necessary to compile
it, unless in order to update the library present in EPROM.

For example if in a system CTX618 (331CPU) are selected: the basic software, the drivers and the
tests for the modules PM8IOA and PM4ANA, the general test of the network, the network
management in AWL, the job directory will be:

Doc. MS269806 - Ed. 01 -26 June 1998 57


CAN management

C:\PROJECT ( Job directory )

LIB ( Libraries )
PLC ( Libraries of PLC )

awlcan.plc ( CAN network management in AWL )


awlcan.upd ( Update file for CAN network management in AWL )
... ( Other managements in AWL )

RETECAN ( CAN network management libraries )

can82200.bmp ( File for the CAN basic software management )


can_hpc.upd ( Update file of the HPC management )
can_hpc.uti ( HPC management File )
can_test.uti ( General test management file )
pm4ana.upd ( Update file of the module PM4ANA )
pm4ana_d.drv ( Driver module PM4ANA )
pm4ana_t.drv ( Test module PM4ANA )
pm4ana_u.drv ( Utility module PM4ANA )
pm8ioa.upd ( Update file of the module PM8IOA )
pm8ioa_t.drv ( Test module PM8IOA )
pm8ioa_u.drv ( Utility module PM8IOA )

... ( Other libraries )


... ( Files referred to the job )

NOTE
The file of the module PM8IOA driver does not exist since the driver of this module, and of the modules
PM8INA - PM8POA - PM8ROA - PM8ROB, are contained in the basic software (can82200.bmp)

NOTE
The files for the CAN network management in AWL are present in the directory PLC and not in the directory
RETECAN.

4.2 INSTALLATION WITHOUT MAKEPRJ

To compile the CAN network management without using the program makeprj.exe it is necessary to
insert in the compilation list of the application program the files for the basic software management,
the files for the management of the single modules, optionally the files for the module tests, for the
general test and for the management AWL in order to manage the network within a program for the
PLC. For the configuration described in the previous paragraph:

... ( Other files


can82200.bmp ( CAN controller management file)
can_hpc.uti ( HPC management file)
pm8ioa_u.drv ( Module PM8IOA utility)
pm8ioa_t.drv ( Module PM8IOA test)
pm4ana_d.drv ( Module PM4ANA driver)
pm4ana_t.drv ( Module PM4ANA test)
pm4ana_u.drv ( Module PM4ANA utility)
can_test.uti ( General test management file)
awlcan.plc ( CAN management in AWL
... ( Other files

NOTE
Remember that for the AWL management it is necessary to compile also the AWLUTI package.
58 Doc. MS269806 - Ed. 01 -26 June 1998
appendix A. PRIMITIVES OF THE COMMANDS

appendix A. PRIMITIVES OF THE COMMANDS

This appendix lists the primitives (basic routines written in Assembler) of some of the commands
used for the CAN network management which can be utilised within subroutines Assembler.

All primitives should be called within a subroutine as follows:

...
JSR .L & name ;
...

where name is the name of the primitive. The parameters have to be passed using the data register of
the CPU as described for each single primitive:

(INPC)

It allows to test a digital input of the CAN network

Parameters of input: d0 .W = Number of the input


Parameters of output: d0 .L = State of the input
Modifies: a0 and d1

(OUTC-SET)

It allows to set a digital output of CAN network

Parameters of input: d0 .W = Number of the output


Parameters of output:
Modifies: a0 and d1

Example
To test the input 5 of the CAN network and if it is active to set the output 1, otherwise the output 2.

...

MOVE .W # 5 d0 ;
JSR .L & (INPC) ;
TST .L d0 ;
ne IF,
MOVE .W # 1 d0 ;
ELSE,
MOVE .W # 2 d0 ;
THEN,
JSR .L & (OUTC-SET) ;
...

(OUTC-RES)

It allows to reset a digital output of the CAN network

Doc. MS269806 - Ed. 01 -26 June 1998 59


CAN management

Parameters of input: d0 .W = Number of the output


Parameters of output:
Modifies: a0 and d1

(OUTC-CHG)

It allows to toggle a digital output of the CAN network

Parameters of input: d0 .W = Number of the output


Parameters of output:
Modifies: a0 and d1

(OUTC)

It allows to test the state of a digital output of the CAN network

Parameters of input: d0 .W = Number of the output


Parameters of output: d0 .L = State of the output
Modifies: a0 and d1

60 Doc. MS269806 - Ed. 01 -26 June 1998


appendix B. PROGRAM FOR THE COMPLETE TEST OF THE NETWORK

appendix B. PROGRAM FOR THE COMPLETE TEST OF THE NETWORK

In all the systems employing a CAN network is available a special command for the complete test of
the network. This command, TST_CANNET must be called from Forth ambient; the first page
which will appear on the PC is a menu of functions which allows the access also to the tests of the
single peripheral modules, beyond the network test described in the chapter 1 (see TST_CAN).

The different pages of the test are not described since they are of easy usage.

Notice that CAN management software is already present in the basic library in some systems and in
this case the complete test TST_CANNET is also present, whereas for other systems it has be
compiled as explained in the chapter 4; in the second case, in order to have the complete test, it is
necessary to select also the test packages of the different modules employed .

Doc. MS269806 - Ed. 01 -26 June 1998 61


CAN management

BIBLIOGRAPHY

[1] CMZ hardware - CAN network


[2] CMZ software - Manuale Forth base (only in Italian)
[3] CMZ software - Axes management in Forth
[4] CMZ software - PLC
[5] CMZ software - Axes management in AWL
[6] CMZ software - Basic notions

62 Doc. MS269806 - Ed. 01 -26 June 1998

You might also like