Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
NOTA DE APLICAO 03
Princpios bsicos da programao de PLC para
BC e IL230x-Cxxx com TwinCAT PLC
BRESIMAR (asaTek)
e-mail j.andril@bresimar.pt
B-NA03(v1.1)
Janeiro/2009
Table Of Contents
1.
2.
3.
4.
5.
6.
Introduction ....................................................................................................................3
1.1.
PLC Boxes (IL230x-Cxxx)................................................................................................... 3
1.2.
BC9000 and IL230x-C900................................................................................................... 3
1.3.
Firewall and Anti-Virus Programs ....................................................................................... 3
BC I/O System Configuration ....................................................................................................4
2.1.
Configuration for BC9000 and IL230x-Cxxx via Ethernet ................................................. 4
2.1.1.
Settings the IP Address ............................................................................................... 4
2.1.2.
Scan Ethernet network ................................................................................................ 4
2.1.3.
Compatible Terminal Types ....................................................................................... 7
2.1.4.
Download BC9000 Configuration via Ethernet ......................................................... 8
2.2.
Configuration for BC and IL230x-Cxxx via Serial Connection ........................................ 10
2.2.1.
Add I/O Terminals to BC .......................................................................................... 13
2.2.2.
Download Configuration via Serial Connection ....................................................... 15
2.3.
Saving TwinCAT System Manager Configuration File .................................................... 16
Creating the BC PLC Project .................................................................................................. 17
3.1.
Create PLC Project ............................................................................................................. 17
3.2.
BC Input and Output Process Images ................................................................................. 19
3.3.
Writing the BC PLC Program ............................................................................................ 21
3.4.
Compiling the BC PLC Program ....................................................................................... 22
Downloading BC PLC Project................................................................................................. 24
4.1.
Select Target BC9000 for Ethernet Connection ................................................................ 24
4.2.
Configure COM Port for Serial Connection ...................................................................... 26
4.3.
Download BC PLC Program ............................................................................................. 27
4.4.
Editing BC PLC Program................................................................................................... 30
4.5.
Create BC Boot Project ..................................................................................................... 31
Checking BC Input and Output Images ................................................................................ 32
5.1.
Export BC Input and Output Images ................................................................................. 32
5.2.
Import BC Input and Output Images ................................................................................. 33
BC Program Cycle Time ......................................................................................................... 35
22/11/2004
V1.3
8/12/2004
V1.4
14/6/2005
Updated: 15/06/2005
Page 2 of 38
Revision: 1.4
1. Introduction
The BC series of bus controllers have a single PLC task that can be used to implement a
PLC program to interact with the I/O terminals connected to it. This allows the BC to be
used as a stand-alone PLC controller, and is configured using a serial connection
the Ethernet port for the serial connection port. As many modern lap-top computers
have built-in Ethernet ports, but no serial communication ports, the Ethernet connection
from the serial connection. If a section heading does not indicate Ethernet or Serial
Connection, the section applies to both methods.
via Ethernet.
Wherever possible, firewalls should be disabled completely on a PC being used to
configure a remote TwinCAT device via Ethernet. If this cannot be done, a trusted
zone must be configured for the range of IP addresses in use on the TwinCAT network,
although this does not prevent some firewalls from interfering with TwinCAT traffic.
Norton Personal Firewall is known to cause problems in this respect.
Updated: 15/06/2005
Page 3 of 38
Revision: 1.4
available later as target devices for the PLC program. In addition, any terminals
connected to the device can be scanned to check the current I/O configuration.
To scan the Ethernet network:
1. Right click I/O Devices
2. Select Append Device
Updated: 15/06/2005
Page 4 of 38
Revision: 1.4
Updated: 15/06/2005
Page 5 of 38
Revision: 1.4
TwinCAT System Manager will add the selected devices to the Ethernet master, scan the
terminals connected to the devices and display the terminal configuration found.
TwinCAT System Manager
Updated: 15/06/2005
Page 6 of 38
Revision: 1.4
System Manager cannot always detect exactly what type of terminal has been found.
To correct the list of terminals fitted to a device:
1. Right click on the terminal that is to be changed
2. Select Change to Compatible Type
3. Select the actual terminal fitted.
Updated: 15/06/2005
Page 7 of 38
Revision: 1.4
Updated: 15/06/2005
Page 8 of 38
Revision: 1.4
5. Click OK to restart the system in run mode, and download the updated I/O
configuration to the BC9000
TwinCAT System Manager will indicate that the local system is now running, and
TwinCAT PLC will be able to access the BC9000 to download the PLC program.
Updated: 15/06/2005
Page 9 of 38
Revision: 1.4
3. Select a master controller appropriate for the BC controller you are using. This
example will use a BC3100, so a PROFIBUS-DP master controller must be selected
4. Click OK
Updated: 15/06/2005
Page 10 of 38
Revision: 1.4
5. Click Cancel
Updated: 15/06/2005
Page 11 of 38
Revision: 1.4
TwinCAT System Manager will show a master controller with a slave BC or IL230x-Cxxx
controller. The example system below shows a PROFIBUS-DP master controller with a
BC3100 connected.
Updated: 15/06/2005
Page 12 of 38
Revision: 1.4
Updated: 15/06/2005
Page 13 of 38
Revision: 1.4
TwinCAT System Manager will add the selected terminals to the controller. Steps 1 to 6
Updated: 15/06/2005
Page 14 of 38
Revision: 1.4
Updated: 15/06/2005
Page 15 of 38
Revision: 1.4
Updated: 15/06/2005
Page 16 of 38
Revision: 1.4
) in TwinCAT PLC
Updated: 15/06/2005
Page 17 of 38
Revision: 1.4
LD Ladder
ST
Structured Text
TwinCAT PLC will create a new blank PLC project for the BC controller.
Updated: 15/06/2005
Page 18 of 38
Revision: 1.4
terminals. It is important to know how the input and output images are structured to
ensure that the PLC input and output images correspond to the correct inputs and
outputs.
NOTE: this note assumes that only compact analogue and digital inputs and
outputs were used in the I/O configuration using TwinCAT System Manager.
Working along the K-bus from the BC:
1. Analogue terminals are added to the process images starting at %IW0 and %QW0,
and are added in the order in which they are found.
2. Each channel on compact analogue terminals uses 2 bytes of data.
3. Digital terminals are added to the process images starting AFTER the analogue
inputs and outputs, and are added in the order in which they are found.
4. Each channel on a digital terminal will use 1 bit of data, and is assigned to the
next available bit.
NOTE: if no analogue terminals are fitted, the digital inputs and output will start
KL4032
Channel
Input Image
Output Image
%IW0
----
%IW2
----
----
%QW0
----
%QW2
Digital Terminals
KL1002
KL1002
KL2032
KL2032
Updated: 15/06/2005
%IX4.0
----
%IX4.1
----
%IX4.2
----
%IX4.3
----
----
%QX4.0
----
%QX4.1
----
%QX4.2
----
%QX4.3
Page 19 of 38
Revision: 1.4
The input and output process images can now be declared for the program, and
variables assigned to each input and output. The lines of code required are shown
below. It is advisable to declare input and output variables as global variables to ensure
(* Inputs *)
AnIn1
AnIn2
DigIn1
DigIn2
DigIn3
DigIn4
(* Outputs *)
AnOut1
AnOut2
DigOut1
DigOut2
DigOut3
DigOut4
AT
AT
AT
AT
AT
AT
%IW0
AT
AT
AT
AT
AT
AT
%QW0
%IW2
:
:
%IX4.0
%IX4.1
%IX4.2
%IX4.3
%QW2
%QX4.0
%QX4.1
%QX4.2
%QX4.3
INT;
INT;
:
:
:
:
:
:
BOOL;
BOOL;
BOOL;
BOOL;
INT;
INT;
:
:
:
:
BOOL;
BOOL;
BOOL;
BOOL;
END_VAR
3. Enter the input and output variable declarations as required. Any variables
declared here will be available to all program modules (POUs) in the BC program.
Updated: 15/06/2005
Page 20 of 38
Revision: 1.4
Updated: 15/06/2005
Page 21 of 38
Revision: 1.4
1. Select Project
2. Select Rebuild all
Updated: 15/06/2005
Page 22 of 38
Revision: 1.4
warnings.
Updated: 15/06/2005
Page 23 of 38
Revision: 1.4
1. Select Online
2. Select Choose Run-Time System
Updated: 15/06/2005
Page 24 of 38
Revision: 1.4
TwinCAT PLC will show the BC9000 as the target system for the PLC program in the red
Updated: 15/06/2005
Page 25 of 38
Revision: 1.4
1. Select Online
2. Select Communication Parameters
3.
4.
5.
6.
7.
Select the Baud rate for the BC. Default baud rate is 19200
Select the COM port to be used on the local PC
Updated: 15/06/2005
Page 26 of 38
Revision: 1.4
1. Select Online
2. Select Login
If the BC does not currently have a program loaded, it will ask if you want to download
Updated: 15/06/2005
Page 27 of 38
Revision: 1.4
4. Select Online
5. Select RUN
Updated: 15/06/2005
Page 28 of 38
Revision: 1.4
Updated: 15/06/2005
Page 29 of 38
Revision: 1.4
1. Select Online
2. Select Logout
TwinCAT PLC will go off-line, and the PLC program can be edited. When the required
changes have been made, the program must be re-compiled and downloaded to the BC.
(Refer to section 3.4, Compiling the BC PLC Program on page 22 and section 4.3,
Download BC PLC Program on page 27.)
Updated: 15/06/2005
Page 30 of 38
Revision: 1.4
1. Select Online
2. Select Create Bootproject
TwinCAT PLC will create the boot project in the BC. When this process is complete:
3. Click OK to finish.
Updated: 15/06/2005
Page 31 of 38
Revision: 1.4
are fixed.
The exported variable names may be changed AFTER they have been imported into the
BC PLC program to make them easier to use in the PLC program. However, if the
variable names were to be re-imported at a later date due to a change in the I/O
configuration, the modified names would be lost.
Updated: 15/06/2005
Page 32 of 38
Revision: 1.4
1. Select Project
2. Select Import
Updated: 15/06/2005
Page 33 of 38
Revision: 1.4
The imported input and output process images are shown in the variable declaration
window. These can be compared with the user-generated input and output process
images to ensure that no mistakes have been made.
Updated: 15/06/2005
Page 34 of 38
Revision: 1.4
1. Select Online
2. Select Coupler
3. Select Start Cycle Time Measuring
Updated: 15/06/2005
Page 35 of 38
Revision: 1.4
4. Select Online
5. Select Coupler
6. Select Stop Cycle Time Measuring
Updated: 15/06/2005
Page 36 of 38
Revision: 1.4
7. Select Online
8. Select Coupler
9. Select Read Cycle Time Measuring
Updated: 15/06/2005
Page 37 of 38
Revision: 1.4
times are displayed, along with the Middle cycle time. The Actual cycle time is the
average measured PLC cycle time taken over the number of measured cycles.
Updated: 15/06/2005
Page 38 of 38
Revision: 1.4