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 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 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: aiRecord conversion |
From: | Bruno Seiva Martins <[email protected]> |
To: | Dirk Zimoch <[email protected]> |
Cc: | [email protected] |
Date: | Tue, 28 Aug 2012 10:28:34 -0300 |
Hi Dirk,I wrote a custom Device Support for this record, so DTYP is set to my custom device. Indeed, it is the device support code that sets those parameters, but only in the init_record routine:epicsFloat64 div;pao->eguf = 10.0;pao->egul = (type == LCN12BMP || type == LCN16BMP) ? 0.0 : -10.0;div = (type == LCN12BMP || type == LCN12BBP) ? 4095.0 : 65535.0;pao->hopr = *eguf;pao->lopr = *egul;pao->eslo = ((pao->eguf) - (pao->egul)) / div;
After the initialization, those parameters are not changed. The read_ai routine only reads into the RVAL field.struct loconState *priv = pao->dpvt;epicsUInt16 value = 0;LOCON_read_analog(priv->address, priv->type, &value);pao->rval = (epicsInt32) value;return 0;Bruno Seiva Martins
On Tue, Aug 28, 2012 at 10:12 AM, Dirk Zimoch <[email protected]> wrote:Hi Bruno,
Many drivers overwrite EOFF and ESLO with their own calculations (from EGUL and EGUF and their own assumptions about the raw value range).
So the important missing information is: What driver are you using (DTYP)?
Dirk
Bruno Seiva Martins wrote:
Hi all,If the conversion algorithm is |LINEAR|, the raw value is converted
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
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