EPICS-Tools-modbus-s7plc-SDDs7plc

advertisement
Document Template
Document Number
Chess Core Template
Date
2012-jul-11
Revision
0
State
Released
EPICS Tools Modbus and s7plc on ESS Vm
Installation Manual
Document Template
Document Number
Chess Core Template
Date
2012-jul-11
TABLE OF CONTENTS
1.
IOC set up ................................................................................................ 3
1.1
On Virtal Machine ............................................................................................ 3
1.2
On Hardware device ........................................................................................ 4
1.3
Installation ...................................................................................................... 4
2.
Creating basic IOC ................................................................................... 5
2.1
EPICS_CA_ADDR_LIST ..................................................................................... 5
3.
EPICS Modbus support ............................................................................. 6
3.1
Case study ...................................................................................................... 6
4.
EPICS s7plc support ................................................................................. 8
4.1
Case study ...................................................................................................... 8
5.
ITER FRAMEWORK S7PLC SUPPORT ........................................................ 9
5.1
Case study ...................................................................................................... 9
6.
References ............................................................................................. 11
List of Abbreviations ..................................................................................................... 12
LIST OF APPENDICES
2(12)
Document Template
Document Number
Chess Core Template
Date
2012-jul-11
1.
IOC SET UP
1.1
On Virtal Machine
This document describes how to prepare ESS Vm to test EPICS Modbus and s7plc support.
VMware Player 5.0.2 was used. Configure new ESS Virtual Machine:

Start VMware Player.

Select Create New Virtual Machine.

Select Install from: Installer disc image file (iso): and select iso file:
ESS_SL6.3_x86_64_CODAC-4.0.iso, press "Next".
(https://public.esss.dk/ad/ks/codac/4.0/ESS_SL6.3_x86_64_CODAC-4.0.iso)

Define Linux as Guest operating system: Version is Read Hat Enterprise Linux 6
64-bit.

Define Virtual machine name and location where it will be stored, press "Next".

Specify Disk Capacity. 20GB or more is recommended. Select "Store virtual disk
as a single file" option, press "Next".

Press on the "Customize hardware..." button and customize other Hardware
parameters (select more Memory, define network, …). Press "Close" button.

Finish New Virtual Machine Wizard. This starts linux installation.
Linux installation on ESS Virtual Machine:



Select the type of installation. Pre-configured x64 AD VM with sda (vmware,
virtualbox, …).
Installation begins with Retrieving installation files.
A storage device warning is displayed. With new installation we select Yes,
discard any data.

Installation packages are installed.

When installation is finished, we define a user and password for this user.

o
Enter username: ess-dev
o
Enter password: spall23
o
Repeat password
After the installation has finished the virtual machine will reboot.
3(12)
Document Template
Document Number
Chess Core Template
Date
2012-jul-11
1.2
On Hardware device
Please follow the instructions on the following link (you will need ESS username and
password):
https://twiki.esss.dk/ad/index.php/Software
ISO image for CODAC 4.0 is available on:
https://public.esss.dk/ad/ks/codac/4.0/ESS_SL6.3_x86_64_CODAC-4.0.iso
1.3
CODAC Installation
EPICS is a part of CODAC and can be installed from a private RPM repository. The installation
is similar to installing any other package. sudo yum install “package” command is used for
the installation.

In the test setup we installed all CODAC components with sudo yum install
codac-core-4.0-codac-{role} command.
RPM Package
System Role
codac-core-4.0-codac-mc
Mini CODAC
codac-core-4.0-codac-ct
CODAC Terminal
codac-core-4.0-codac-psh
PSH
codac-core-4.0-codac-pcf
PCF
codac-core-4.0-codac-mc-devel
Mini CODAC for Development
codac-core-4.0-codac-psh-devel PSH for Development
codac-core-4.0-codac-pcf-devel
PCF for Development
codac-core-4.0-codac-devel
All roles - Complete CODAC Core System
For example: sudo yum install codac-core-4.0-codac-devel.
4(12)
Document Template
Document Number
Chess Core Template
Date
2012-jul-11

Restart Vm after installation is finished.
CODAC in installed in /opt/codac/.
EPICS is installed in /opt/codac/epics/.
2.
CREATING BASIC IOC
To install an IOC server it is assumed that EPICS base has been correctly installed. Then, the
following steps must be accomplished:
1. First of all, it is necessary to create a directory, preferably out of $EPICS_BASE, that will
be considered as < TOP > directory in the IOC installation:
(a) mkdir ~/epicsapps/ioc
(b) cd ~/epicsapps/ioc
2. The execution of the following perl script will automatically arrange the necessary files in
the < TOP > directory to build the IOC.
(a) makeBaseApp.pl -t example iocAppname
(b) makeBaseApp.pl -t example -i iocAppname
3. To build the application (in < TOP > directory) execute:
(a) make
4. Finally, to run the IOC application:
(a) cd < TOP >/iocBoot/iocAppname
(b) ../../bin/linux-x86_64/iocAppname st.cmd
Basic IOC is now built. Folder name ioc and application name iocAppname used in this
example, should be substituted with other names.
2.1
EPICS_CA_ADDR_LIST
For the Channel Acces to get response from the IOC server we should set the
EPICS_CA_ADDR_LIST environment variable. The addresses in EPICS_CA_ADDR_LIST may
be dotted IP addresses or host names if the local OS has support for host name to IP
address translation. When multiple names are added to EPICS_CA_ADDR_LIST they must be
separated by while space. There is no requirement that the addresses specified in the
EPICS_CA_ADDR_LIST be a broadcast addresses, but this will often be the most convenient
choice.
5(12)
Document Template
Document Number
Chess Core Template
Date
2012-jul-11
To set this variable permanently we can add it to /etc/opt/codac-4.0/env.d/caRepeater and
reboot the server. In our test case I added IP address of the IOC :
EPICS_CA_ADDR_LIST="127.0.0.0"
3.
EPICS MODBUS SUPPORT
The Modbus driver is installed with command:

sudo yum install *modbus*
The asyn driver that is used with Modbus was already installed.
Modbus is installed in /opt/codac/epics/modules/Modbus/. Asyn is installed in
/opt/codac/epics/modules/asyn/.
We can check installed versions with:

rpm –qa |grep Modbus

rpm –qa |grp asyn
We can display additional information about a package with rpm –qi package_name.
3.1
Case study
In order to explain how to use this application, a case study was prepared. EPICS program
has a counter that increases its value at defined intervall. This values are written to the
output records. Output records send their values to the PLC. EPICS input records are used to
read back this values from the PLC.
Simatic project can be reteived from Modbus_simatic.zip and downloaded to the PLC.
EPICS program can be unpacked from the file modbus_epics.tgz. Procedure:
1.
2.
3.
4.
5.
6.
Create folder : mkdir ~/performancetesting
Copy modbus_epics.tgz to this folder and open folder.
Extract archive: tar zxvf modbus_epics.tgz
Open folder modbus: cd modbus/testSiemens
Make program: make
Program parameters can be changed in files:
a. ./iocBoot/iocmodbus/testsi.substitutions
b. ./iocBoot/iocmodbus/testsi.cmd
c. ./modbusApp/Db/testsi.template
d. ./ modbusApp/src/arcalc.c
6(12)
Document Template
Document Number
Chess Core Template
Date
2012-jul-11
testsi.substitutions
With parameters in this file we can define how much data is exchanged beetven EPICS an
PLC.
testsi.cmd
This file is the startup script for the EPICS program. In this file we configure modbus
communication:



Before modbus port drivers can be created, it is necessary to first create at least one
asyn TCP/IP or serial port driver to communicate with the hardware. The commands
required depend on the communications link being used. For TCP/IP use the
following standard asyn command: drvAsynIPPortConfigure(portName, hostInfo,
priority, noAutoConnect, noProcessEos).
o drvAsynIPPortConfigure("sim1"," 192.168.1.1:502 ",0,0,1)
After creating the asynIPPort, the next step is to add the asyn "interpose interface"
driver. This driver takes the device-independent Modbus frames and adds or removes
the communication-link specific information for the TCP protocol. The interpose driver
is created with the command modbusInterposeConfig(portName, linkType,
timeoutMsec, writeDelayMsec).
o modbusInterposeConfig("sim1",0,2000,0)
Once the asyn IP or serial port driver has been created, and the modbusInterpose
driver has been configured, a modbus port driver is created with the following
command: drvModbusAsynConfigure(portName, tcpPortName, slaveAddress,
modbusFunction, modbusStartAddress, modbusLength,dataType, pollMsec, plcType)
o drvModbusAsynConfigure("A0_In_Word1", "sim1", 1, 3, 1, 125, 2, 10,
"Simulator")
o drvModbusAsynConfigure("A0_Out_Word1", "sim1", 1, 6, 10, 123, 2, 0,
"Simulator")
We also load the template which will load epics records
dbLoadTemplate("testsi.substitutions").
testsi.template
This template defines the counter that is used to increase values at defined rate.
testsiinout.template
This template defines input and output records used to exchange data with the PLC.
arcalc.c
This is a subrutine file used increse values of the counter.
7. Make program must be run if change is made: make
8. To run the program:
a. cd ~/performancetesting/ modbus/testSiemens/ iocBoot/iocmodbus/
7(12)
Document Template
Document Number
Chess Core Template
Date
2012-jul-11
b. ../../bin/linux-x86_64/modbus testsi.cmd
4.
EPICS S7PLC SUPPORT
With CODAC installation the s7plc EPICS driver was already installed. But this is the version
modified by ITER. Since I use my own PLC program to perform the tests, the driver must be
changed with the standard s7plc driver:
1. Move original driver to backup directory: sudo cp -r /opt/codac/epics/modules/s7plc
/opt/codac/epics/modules/s7plcOLD
2. Extract s7plc.tgz co current folder.
3. Move extracted files to modules folder: sudo mv s7plc /opt/codac/epics/modules/
4.1
Case study
In order to explain how to use this application, a case study was prepared. EPICS program
has a counter that increases its value at defined intervall. This values are written to the
output records. Output records send their values to the PLC. EPICS input records are used to
read back this values from the PLC.
Simatic projects can be reteived from S7plc_simatic.zip and downloaded to the PLC. There
are 6 projects prepared, depending on the number of tcp channels used and send interval.
EPICS program can be unpacked from the file s7plc_epics.tgz. Procedure:
Open folder : cd ~/performancetesting
Copy s7plc_epics.tgz to this folder.
Extract archive: tar zxvf s7plc_epics.tgz
Open folder modbus: cd s7plc/testSiemens
Make program: make
Program parameters can be changed in files:
a. ./psiplcApp/Db/tests7.substitutions
b. ./iocBoot/psiplc/st.cmd
c. ./psiplcApp/Db/tests7.template
d. ./ psiplcApp/src/arcalc.c
tests7.substitutions
1.
2.
3.
4.
5.
6.
With parameters in this file we can define how much data is exchanged beetven EPICS an
PLC.
st.cmd
This file is the startup script for the EPICS program. In this file we configure s7plc
communication:

To configure the s7plc driver we use command s7plcConfigure (PLCname, IPaddr,
port, inSize, outSize, bigEndian, recvTimeout, sendIntervall, configuration version).
8(12)
Document Template
Document Number
Chess Core Template
Date
2012-jul-11
o
s7plcConfigure PLC400,192.168.1.1,2000,8000,8000,1,500,25, "PLCSample 0"
We also load the template which will load epics records: dbLoadTemplate
"db/tests7.substitutions".
tests7.template
This template defines the counter that is used to increase values at defined rate.
tests7inout.template
This template defines input and output records used to exchange data with the PLC.
arcalc.c
This is a subrutine file used increse values of the counter.
7. Make program must be run if change is made: make
8. To run the program:
c. cd ~/performancetesting/ s7plc/testSiemens/ iocBoot/psiplc/
d. ../../bin/linux-x86_64/psiplc st.cmd
5.
ITER FRAMEWORK S7PLC SUPPORT
The CODAC packages were already installed so no additional installation is needed. S7plc is
installed in /opt/codac/epics/modules/s7plc/.
We can check installed versions with:
•
rpm –qa |grep s7plc
We can display additional information about a package with rpm –qi package_name.
5.1
Case study
In order to explain how to use this application, a case study is proposed. It consists of
reading from and writing to two registers of an PLC. The PLC writes a watchdog value
(switching continously from 0 to 1) in the register %MW58. This value is read by EPICS
through Modbus and written back in the %MW0 PLC’s register. The IP assigned to the PLC is
10.5.2.175.
1.
Upload project framework-iter.zip to the PLC.
2.
Start SDD Editor.
3.
Create an I&C project and function:

Right click on I&C Projects, select Add a New I&C Project and name it:
“frameworkcase”.
9(12)
Document Template
Document Number
Chess Core Template
Date
2012-jul-11


4.
Right click on Plant System I&Cs, select Add Plant System I&C with CBS
L1: “CWS”.
Set the CBS2 Name of your Plant System I&C to “CWS-TCPH”.
Create the Controllers:

In SDD Editor, right click on the CWS-TCPH (Plant System I&C).

Choose Import Control Unit List, and select the Control Units file
framework_controlunits.xls.

Confirm that the two controllers have been added in Control Units and that
both their host names have been set correctly.
5.
Create the Variables:

In SDD Editor, right click on the CWS-TCPH (Plant System I&C).

Choose Import Variable
framework_Variables.xls.

Confirm that a new function has been created and that the three
variables have been added into it.
6.
List,
and
select
the
Variables
file
Generate the I&C project

In SDD Editor, right click on the frameworkcase:V1 I&C project and select
Generate Configuration Files.

Select the option to create I&C Project Unit automatically in your home
folder and select directory.

Select the option to delete the existing I&C Project Unit.

Click OK.
7.
Compile and run the application

Switch to the Maven view.

Compile and make your project run by right-clicking on it, going to
Execution and selecting Clean, Compile and Run.

3 IOCs were started, one for the PSH Core Application, one for the PLC
IOC, and one for the System Monitor.
8.
Import project in CSS

Start CSS by going to a terminal and typing: CSS &

Import projest by selecting: File -> Import -> General -> Existing Projects
into Workspace and click Next>

Browse for our m-frameworkcase project and click OK.
10(12)
Document Template
Document Number
Chess Core Template
Date
2012-jul-11

Project m-frameworkcase will appear selected. Clisk Finish.

Software unit should now appear in the Navigator view.
9.
View CSS COY interface

To view CSS BOY screen for our test variables we must navigate to:
frameworkcase -> target -> main -> boy -> sdd and open CWS-TCPHfwk.opi
If CSS GUI variables appear s Disconnected first check in Maven Editor if our IOCs are
running. If they are, check CSS settings in: Edit -> Preferences... -> CSS Core -> EPICS addr_list
f
6.
REFERENCES
1. EPICS Tech-Talk page. http://www.aps.anl.gov/epics/tech-talk/index.php
2. EPICS Home page. http://www.aps.anl.gov/epics/
3. EPICS Modbus driver. https://subversion.xor.aps.anl.gov/synApps/modbus/
4. EPICS s7plc driver http://epics.web.psi.ch/software/s7plc/
5. EPICS Tools Installation Manual CTRL-CN-EP00-ESS-07-MAN.pdf.
6. CSS training: Exercise_6_-_PLC_Integration_9NYD4G_v1_6.pdf.
7. ESS wiki https://twiki.esss.dk/ad/index.php/Software:Preparing_a_virtual_machine
8. ESS wiki
https://twiki.esss.dk/ad/index.php/Software:CODAC_Core_System_installation
11(12)
Document Template
Document Number
Chess Core Template
Date
2012-jul-11
LIST OF ABBREVIATIONS
Abbreviation
Definition
12(12)
Download