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: decimal value convert to hex problem
From: Ralph Lange <[email protected]>
To: EPICS Tech Talk <[email protected]>
Date: Thu, 28 Mar 2013 10:22:52 +0100
On Thu Mar 28 2013 09:54:21 GMT+0100 (CET), 张德敏 <[email protected]> wrote:
Dear all,
  I am trying to communicate a serial device using StreamDevice-2-3 on 32-bit Linux OS.  writting values using the following protocol:
      !Innn<cr>   (program mA demand. FFF=10mA, nnn must be 3 hexadecimal digits)
      Reading values using the following protocol:
     ?I<cr>  , and the response is ?Innn.  nnn represents the hexadecimal.
How can I convert decimal to hex when sending value ,and how can I convert hex to decimal when receiving value?
Thanks,
Demin zhang



Hello Demin,

Please refer to the StreamDevice doc that explains the formats [1].
There you will find that the %x and %X converters are converting LONG values from and to hexadecimal digits.

In addition to the hex encoding done by the format converters in StreamDevice, you will have to add Linear Conversion to the ai and ao records you use, converting engineering values (0...10) to raw values (0...4095) and vice versa. (ESLO=0.002442 and LINR=SLOPE should do that. See [2] for details.)

Hope this helps,
~Ralph


[1] http://epics.web.psi.ch/software/streamdevice/doc/formats.html
[2] https://wiki-ext.aps.anl.gov/epics/index.php/RRM_3-14_Analog_Output

References:
decimal value convert to hex problem 张德敏

Navigate by Date:
Prev: decimal value convert to hex problem 张德敏
Next: decimal value convert to hex problem 张德敏
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: decimal value convert to hex problem 张德敏
Next: decimal value convert to hex problem 张德敏
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 ·