本实例使用motor模块中软电机,通过通道访问控制另一个直流电源IOC的输出电压,并且回读输出电压。 此处使用的另一个IOC为:基于EPICS stream模块的直流电源的IOC控制程序实例-CSDN博客
1)创建这个IOC程序目录结构,操作演示如下:
root@bl02u2-X1:/usr/local/EPICS/program# mkdir softmotor
root@bl02u2-X1:/usr/local/EPICS/program# cd softmotor/
root@bl02u2-X1:/usr/local/EPICS/program/softmotor# ls
root@bl02u2-X1:/usr/local/EPICS/program/softmotor# source /etc/profile.d/epics.sh
root@bl02u2-X1:/usr/local/EPICS/program/softmotor# ls
root@bl02u2-X1:/usr/local/EPICS/program/softmotor# makeBaseApp.pl -t ioc softmotor
root@bl02u2-X1:/usr/local/EPICS/program/softmotor# makeBaseApp.pl -i -t ioc softmotor
Using target architecture linux-x86_64 (only one available)
The following applications are available:softmotor
What application should the IOC(s) boot?
The default uses the IOC's name, even if not listed above.
Application name?
root@bl02u2-X1:/usr/local/EPICS/program/softmotor#
root@bl02u2-X1:/usr/local/EPICS/program/softmotor# ls
configure iocBoot Makefile softmotorApp
2)编辑configure/RELEASE文件,列出本IOC中使用到的模块所在的路径:
...
SUPPORT=/usr/local/EPICS/synApps/support# If any motor controller communication mechanism besides
# the VME backplane is required, then ASYN must be defined.
# Recommended ASYN release: R4-35
ASYN=$(SUPPORT)/asyn
MOTOR=$(SUPPORT)/motor# EPICS_BASE should appear last so earlier modules can override stuff:
EPICS_BASE = /usr/local/EPICS/base...
3) 进入softmotorApp/src/目录,编辑Makefile文件,添加这个IOC将使用到的数据库定义文件和库文件:
PROD_IOC = softmotor
# softmotor.dbd will be created and installed
DBD += softmotor.dbd# softmotor.dbd will be made up from these files:
softmotor_DBD += base.dbd
softmotor_DBD += asyn.dbd
softmotor_DBD += motorSupport.dbd
softmotor_DBD += devSoftMotor.dbd# Include dbd files from all support applications:
#softmotor_DBD += xxx.dbd# Add all the support libraries needed by this IOC
softmotor_LIBS += asyn
softmotor_LIBS += motor
softmotor_LIBS += softMotor# softmotor_registerRecordDeviceDriver.cpp derives from softmotor.dbd
softmotor_SRCS += softmotor_registerRecordDeviceDriver.cpp# Build the main IOC entry point on workstation OSs.
softmotor_SRCS_DEFAULT += softmotorMain.cpp
softmotor_SRCS_vxWorks += -nil-# Add support from base/src/vxWorks if needed
#softmotor_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary# Finally link to the EPICS Base libraries
softmotor_LIBS += $(EPICS_BASE_IOC_LIBS)#===========================include $(TOP)/configure/RULES
4)进入softmotorApp/Db目录,添加数据库实例文件以及Makefile文件:
# softMotor.db
record(motor, "$(P)$(M)SoftMotor") {field(DESC, "Set Voltage")field(SCAN, "Passive")field(DTYP, "Soft Channel")field(VELO, "0.1")field(VBAS, "0.1")field(OUT, "$(USER)SetVoltage") # Set Voltage for another IOC of a devicefield(RINP, "$(P)$(M)convertReadbackValue") # Readback Voltagefield(UEIP, "No")field(URIP, "No")field(PREC, "2")field(EGU, "V")field(DHLM, "40")field(DLLM, "0")field(RTRY, "0")field(TWV, "0.01")field(NTM, "NO")field(MRES, "0.01")field(RRES, "0.01")field(VELO, "0.01")field(VBAS, "0.01")field(IGSET, "1")}grecord(calcout,"$(P)$(M)convertReadbackValue")
{field(DESC,"ReadBack Voltage to feed the SoftMotor Record")field(CALC,"A * 100")field(INPA,"$(USER)Voltage_RBV CP MS")
}
将这个db文件添加到相同路径中的Makefile中:
...
DB += softMotor.db
...
5) 回到这个IOC的顶层目录,执行make命令,编译这个IOC程序。
6)进入iocBoot/iocsoftmotor目录,编辑st.cmd启动脚本:
...
dbLoadRecords("db/softMotor.db","P=SoftMotor:,M=M1:,USER=UDP6721:")
...
7) 启动以上IOC:
root@bl02u2-X1:/usr/local/EPICS/program/softmotor/iocBoot/iocsoftmotor# ../../bin/linux-x86_64/softmotor st.cmd
#!../../bin/linux-x86_64/softmotor
< envPaths
...
epics> dbl
SoftMotor:M1:convertReadbackValue
SoftMotor:M1:SoftMotor
epics>
8) 调出以上两个IOC的图形控制界面:每按一次电机界面中TWF按钮,输出电压增加0.01V。
通过以上转换,能够用电机控制方式来控制一个直流电压源输出电压,如在sscan模块中进行电压扫描:
在SPEC软件中,可以配置一路EPICS电机来设置输出电压:
210.SPEC> dscan sm -1 1 20 1
Total 21 points, 21 secondsScan 15 Fri Dec 01 02:08:26 2023 file = test spec user = blctrl
ascan sm 1 3 20 1# SoftMotor Seconds Seconds Seconds Monitor Detector Counter0 1.0000 1 1 1 0 0 01 1.1000 1 1 1 0 0 02 1.2000 1 1 1 0 0 03 1.3000 1 1 1 0 0 04 1.4000 1 1 1 0 0 05 1.5000 1 1 1 0 0 06 1.6000 1 1 1 0 0 07 1.7000 1 1 1 0 0 08 1.8000 1 1 1 0 0 09 1.9000 1 1 1 0 0 010 2.0000 1 1 1 0 0 011 2.1000 1 1 1 0 0 012 2.2000 1 1 1 0 0 013 2.2900 1 1 1 0 0 014 2.4000 1 1 1 0 0 015 2.5000 1 1 1 0 0 016 2.6000 1 1 1 0 0 017 2.7000 1 1 1 0 0 018 2.8000 1 1 1 0 0 019 2.9000 1 1 1 0 0 020 3.0000 1 1 1 0 0 0Returning sm to 2