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

Subject: A problem with modbus reading floating point numbers
From: 高振华 via Tech-talk <tech-talk at aps.anl.gov>
To: "mark rivers" <rivers at cars.uchicago.edu>
Cc: tech-talk at aps.anl.gov
Date: Wed, 17 Nov 2021 16:36:38 +0800 (GMT+08:00)
Hi Mark,

I am reading the ai value of moxa E1242 multifunctional IO module and I have a problem,

Cannot display floating point numbers, only integer numbers, 

cannot display decimal places.

What's the reason? thanks.


#moxa1242.cmd
#!./../../bin/linux-x86_64/modbusApp
< envPaths
dbLoadDatabase("../../dbd/modbus.dbd")
modbus_registerRecordDeviceDriver(pdbbase)
drvAsynIPPortConfigure("moxa","192.168.127.254:502",0,0,1)
asynSetOption("moxa",0, "disconnectOnReadTimeout", "Y")
modbusInterposeConfig("moxa",0,5000,0)
#read moxa E1242 AI_scaledValue,7 is little endian,8 is big endian
drvModbusAsynConfigure("MOXA_E1242_In_Word",   "moxa",    255, 4,  0x208,  0x8,    0x7,  2000,    "moxa E1242")
# Enable ASYN_TRACEIO_HEX on octet server
asynSetTraceIOMask("moxa",0,4)
# Enable ASYN_TRACE_ERROR and ASYN_TRACEIO_DRIVER on octet server
asynSetTraceMask("moxa",0,9)
dbLoadTemplate("moxa1242.substitutions")
iocInit
asynReport 1
dbl

#moxa1242.substitutions
#asyn record for the underlying asyn octet port
file "$(ASYN)/db/asynRecord.db" { pattern
{P,           R,       PORT,      ADDR,   IMAX,    OMAX}
{MOXA:    OctetAsyn,    moxa,     0,      80,      80}
}
file "../../db/ai.template" { pattern
{P,         R,      PORT,               OFFSET, BITS,  EGUL,  EGUF,   PREC,   SCAN}
{MOXA:,    ADC1,   MOXA_E1242_In_Word,   0,      16,   0.,    65535.,    3,      "I/O Intr"}
{MOXA:,    ADC2,   MOXA_E1242_In_Word,   1,      16,   0.,    65535.,    3,      "I/O Intr"}
}

#ai.template
record(ai, "$(P)$(R)_AI") {
    field(DTYP,"asynInt32")
    field(INP,"@asynMask($(PORT) $(OFFSET) $(BITS))MODBUS_DATA")
    field(LINR,"LINEAR")
#    field(LINR,"NO CONVERSION")
    field(EGUL,"$(EGUL)")
    field(EGUF,"$(EGUF)")
    field(HOPR,"$(EGUF)")
    field(LOPR,"$(EGUL)")
    field(PREC,"$(PREC)")
    field(SCAN,"$(SCAN)")
}

#traceIO
2021/11/17 15:41:17.075 192.168.127.254:502 write 12

01 17 00 00 00 06 ff 04 02 08 00 08 
2021/11/17 15:41:17.083 192.168.127.254:502 read 25

01 17 00 00 00 13 ff 04 10 13 b0 40 f0 00 00 00 00 00 dc 3b 
5c 00 a0 3b a0 

#caget display
[gaozh@localhost db]$ caget MOXA:ADC1_AI
MOXA:ADC1_AI                   7
note:The actual input is 7.5V.

application environment:
EPICS 7.0.3
Asyn R4-33
Modbus R2-11

Thanks,
Gao Zhenhua

---
BSRF(Beijing Synchrotron Radiation Facility)
Email:gaozh at ihep.ac.cn






Replies:
Re: A problem with modbus reading floating point numbers Mark L Rivers via Tech-talk
Re: A problem with modbus reading floating point numbers Mark L Rivers via Tech-talk

Navigate by Date:
Prev: Re: Understanding Motor Record Torsten Bögershausen via Tech-talk
Next: ODP: Failed connection using e3-s7plc to Siemens S7-1500 Mateusz Nabywaniec via Tech-talk
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  <20212022  2023  2024 
Navigate by Thread:
Prev: Re: Understanding Motor Record Kevin Peterson via Tech-talk
Next: Re: A problem with modbus reading floating point numbers Mark L Rivers via Tech-talk
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  <20212022  2023  2024 
ANJ, 18 Nov 2021 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·