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