EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  <20222023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  <20222023  2024 
<== Date ==> <== Thread ==>

Subject: PyDevice modbus
From: liuxiaomin via Tech-talk <tech-talk at aps.anl.gov>
To: "Smith, Martin via Tech-talk" <tech-talk at aps.anl.gov>
Date: Fri, 22 Jul 2022 14:14:01 +0800

Hi,

I am trying to control a device which can get the temperature values ,Because the register address of the values not continuous, so I did not use the Modbus module under EPICS, but used modbus_tk under python to get the value. In order to match with EPICS, I used the support module PyDevice which is an EPICS device support for Python interpreter, When I run the st.cmd file, the following error occurs, So now there are three files, the db file, the st.cmd file and the wave.py file that gets the temperature data.

 

The db files is as flollows:

record(ai, "$(user):GETDATA")

{

   field(DTYP, "pydev")

   field(INP,"@temp1.getData()")

   field(SCAN, "1 second")

}

 

record(waveform, "$(user):TEMP")

{

   field(DTYP, "pydev")

   field(INP, "@pydev.iointr('temp_sent')")

   field(SCAN, "I/O Intr")

   #field(INP, "@temp1.temp_array")

   field(NELM, "1000")

   field(FTVL, "DOUBLE")

}

 

The st.cmd files is as follows:

#!../../bin/linux-x86_64/waveioc

< envPaths

epicsEnvSet("EPICS_CA_SERVER_PORT", 5070)

epicsEnvSet("IOCNAME","waveioc")

cd "${TOP}"

## Register all support components

dbLoadDatabase "dbd/waveioc.dbd"

waveioc_registerRecordDeviceDriver pdbbase

drvModbusAsynConfigure("WORDIR","CAT1",slaveAddress,modbusFunction,modbusStartAddr,modbusLen,dataType,posMsec,"plcType")

pydev("import sys; sys.path.insert(0,'${PWD}')")

pydev("import modbus_tk")

pydev("from wave import Temp")

pydev("temp1 = Temp('192.168.0.11','502')")

dbLoadRecords "db/dbWaveform.db", "user=${IOCNAME}"

cd "${TOP}/iocBoot/${IOC}"

iocInit

 

I encounter a problem, the obtained temperature values are all 0, the real temperature are not 0. If only used  modbus_tk without PyDevice, there is no such error, and can caget the real temperature .

 

caget   waveioc:TEMP

waveioc:TEMP   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

 

When the command file runs, it shows:

#!../../bin/linux-x86_64/waveioc

< envPaths

epicsEnvSet("IOC","waveioc")

epicsEnvSet("TOP","/home/iocusr/xm/waveioc")

epicsEnvSet("MODULES","/opt/epics/base/../modules")

epicsEnvSet("AUTOSAVE","/opt/epics/base/../modules/autosave-R5-7-1")

epicsEnvSet("ASYN","/opt/epics/base/../modules/asyn-R4-41")

epicsEnvSet("BUSY","/opt/epics/base/../modules/busy-1-6-1")

epicsEnvSet("CALC","/opt/epics/base/../modules/calc-R3-7-4")

epicsEnvSet("CAPUTLOG","/opt/epics/base/../modules/caPutLog-3-5")

epicsEnvSet("IOCSTATS","/opt/epics/base/../modules/iocStats-3-1-16")

epicsEnvSet("MODBUS","/opt/epics/base/../modules/modbus-R3-2")

epicsEnvSet("NETDEV","/opt/epics/base/../modules/netDev-1-0-6")

epicsEnvSet("PC-MONITOR","/opt/epics/base/../modules/PC-MONITOR1-0-2")

epicsEnvSet("PROCSERVCONTROL","/opt/epics/base/../modules/procServControl-1-9")

epicsEnvSet("S7NODAVE","/opt/epics/base/../modules/s7nodave-2-1-3")

epicsEnvSet("S7PLC","/opt/epics/base/../modules/s7plc")

epicsEnvSet("SSCAN","/opt/epics/base/../modules/sscan-2-10")

epicsEnvSet("STREAM","/opt/epics/base/../modules/StreamDevice-2-8-9")

epicsEnvSet("SNCSEQ","/opt/epics/base/../modules/seq-2-2-6")

epicsEnvSet("PYDEVICE","/opt/PyDevice")

epicsEnvSet("EPICS_BASE","/opt/epics/base")

epicsEnvSet("EPICS_CA_SERVER_PORT", 5070)

epicsEnvSet("IOCNAME","waveioc")

cd "/home/iocusr/xm/waveioc"

## Register all support components

dbLoadDatabase "dbd/waveioc.dbd"

waveioc_registerRecordDeviceDriver pdbbase

Executing Python code: import pydev

Executing Python code: import builtins

Executing Python code: builtins.pydev=pydev

Executing Python code: import pydev

pydev("import sys; sys.path.insert(0,'${PWD}')")

pydev("import modbus_tk")

Executing Python code: import modbus_tk

Traceback (most recent call last):

  File "<string>", line 1, in <module>

ModuleNotFoundError: No module named 'modbus_tk'

pydev("from wave import Temp")

Executing Python code: from wave import Temp

Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "/usr/lib/python3.7/wave.py", line 2, in <module>

    import modbus_tk

ModuleNotFoundError: No module named 'modbus_tk'

pydev("temp1 = Temp('192.168.0.11','502')")

Executing Python code: temp1 = Temp('192.168.0.11','502')

Traceback (most recent call last):

  File "<string>", line 1, in <module>

NameError: name 'Temp' is not defined

dbLoadRecords "db/dbWaveform.db", "user=waveioc"

cd "/home/iocusr/xm/waveioc/iocBoot/waveioc"

iocInit

Starting iocInit

############################################################################

## EPICS R7.0.5

## Rev. 2021-09-13T15:44+0800

############################################################################

sevr=info s7plcInit: no stations configured

drvStreamInit: Warning! STREAM_PROTOCOL_PATH not set. Defaults to "."

iocRun: All initialization complete

epics>

 Why can't I get the real temperature value?

 

Thanks

xiaomin

 

 


Replies:
Re: PyDevice modbus Mark Rivers via Tech-talk
Re: [EXTERNAL] PyDevice modbus Vodopivec, Klemen via Tech-talk

Navigate by Date:
Prev: Re: [EXTERNAL] Phoebus Scan Server Ian Gillingham via Tech-talk
Next: Re: PyDevice modbus Mark Rivers via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  <20222023  2024 
Navigate by Thread:
Prev: RE: CS-Studio: File Manager configuration when executing external command Zhang, Tong via Tech-talk
Next: Re: PyDevice modbus Mark Rivers via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  <20222023  2024 
ANJ, 14 Sep 2022 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·