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  <20152016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: ai RVAL via asyn + modbus: getting unsigned integer
From: [email protected]
To: [email protected]
Date: Wed, 2 Dec 2015 16:26:59 -0800 (PST)


I am reading from an Acromag XT1221 analog input module, into the RVAL
field of an ai record, via asyn and modbus.  

This module encodes analog voltages as 16-bit signed integers, but it
appears that EPICS interprets them as unsigned integers when it
reports the RVAL.  As the input voltage crosses from a small positive
to a small negative value, RVAL discontinuously jumps from a small
positive integer to a large positive integer.  The VAL computed from
RVAL via ESLO and EOFF also jumps discontinuously.

For example when the input voltage is +0.009 V:

 $ caget Iso:GantryCouch:Collimator:Actual.RVAL
Iso:GantryCouch:Collimator:Actual.RVAL 17

 $ caget -0b Iso:GantryCouch:Collimator:Actual.RVAL
Iso:GantryCouch:Collimator:Actual.RVAL 10110

But when the input voltage is -0.002 V:

 $ caget Iso:GantryCouch:Collimator:Actual.RVAL
Iso:GantryCouch:Collimator:Actual.RVAL 65534
 $ caget -0b Iso:GantryCouch:Collimator:Actual.RVAL
Iso:GantryCouch:Collimator:Actual.RVAL 1111111111111110

I expected this RVAL to be reported (in decimal) as a small negative
integer, not a large positive integer.  (The binary numbers are not
exactly equal to the decimal numbers because the voltage varies
slightly between caget samples).  Displaying the record contents with
dpbr (in iocsh) shows the same thing: large positive RVAL with small
negative voltages.

Here is part of the template that generates the ai record:


Here is part of the template that generates the ai record:

record(ai, "$(ROOM="Iso"):$(SUBSYSTEM):$(SETTING):Actual") {
  field(DESC, "$(DESC)")
  field(SCAN, "I/O Intr")
  field(DTYP, "asynInt32")
  field(INP, "@asynMask(CollimCouch, $(OFFSET), 16, 1000)MODBUS_DATA")
  field(LINR, "SLOPE")
  field(ESLO, "$(ESLO=1.0)")
  field(EOFF, "$(EOFF=0.0)")
  ...
}

Here is the configure call in st.cmd.  The modbusFunction is 4
and the modbusDataType is 0, which (with DTYP asynInt32) should select 
16-bit word, in binary twos-complement format:

drvModbusAsynConfigure("CollimCouch", "AcromagCollimCouch",0,4,0,9,0,100,"AcromagXT1221")

Is there anything I can do to get a signed integer in this RVAL, so
small negative voltages result in small negative integers?

Jon Jacky





Replies:
RE: ai RVAL via asyn + modbus: getting unsigned integer Mark Rivers

Navigate by Date:
Prev: Re: migration from old EPICS Base Hartman, Steven M.
Next: RE: ai RVAL via asyn + modbus: getting unsigned integer Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: problem building msi with base-3.15.3 Pete Jemian
Next: RE: ai RVAL via asyn + modbus: getting unsigned integer Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 16 Dec 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·