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 2025 | 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 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: Re: A problem with modbus reading floating point numbers |
From: | 高振华 via Tech-talk <tech-talk at aps.anl.gov> |
To: | "mark l rivers" <rivers at cars.uchicago.edu> |
Cc: | "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov> |
Date: | Thu, 18 Nov 2021 16:29:14 +0800 (GMT+08:00) |
Hi Mark,
Now rval=7 instead of 49169 for 7.5V.
note:I used the AI_scaledValue command to read moxa E1242 instead of the raw AI_rawValue command.
Instead of reading the original 2-byte integer, the 4-byte float value converted to the scaled value is read .
-----原始邮件-----
发件人:"Mark L Rivers" <rivers at cars.uchicago.edu>
发送时间:2021-11-17 22:22:52 (星期三)
收件人: "高振华" <gaozh at ihep.ac.cn>
抄送: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
主题: Re: A problem with modbus reading floating point numbers
Hi Gao,
I think I see the problem:
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"}
}
You have set EGUF to 65535. If you do that then the ai record will do a linear conversion, but the output values in EGU units will be the same as the input values in RAW units. You should set the EGUF to be the maximum value of the ADC in the engineering units you want to use. For example, if it is a 0 to 10V ADC then you can set EGUF=10 and then the ai record will be in the units of volts. If it is -10V to 10V ADC you should set EGUL=-10.
Mark
From: 高振华 <gaozh at ihep.ac.cn>
Sent: Wednesday, November 17, 2021 2:36 AM
To: Mark L Rivers <rivers at cars.uchicago.edu>
Cc: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: A problem with modbus reading floating point numbersHi 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