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  <20132014  2015  2016  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  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Help beginner with ASYN device support, ai record conversion to EGU
From: Ralph Lange <[email protected]>
To: EPICS Tech Talk <[email protected]>
Date: Mon, 13 May 2013 21:57:30 +0200
Hi Andrew,

+1 on using StreamDevice - no question.

About your failing conversion:

If you want to use LINR=LINEAR, your device support has to convert EGUF and EGUL to EOFF and ESLO in its special_linconv() routine. If it doesn't, the linear conversion at run time (doing "val = val * ESLO + EOFF") always yields 0.
For the other option, SLOPE, your database has to set ESLO and EOFF instead of EGUL/EGUF.

So, to convert 0...4095 (raw) to 0...1000 (uA), I would use
   LINR=SLOPE
   ESLO=0.2442
and not set EOFF, ASLO, or AOFF (as they all default to 0).

The ai page in the Record Reference Manual [1] does document this, though maybe not prominent enough. It's a wiki, so please feel encouraged to improve it if necessary.

Hope this helps,
~Ralph

[1] https://wiki-ext.aps.anl.gov/epics/index.php/RRM_3-14_Analog_Input




On Mon May 13 2013 19:37:06 GMT+0200 (CEST), Mark Rivers <[email protected]> wrote:

Hi Andrew,

 

I would second what Eric suggested about using StreamDevice.  The only thing you need to write is a protocol file, no C code.

 

asyn now comes with a new document explaining how to do that:

 

asyn-4-21/documentation/HowToDoSerial/HowToDoSerial_StreamDevice.html

 

This document is not on the asyn Web site yet (will fix that), but it is included in the documentation directory in asyn.

 

Mark

 

 

 

J:\epics\devel\asyn-4-21\documentation\HowToDoSerial\HowToDoSerial_StreamDevice.html

 

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Eric Norum
Sent: Monday, May 13, 2013 12:15 PM
To: Gomella, Andrew (NIH/NHLBI) [F]
Cc: epics Techtalk
Subject: Re: Help beginner with ASYN device support, ai record conversion to EGU

 

1) LINR should be SLOPE.

2) I recommend that you have a look at StreamDevice -- it's now what I'd recommend as the best place to start to support a message-based device.

 

 

On May 13, 2013, at 10:07 AM, "Gomella, Andrew (NIH/NHLBI) [F]" <[email protected]> wrote:

 

> Hi,

>

> I have been following Eric Norum's "How To Do Serial" guide ( http://www.aps.anl.gov/epics/modules/soft/asyn/R4-21/HowToDoSerial/tutorial.pdf) to write an application to control a serial port controller table top x-ray source.

>

> So far everything works near perfectly (Thanks to Eric for the guide, and the writers of ASYN/EPICS), my only issue is that I am having trouble getting the Analog Input and Output fields to work properly. I can easily read and write the raw values (0 to 4095 due to it being a 12 bit DAC inside the xray's controller) but when I change the .db record to try and use ASYN's built in functions to convert the value I run in to issues. I'm definitely missing something that is probably obvious for most techtalk readers.

>

> Here is one of the commands in the app source file.

>

> {&DSET_AI, GPIBREAD, IB_Q_LOW, "RD1", NULL, 0, 127, NULL, 0, 0, NULL, NULL, NULL},

>

> The controller responds to RD1 with 0000\r  with 0000 being from 0000 to 4095. (I tried using the format function, i.e. with "%u\r" but this didn't seem to work, but with NULL it does.)

>

> Here is the corresponding section of my db file.  (which is how I was hoping it would work at first) srxr is the name of my device.

>

> record(ai, "$(P)$(R):uAStatus")

> {

>    field(DESC, "Read Xray uA Monitor")

>    field(SCAN, "1 second")

>    field(DTYP, "srxr")

>    field(LINR, "LINEAR")

>    field(ASLO, "0.244")

>    field(AOFF, "0")

>    field(EGUF, "900")

>    field(EGUL, "0")

>    field(EGU, "uA")

>    field(INP,  "#L$(L) A$(A) @11")

> }

>

> I tried changing DTYP to asynInt32, and then changing INP to the @asyn format, but this did not seem to work.

>

> I also tried to change several of the fields, such as LINR to SLOPE. So far I only get the field showing as 0 (when it should be reading

> an output, or as the raw value.

>

> Here are relevant portions of st.cmd

>

> ## Register all support components

> dbLoadDatabase "dbd/srxr.dbd"

> srxr_registerRecordDeviceDriver pdbbase

>

> ## Load record instances

> dbLoadRecords("db/devsrxr.db","P=srxr,R=,L=0,A=0")

>

> drvAsynSerialPortConfigure("L0","/dev/ttyS0",0,0,0)

> asynSetOption("L0", -1, "baud", "9600")

> asynSetOption("L0", -1, "bits", "8")

> asynSetOption("L0", -1, "parity", "none")

> asynSetOption("L0", -1, "stop", "1")

> asynSetOption("L0", -1, "clocal", "Y")

> asynSetOption("L0", -1, "crtscts", "N")

>

> As is, this just reads out the raw values of uA, rather than it being converted to EGU.

>

> Alternatively someone can point me to example source code that runs a serial device, but is more complex

> than the filter wheel in the "How To Do Serial" guide (uses more record types like ai etc).

>

> I couldn't find any that helped me with this issue.

>

> Thanks,

> Andrew

>

 

 



References:
Help beginner with ASYN device support, ai record conversion to EGU Gomella, Andrew (NIH/NHLBI) [F]
Re: Help beginner with ASYN device support, ai record conversion to EGU Eric Norum
RE: Help beginner with ASYN device support, ai record conversion to EGU Mark Rivers

Navigate by Date:
Prev: RE: CA subscription synchronisation shutdown problem Hill, Jeff
Next: Modbus TCP and Omega S. Banerian
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: Help beginner with ASYN device support, ai record conversion to EGU Mark Rivers
Next: Modbus TCP and Omega S. Banerian
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 20 Apr 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·