Final Power Supply controls
From LNLEpicsWiki
Make an IOC application
$ cd /home/irudolf
$ mkdir top_PScontrols
$ cd top_PScontrols
$ makeBaseApp.pl -t ioc PScontrols
$ makeBaseApp.pl -i -t ioc PScontrolsIOC
Using target architecture linux-x86 (only one available)
The following applications are available:
PScontrols
What application should the IOC(s) boot?
The default uses the IOC's name, even if not listed above.
Application name? PScontrols
Install StreamDevice
$ cd /opt/epics/deviceSupport $ mkdir top_streamApp $ cd top_streamApp $ wget http://epics.web.psi.ch/software/streamdevice/StreamDevice-2-4.tgz uncompress the archive file $ tar -zxvf StreamDevice-2-4.tgz make an EPICS support application $ makeBaseApp.pl -t support streamApp edit into the file /opt/epics/deviceSupport/top_streamApp/configure/RELEASE $ vi configure/RELEASE add the following line to end of the file: ASYN=/opt/epics/deviceSupport/asyn-4.10/
Make the StreamDevice
$ cd StreamDevice-2-4 $ make
Edit into the file /home/irudolf/top_PScontrols/configure/RELEASE
$ vi /home/irudolf/top_PScontrols/configure/RELEASE add the following line to the file: ASYN=/opt/epics/deviceSupport/asyn-4.10/ STREAM=/opt/epics/deviceSupport/top_streamApp/
Make ASYN and StreamDevice available for your DB records:
$ cd /home/irudolf/top_PScontrols edit into the file /home/irudolf/top_PScontrols/PScontrolsApp/src/PScontrolsDBD.dbd $ vi PScontrolsApp/src/PScontrolsDBD.dbd put the following lines into the empty file: ... include "base.dbd" #This line includes definitions on all conventional EPICS Base records like ai, ao, calc, ... include "stream.dbd" #This line includes the device definitions for StreamDevice and adds the "stream" option to the DTYP fields in any I/O records include "asyn.dbd" #This line and the two followings loads the definitions for ASYN which is used by StreamDevice registrar(drvAsynIPPortRegisterCommands) registrar(drvAsynSerialPortRegisterCommands) ...
Edit into the source Makefile:
$ vi /home/irudolf/top_PScontrols/PScontrolsApp/src/Makefile comment out the line "PScontrols_DBD += base.dbd" and insert just after the following line: PScontrols_DBD += PScontrolsDBD.dbd
And insert the following lines into the same Makefile:
$ vi /home/user/top_powerSupply/PSupplyApp/src/Makefile #Following the instructions on page http://epics.web.psi.ch/software/streamdevice/doc/ PROD_LIBS += stream PROD_LIBS += asyn
Make the PScontrols application:
$ cd /home/irudolf/top_PScontrols $ make
Protocol files
Make a directory for the protocol files:
$ cd /home/irudolf/top_PScontrols/iocBoot/iocPScontrolsIOC $ mkdir protocols
Create a protocol file in /home/irudolf/top_PScontrols/iocBoot/iocPScontrolsIOC/protocols (or copy the most recent one there in our case) like: PS_controls_20090219.proto. Insert a line to the start-up script /home/irudolf/top_PScontrols/iocBoot/iocPScontrolsIOC/st.cmd after line "< envPaths":
$ vi /home/irudolf/top_PScontrols/iocBoot/iocPScontrolsIOC/st.cmd
epicsEnvSet ("STREAM_PROTOCOL_PATH", ".:../protocols:./protocols")
Serial port communication
Build up the serial port communication between EPICS records and the power supplies. First open the serial port channels by ASYN in the startup script st.cmd. There are 5 set of power supplies needing individual serial communication:
- Target heating: 4 current regulated power supplies connected parallel; range: 0-10 V, 0-1320 A; name: PSC_4set_target
- Line heating: 3 current regulated power supplies connected parallel; range: 0-15 V, 0-660 A; name: PSC_3set_line
- Magnet (solenoid): 1 current regulated power supply; range: 0-30 V, 0-110 A; name: PSC_magnet
- Anode: 1 voltage regulated power supply; range: 0-300 V, 0-5 A; name: PSV_anode
- Owen: 1 current regulated power supply; range: 0-30 V, 0-50 A; name: PSC_owen
Provided DeviceMaster is installed on your system (consult section: DeviceMaster) you have to add the following lines into the startup script st.cmd:
$ vi /home/irudolf/top_PScontrols/iocBoot/iocPScontrolsIOC/st.cmd
drvAsynSerialPortConfigure ("PSC_4set_target","/dev/ttySI0")
asynSetOption ("PSC_4set_target", 0, "baud", "19200")
asynSetOption ("PSC_4set_target", 0, "bits", "8")
asynSetOption ("PSC_4set_target", 0, "parity", "none")
asynSetOption ("PSC_4set_target", 0, "stop", "1")
asynSetOption ("PSC_4set_target", 0, "clocal", "Y")
asynSetOption ("PSC_4set_target", 0, "crtscts", "N")
drvAsynSerialPortConfigure ("PSC_3set_line","/dev/ttySI1")
asynSetOption ("PSC_3set_line", 0, "baud", "19200")
asynSetOption ("PSC_3set_line", 0, "bits", "8")
asynSetOption ("PSC_3set_line", 0, "parity", "none")
asynSetOption ("PSC_3set_line", 0, "stop", "1")
asynSetOption ("PSC_3set_line", 0, "clocal", "Y")
asynSetOption ("PSC_3set_line", 0, "crtscts", "N")
drvAsynSerialPortConfigure ("PSC_magnet","/dev/ttySI2")
asynSetOption ("PSC_magnet", 0, "baud", "19200")
asynSetOption ("PSC_magnet", 0, "bits", "8")
asynSetOption ("PSC_magnet", 0, "parity", "none")
asynSetOption ("PSC_magnet", 0, "stop", "1")
asynSetOption ("PSC_magnet", 0, "clocal", "Y")
asynSetOption ("PSC_magnet", 0, "crtscts", "N")
drvAsynSerialPortConfigure ("PSV_anode","/dev/ttySI3")
asynSetOption ("PSV_anode", 0, "baud", "19200")
asynSetOption ("PSV_anode", 0, "bits", "8")
asynSetOption ("PSV_anode", 0, "parity", "none")
asynSetOption ("PSV_anode", 0, "stop", "1")
asynSetOption ("PSV_anode", 0, "clocal", "Y")
asynSetOption ("PSV_anode", 0, "crtscts", "N")
drvAsynSerialPortConfigure ("PSC_owen","/dev/ttySI4")
asynSetOption ("PSC_owen", 0, "baud", "19200")
asynSetOption ("PSC_owen", 0, "bits", "8")
asynSetOption ("PSC_owen", 0, "parity", "none")
asynSetOption ("PSC_owen", 0, "stop", "1")
asynSetOption ("PSC_owen", 0, "clocal", "Y")
asynSetOption ("PSC_owen", 0, "crtscts", "N")
Sequencer programs
Make (or copy) sequencer files into /home/irudolf/top_PScontrols/PScontrolsApp/src/ and register the sequencer programs in a dbd file in the same directory. In our case it looks like that:
$ vi ramping_machine_20090409.dbd registrar(TE_current_rampingRegistrar) registrar(IE_current_rampingRegistrar)
Invoke the dbd file in the application makefile:
$ vi /home/irudolf/top_PScontrols/PScontrolsApp/src/Makefile ... PScontrols_DBD += ramping_machine_20090409.dbd ...
Invoke the sequencer libraries in the application makefile:
$ vi /home/irudolf/top_PScontrols/PScontrolsApp/src/Makefile ... PScontrols_LIBS += seq pv ...
Invoke the sequencer program files in the application makefile:
$ vi /home/irudolf/top_PScontrols/PScontrolsApp/src/Makefile ... PScontrols_SRCS += TE_ramping_machine_20090409.stt PScontrols_SRCS += IE_ramping_machine_20090409.stt ...
Define the sequencer compilation rules in the file configure/RELEASE
$ vi /home/irudolf/top_PScontrols/configure/RELEASE SNCSEQ=/opt/epics/sequencer/sncseq-2.0.12
Finally invoke the sequencer programs in the startup script st.cmd:
$ vi /home/irudolf/top_PScontrols/iocBoot/iocPScontrolsIOC/st.cmd seq TE_current_ramping, "instrID=TargEheater" seq IE_current_ramping, "instrID=IonizerEheater"
Make your IOC application:
$ cd /home/irudolf/top_PScontrols $ make
If you change the names of the seqencer files you have to run "make clean" first and then "make".
Starting the IOC
Give read and write privilages to all serial ports:
$ su # chmod a+rw /dev/ttySI* # ls -l /dev/ttyS* # exit
Set the baud rates on the Power Supplies to 19200 bps
Boot the IOC:
$ cd /home/irudolf/top_PScontrols/iocBoot/iocPScontrolsIOC $ ../../bin/linux-x86/PScontrols st.cmd
MEDM
Make a directory for the medm in /home/irudolf/top_PScontrols
$ cd /home/irudolf/top_PScontrols $ mkdir medm
