g+
g+ Communities
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  <20122013  2014  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014 
<== Date ==> <== Thread ==>

Subject: Re: aiRecord conversion
From: Eric Norum <eric@norum.ca>
To: Bruno Seiva Martins <brunoseivam@gmail.com>
Cc: tech-talk@aps.anl.gov
Date: Tue, 28 Aug 2012 08:31:37 -0700
Well, it may be, "the top Google result for "epics record reference".", but it's still wrong.

Here's the code itself.
static void convert(aiRecord *prec)
{
    double val;


    val = (double)prec->rval + (double)prec->roff;
    /* adjust slope and offset */
    if(prec->aslo!=0.0) val*=prec->aslo;
    val+=prec->aoff;

    /* convert raw to engineering units and signal units */
    switch (prec->linr) {
    case menuConvertNO_CONVERSION:
        break; /* do nothing*/

    case menuConvertLINEAR:
    case menuConvertSLOPE:
        val = (val * prec->eslo) + prec->eoff;
        break;

    default: /* must use breakpoint table */
                if (cvtRawToEngBpt(&val,prec->linr,prec->init,(void *)&prec->pbrk,&prec->lbrk)!=0) {
                      recGblSetSevr(prec,SOFT_ALARM,MAJOR_ALARM);
                }
    }

NOTE TO WHOMEVER IS MAINTAINING http://www.aps.anl.gov/epics/EpicsDocumentation/AppDevManuals/RecordRef/Recordref-8.html#HEADING8-0    ----  IT NEEDS TO BE FIXED!


On Aug 28, 2012, at 6:55 AM, Bruno Seiva Martins <brunoseivam@gmail.com> wrote:

Hi Eric,

I believe you refer to [1]. I was referring to the text that I found in [2], which is the top Google result for "epics record reference". Those texts present different formulas:

[1] val = val * ESLO + EGUL
[2] val = val * ESLO + EOFF

So there seems to be an inconsistency in the documentation. I'll try to set both EOFF and EGUL, as Ralph suggested.

Thanks!




Bruno Seiva Martins


On Tue, Aug 28, 2012 at 10:45 AM, Eric Norum <eric@norum.ca> wrote:
Perhaps you misread the wiki page.  EGUL does not take part in the conversions.  
Here is the salient portion of the wiki page:

The record processing routine performs the following algorithm for all records except those that use the Soft Channel device support routine. Be aware that step 3 is performed only when the record specifies LINEAR:

1. Val= RVAL + ROFF
2. Val = Val * ASLO + AOFF

If the conversion algorithm is LINEAR, the raw value is converted via the equation:

3. val = val * ESLO + EOFF

If the conversion is via a breakpoint table, the new value is obtained.



On Aug 28, 2012, at 5:48 AM, Bruno Seiva Martins <brunoseivam@gmail.com> wrote:

Hi all,

I am having trouble trying to adjust the conversion parameters of an analog input record for a A/D converter.
My AD accepts voltages ranging from -10 to 10 volts and has a resolution of 12 bits.

For -10 volts, it produces a digital output of 0
For 10 volts, 4095

I configured the conversion fields as follows:

EGUF: 10
EGUL: -10
AOFF: 0
ASLO: 1
EOFF: 0
ESLO 0.004884   // which is (EGUF - EGUL) / 4095
ROFF: 0
LINR: LINEAR

Those values seem right to me but, for example, RVAL=1005 gets converted to VAL=4.9084, when it should be VAL=-5.0916. The problem seems to be that the conversion formula isn't taking into account the EGUL field.

According to the EPICS record reference for aiRecord:

The record processing routine performs the following algorithm for all records except those that use the Soft Channel device support routine. Be aware that step 3 is performed only when the record specifies LINEAR:
1. Val= RVAL + ROFF
2. Val = Val * ASLO + AOFF
If the conversion algorithm is LINEAR, the raw value is converted via the equation:
3. val = val * ESLO + EGUL

Seems like the step 3 is not being completely executed, or considering EGUL = 0...


Does anybody know what is wrong? Probably I'm missing something really obvious, but I couldn't figure it out...


Thanks in advance,


Bruno Seiva Martins

-- 
Eric Norum
eric@norum.ca






-- 
Eric Norum
eric@norum.ca





Replies:
Re: aiRecord conversion Ralph Lange
References:
aiRecord conversion Bruno Seiva Martins
Re: aiRecord conversion Eric Norum
Re: aiRecord conversion Bruno Seiva Martins

Navigate by Date:
Prev: Re: aiRecord conversion Bruno Seiva Martins
Next: Re: aiRecord conversion Dirk Zimoch
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014 
Navigate by Thread:
Prev: Re: aiRecord conversion Bruno Seiva Martins
Next: Re: aiRecord conversion Ralph Lange
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICSv4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·