Differences between revisions 9 and 10
Revision 9 as of 2010-04-15 22:00:03
Size: 2610
Editor: YoichiAso
Comment:
Revision 10 as of 2010-04-15 22:28:16
Size: 5286
Editor: YoichiAso
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
* [[#Installation|Installation]]
 * [[#EpicsCA|EpicsCA]]
 * [[#EPICS IOC|EPICS IOC]]
 * [[#Overview|Overview]]
 * [[#Installation|Installation]]
  * [[#EpicsCA|EpicsCA]]
  * [[#EPICSIOC|EPICS IOC]]
  * [[#GenerateDb|Generating db file, MEDM screens and autoBurt file]]

<<Anchor(Overview)>>
== Overview ==
In CLIO, Picomotors are used everywhere. In this page, how to control those Picomotors through EPICS is explained.
There are a few scripts and configuration files to make the EPICS-Picomotor system work in harmony. The list of scripts and files involved are shown below.

This system mainly consists of two programs. One is an EPICS IOC, named k1pico, which holds PVs (or channels) used to communicate with Picomotors. This IOC resides in {{{/cvs/cds/kami/target/k1pico}}}. The IOC can be started by running {{{startk1pico}}} command.

Another part of the system is a daemon script called {{{pmepics.py}}}. This script connects to those PVs provided by k1pico and wait for changes. Once it detects a change in one of the PVs, it takes an appropriate action, such as changing the speed of a motor, or start/stop motor rotation, etc. Therefore, users can control Picomotors by changing the values of those PVs, either through MEDM or command line tools.

For example, {{{K1:PICO-MC_END_PIT_SPD}}} is used to set the speed (pulses/sec) of the Picomotor for MC end mirror pitch. Another example is {{{K1:PICO-MC_END_PIT_FWD}}}. If {{{pmepics.py}}} detects a change in this channel, it starts or stops the rotation of the Picomotor depending on the value of this channel. If it is 1, the Picomotor starts moving. If it is 0, the motor stops.

The way {{{pmepics.py}}} controls the Picomotors are somewhat hidden from users. However, it is worth explaining the mechanism here since it will helpful to understand the syntax of {{{pmepics.conf}}}.



||File name||Description||Location||
||{{{pmepics.py}}}||The main script which bridges EPICS PVs and Picomotors. This is run by a user.||{{{/cvs/cds/kami/scripts/PicoMotor/}}}||
||{{{pmepics.conf}}}||The main configuration file. This file describes the layout of the Picomotors and associates them with EPICS PVs. This file is used both by {{{pmepics.py}}} and {{{pmGenDbMedm.py}}}||{{{/cvs/cds/kami/scripts/PicoMotor/}}}||
||{{{pmGenDbMedm.py}}}||A script to automatically generate necessary configuration files for EPICS IOC, MEDM and Burt from {{{pmepics.conf}}}. It has to be run by user every time {{{pmepics.conf}}} is modified in order to reflect the changes.||{{{/cvs/cds/kami/scripts/PicoMotor/}}}||
||{{{pmepics.db}}}||A database file for the EPICS IOC (k1pico). It is automatically generated by {{{pmGenDbMedm.py}}}||/cvs/cds/kami/target/k1pico/db/||
||{{{autoBurt.req}}}||This is a Burt request file for the IOC k1pico||
Line 39: Line 63:
<<Anchor(EPICS IOC)>> <<Anchor(EPICSIOC)>>
Line 66: Line 90:
== Generating db file and MEDM screens == <<Anchor(GenerateDb)>>
== Generating db file, MEDM screens and autoBurt file ==

PicoMotor control system using EPICS and Python

Overview

In CLIO, Picomotors are used everywhere. In this page, how to control those Picomotors through EPICS is explained. There are a few scripts and configuration files to make the EPICS-Picomotor system work in harmony. The list of scripts and files involved are shown below.

This system mainly consists of two programs. One is an EPICS IOC, named k1pico, which holds PVs (or channels) used to communicate with Picomotors. This IOC resides in /cvs/cds/kami/target/k1pico. The IOC can be started by running startk1pico command.

Another part of the system is a daemon script called pmepics.py. This script connects to those PVs provided by k1pico and wait for changes. Once it detects a change in one of the PVs, it takes an appropriate action, such as changing the speed of a motor, or start/stop motor rotation, etc. Therefore, users can control Picomotors by changing the values of those PVs, either through MEDM or command line tools.

For example, K1:PICO-MC_END_PIT_SPD is used to set the speed (pulses/sec) of the Picomotor for MC end mirror pitch. Another example is K1:PICO-MC_END_PIT_FWD. If pmepics.py detects a change in this channel, it starts or stops the rotation of the Picomotor depending on the value of this channel. If it is 1, the Picomotor starts moving. If it is 0, the motor stops.

The way pmepics.py controls the Picomotors are somewhat hidden from users. However, it is worth explaining the mechanism here since it will helpful to understand the syntax of pmepics.conf.

File name

Description

Location

pmepics.py

The main script which bridges EPICS PVs and Picomotors. This is run by a user.

/cvs/cds/kami/scripts/PicoMotor/

pmepics.conf

The main configuration file. This file describes the layout of the Picomotors and associates them with EPICS PVs. This file is used both by pmepics.py and pmGenDbMedm.py

/cvs/cds/kami/scripts/PicoMotor/

pmGenDbMedm.py

A script to automatically generate necessary configuration files for EPICS IOC, MEDM and Burt from pmepics.conf. It has to be run by user every time pmepics.conf is modified in order to reflect the changes.

/cvs/cds/kami/scripts/PicoMotor/

pmepics.db

A database file for the EPICS IOC (k1pico). It is automatically generated by pmGenDbMedm.py

/cvs/cds/kami/target/k1pico/db/

||autoBurt.req||This is a Burt request file for the IOC k1pico||

Installation

We assume that EPICS base is installed in /cvs/cds/kami/lib/epics/base.

EpicsCA

Download EpicsCA version 2 (not 3 yet) from below:

http://cars9.uchicago.edu/~newville/Epics/Python/

Extract it in /cvs/cds/kami/lib/epics/.

Set appropriate environmental variables (these are actually set by .cshrc, so you shouldn't have to be bothered).

LD_LIBRARY_PATH=/cvs/cds/kami/lib/epics/base/lib/linux-x86_64
EPICS_BASE=/cvs/cds/kami/lib/epics/base
EPICS_EXTENSIONS=/cvs/cds/kami/lib/epics/extensions
EPICS_HOST_ARCH=linux-x86_64

Run

python setup.py build

You may need to install development files for python, if these are not installed yet.

Run

python setup.py install

as root. Be sure to source /home/controls/.cshrc to set the environmental variables.

EPICS IOC

We want to have a dedicated IOC for the PicoMotor controller. Actually, this section gives you a general procedure to make a generic IOC.

Make a directory in /cvs/cds/kami/target. In this example, we create /cvs/cds/kami/target/k1pico.
Run the following commands in the created directory:

/cvs/cds/kami/lib/epics/base/bin/linux-x86_64/makeBaseApp.pl -t example k1pico
/cvs/cds/kami/lib/epics/base/bin/linux-x86_64/makeBaseApp.pl -i -t example k1pico

example is the name of a template. example is a good template to start. k1pico is the name of your IOC. Usually, we want to start it with k1.

Type make in the directory. The EPICS build system will compile an IOC.

Modify db/*.db file. Then go to iocBoot/iock1pico and run st.cmd.

Now, for the PicoMotor controller, we have to put pmepics.db in the db/ directory. This file is automatically generated by pmGenDbMedm.py script. Then you have to add a line like the following to iocBoot/iock1pico/st.cmd.

dbLoadRecords("db/pmepics.db", "site=K1")

Run the IOC by typing

cd /cvs/cds/kami/target/k1pico/iocBoot/iock1pico
./st.cmd

Generating db file, MEDM screens and autoBurt file

pmGenDbMedm.py is a python script to automatically generate an EPICS db file, MEDM screens and an autoBurt request file.

The usage is:

pmGenDbMedm.py -c pmepics.conf

The syntax of pmepics.conf is explained at the beginning of the file as comments.

CLIO/Technicals/PMEPICS (last edited 2010-04-15 22:51:13 by YoichiAso)