PROFIBUS - Description Interface PLC-PC
The following description is a overview for the functionality of
the PC-PLC interface.
Communication with the control system
The actual data exchange takes places by means of three types
of different data areas:
1. Control block, a matrix of 8 words, 16 bits each
2. Order, acknowledge and
3. notification blocks and Data blocks.
|
1. Control block
The control clock occupies 8 words in a PLC data block (DB).
The address of the control block (DB and offset inside the PLC) must
be defined in the project file and may be changed at any time. The
address is fixed after the program of the PC was started.
The contents of the control block could be seen as a sequence of words,
where each word has a special task to perform. Each corresponding
bit of the words may be related to a channel, e.g. there are 16 available
channels:
Channel:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Word1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 Order
Word2 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 Busy
Word3 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 Ready
Word4 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 Error
Word5 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 Notify
Word6 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 Error
Word7 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 reserved
Word8 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 Startup
|
| - |
The ORDER word is used by the PLC each
time, the PLC wants to send a command to the PC |
| - |
The BUSY word (2) shows the active status
of that channel |
| - |
The READY word (3) shows the idle status
of that channel |
| - |
The ERROR word (4) will be set, if a
command was executed and returned an error |
| - |
The NOTIFY word (5) will be set, if
an event occurred, without a previous command. For instance, if a
channel is receiving data from an external communication partner,
normally no command is given to this channel in advance. So, an incoming
message (telegram) causes a notification on that channel |
| - |
The ERROR word (6) will be set, if an
event occurred with an error condition |
| - |
The STARTUP word (8) is set to all ones
at each startup of the PC. This word must be monitored by the PLC
program and should be set to zero after all 1s have been detected.
An indication of all 1s shows that the PC has executed a restart
and possible pending commands may have been lost, for example due
to a power cycle. In this case the PLC has to repeat the command given
before |
| |
|
| |
The bit pattern shown above indicates
the inactive status of all channels and is created at the startup
of the PC.
The PC accesses all (!) words of the control block with read and write
operation while the PLC is allowed only to write to word 1 and 8:
the ORDER and the RESTART word. Since there is no synchronization
between the PC and the PLC, and the operation of each channel should
be asynchronous too, certain limitation of the timing must be considered:
The PLC may only write to the ORDER word if the contents is all
zero.
The control block is constantly monitored by the PC. As soon as
the PC detects a bit set to one in the ORDER word, it will clear the
ORDER word, clear the corresponding bit in the READY word and set
the corresponding bit in the BUSY word. As the PC can write only entire
words to the PLC, no single bit can be modified.
Lets assume the PLC sets the ORDER word for channel 0. This is detected
shortly after by the PC, which starts modifying the control block.
If at this time the PLC wants to set a command on channel 1 and does
not wait until the ORDER word is zero it may happen, that the PLC
sets the bit and some milliseconds later the PC clears the entire
ORDER word due to the previous command on channel 0. In this case,
the command on channel 1 will be lost. |
| |
|
| |
1.1. Acknowledge block
The acknowledge block is the second part of the sequence order,
acknowledge and notification block. Its length is configurable.
The acknowledge block contains information regarding the execution
of a command previously given from the PLC to the PC.
The address of the acknowledge block is determined by the address
of the order block plus the length of the order block plus 1. The
address is fixed during runtime. There is a specific acknowledge block
for each channel.
1.2. Notification block
The notification block is the third part of the sequence order,
acknowledge and notification block. Its length is configurable.
The notification block contains information regarding an event that
happened due to external activities.
The address of the notification block is determined by the address
of the order block plus the length of the order block plus the length
of the acknowledge block plus 1. The address is fixed during runtime.
There is a specific notification block for each channel.
1.3. Data block
1. Data blocks are areas of PLC memory that may be used
optionally with this interface. If the data to be exchanged via a
channel is too large in order to fit into a order, acknowledge or
notification block, the address of the data block may be specified
inside these blocks. The length of a data block is limited due to
the profibus limitations and must be kept smaller than 240 bytes.
2. The data block contains the actual information exchanged between
the PLC and the PC. The address is not fixed at runtime and is specified
by the PLC programmer inside the order block. Care must be taken to
specify a valid address since the PC has no possibility to check the
correctness of the address. Important data in the PLC memory may be
over written if a false address is given. |
| |
|
2. Exchanging commands
In order to send a command to the VIPA the following sequence
of program execution has to be considered:
1. Check the READY status of the channel
2. Set the order buffer to the appropriate command and user data
3. Set the start bit in the ORDER word.
Status of the control block after the command was given:
Channel:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Word1 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 ORDER
Word2 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 BUSY
Word3 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 READY
Word4 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 ERROR
Word5 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 NOTIFY
Word6 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 ERROR
The PC detects the command. The order is
cleared, BUSY is set and READY is cleared.
Status of the control block after the
command was detected:
Channel: 0 1 2 3
4 5 6 7 8 9 10 11 12 13 14 15
Word1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ORDER
Word2 1 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 BUSY
Word3 0 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 READ
Word4 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 ERROR
Word5 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 NOTIFY
Word6 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 ERROR
Now the command is executed
by the PC. During this time no second command may be given on this
channel, because the PC will reject it with a DUPLICATE error code.
After the command was finished
the status for this channel will be reset to default. It depends
on the result of the command whether the bit in the ERROR word (4)
is set or not.
Status after execution
of the command:
Channel:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Word1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 ORDER
Word2 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 BUSY
Word3 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 READY
Word4 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 ERROR
Word5 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 NOTIFY
Word6 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 |