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

Subject: aiRecord/devGpib problem
From: Andrew Wagner <[email protected]>
To: [email protected]
Date: Fri, 6 Aug 2010 16:56:03 -0700
Hey guys, 

I've got EPICS and ASYN running and have successfully followed one of Eric Norum's examples to talk to an Agilent 34970A MUX (over IP) and store the *IDN in a stringin record. I'm having problems however with reading a voltage measurement back reliably. I create device support with the devGpib template and the commands: 

  /* Param 0 -- Read identification string */
  {&DSET_SI, GPIBREAD, IB_Q_HIGH, "*IDN?\n++read eoi",NULL, 0, 200, NULL, 0, 0, NULL, NULL, NULL},

  /*Param 1 -- Read Measurement @ Channel */ 
  {&DSET_AI, GPIBREAD, IB_Q_HIGH, "MEAS:VOLT:DC? (@203)\n++read eoi", NULL, 0, 200, readMEAS, 0, 0, NULL, NULL, NULL} 

I'm interfacing with the GPIB device via the PROLOGIX GPIB-Ethernet controller, (Google them, they're pretty neat) so you can ignore the ++read eoi part of the command string. The conversion method is: 


static int readMEAS( struct gpibDpvt *pdpvt, int P1, int P2, char **P3){ 

  struct aiRecord *pai= (struct aiRecord *)pdpvt->precord;

  double meas; 
  sscanf(pdpvt->msg,"%lg",&meas); 
  printf("meas %f\n",meas); 
  printf("Messge Length %d. Msg %s\n",pdpvt->msgInputLen,pdpvt->msg);
  meas = (double)atof(pdpvt->msg);
  printf("meas %f\n",meas); 
  pai->val = meas;

  return 0;

}

I set:

asynSetTraceMask("L0",-1,0x9)
asynSetTraceIOMask("L0",-1,0x2)

in my st.cmd to do some debugging. When I force one of my voltage measurement records to process the first time I get: 

epics> dbtr AG34970:VOLT:Coil 
epics> 2010/08/06 15:39:30.848 172.25.100.85:1234 write 32
MEAS:VOLT:DC? (@203)\n++read eoi\n
2010/08/06 15:39:31.011 172.25.100.85:1234 read 17
+2.99865210E+00\n\003
meas 2.998652
Messge Length 15. Msg +2.99865210E+00
meas 2.998652

This is exactly what I expect since I'm supplying the MUX with 3 V at Channel 203. So far so good. When I print the record I get: 

epics> dbpr AG34970:VOLT:Coil
ASG:                DESC: Coil Voltage  DISA: 0             DISP: 0             
DISV: 1             NAME: AG34970:VOLT:Coil                 RVAL: 0             
SEVR: INVALID       STAT: UDF           SVAL: 0             TPRO: 0             
VAL: 2.9986521  

My first newbie question is why is SEVR: INVALID? The VAL is certainly what I want it to be. The problem occurs if I try to process the record more than once: 

epics> dbtr AG34970:VOLT:Coil
epics> 2010/08/06 15:39:49.785 172.25.100.85:1234 write 32
MEAS:VOLT:DC? (@203)\n++read eoi\n
2010/08/06 15:39:49.948 172.25.100.85:1234 read 17
+2.99867890E+00\n\003
meas 0.000000
Messge Length 16. Msg +2.99867890E+00
meas 0.000000

Hmmm........an ASCII string indicating an appropriate value is read but converted into a double of 0.0000 . Note the message length has increased by 1. Its as if a hidden character is appended somewhere that screws up the sscanf and atof functions. Perhaps there is a more error proof way to convert ASCII to doubles? Has anyone seen this before? I have no such problem with my stringin record. I can send *IDN? and read the device name reliably. 

Thanks very much for your help. I will happily make any device support I get working public. 

Cheers, 

Andrew Wagner



 




Replies:
RE: aiRecord/devGpib problem Mark Rivers
RE: aiRecord/devGpib problem Allison, Stephanie

Navigate by Date:
Prev: Re: BOY - XY Graph and macro substitution John William Sinclair
Next: Re: BOY - XY Graph and macro substitution PaweÅ PrÄdki
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: NI USB-6221 BNC Szalata, Zenon M.
Next: RE: aiRecord/devGpib problem Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Sep 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·