EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  <19971998  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  <19971998  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: ai record support has an error
From: Benjamin Franksen <[email protected]>
To: [email protected]
Date: Mon, 20 Oct 1997 19:20:28 +0200
Hi Folks,

it's been quite a few weeks ago when one of my colleagues (Goetz
Pfeiffer) had a problem with the ai record and another one (Jens Bergl)
proposed a _very_ simple solution. The problem concerns the record's
behavior when it does linear conversion from a 32 bit raw value to an
analogue (double) value.

The formula

	val = (rval + roff) * eslo + egul

is implemented in the ai record support inside the function convert().
Here, the first thing that happens is

    val = pai->rval + pai->roff;

which leads to an overflow (and thus to an incorrect pai->val) if the
raw value uses all 32 bits and the egul/eguf values are (for example)
min(long) and max(long). This is because the calculation uses long
arithmetic. A simple cast _before_ the calculation like

    val = (double)pai->rval + (double)pai->roff;

solves the problem (one of the casts would do).

	Ben
-- 
The Notorious Neb Nesknarf
// snail: BESSY II, Rudower Chaussee 5, D-12489 Berlin, Germany
// email: [email protected]
// phone/fax: +49(30)6392-4865 / 6392-4859

Replies:
Re: ai record support has an error Marty Kraimer

Navigate by Date:
Prev: Install problem w/epics 3.13beta11 mauro
Next: Re: ai record support has an error Marty Kraimer
Index: 1994  1995  1996  <19971998  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 
Navigate by Thread:
Prev: Install problem w/epics 3.13beta11 mauro
Next: Re: ai record support has an error Marty Kraimer
Index: 1994  1995  1996  <19971998  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 
ANJ, 10 Aug 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·