Hi Marco,
Your observations here are easy to explain. There are 2 types of messages:
These are the messages from drvModbusAsyn::readInt32():
2022/07/26 18:41:19.114 drvModbusAsyn::readInt32 port NEG_EMODBUS_1_1_Rd_VTarget function=0x3, offset=00, value=0x4b0
2022/07/26 18:41:20.114 drvModbusAsyn::readInt32 port NEG_EMODBUS_1_1_Rd_VTarget function=0x3, offset=00, value=0x4b0
They are printed at this line in the driver:
https://github.com/epics-modules/modbus/blob/7b3db1275992dbebfbf47ba1ece5a99a2f051d11/modbusApp/src/drvModbusAsyn.cpp#L705
They occur at 1 Hz because that is the scan rate of the TargetVoltRead record. They do not occur if you set the record scan to Passive. The readInt32 function is just returning the value from the last poll done by the driver, it does
not actually do any Modbus I/O.
These are the messages from drvModbusAsyn::doModbusIO():
2022/07/26 18:41:19.583 drvModbusAsyn::doModbusIO port NEG_EMODBUS_1_1_Rd_VTarget READ_REGISTERS
2022/07/26 18:41:20.631 drvModbusAsyn::doModbusIO port NEG_EMODBUS_1_1_Rd_VTarget READ_REGISTERS
Those are printed at this line in the driver:
https://github.com/epics-modules/modbus/blob/7b3db1275992dbebfbf47ba1ece5a99a2f051d11/modbusApp/src/drvModbusAsyn.cpp#L2071
They also occur about every 1 second. That must be because that is the value of the macro argument $(MBUS_POLL) that you used in the following command. That is the poll_ms argument of drvModbusAsynConfigure(). I don’t think you shared
the line which sets the value of MBUS_POLL.
drvModbusAsynConfigure("NEG_EMODBUS_1_1_Rd_VTarget", "EMODBUS", ${MBUS_SL_ADDR},${MBUS_READ},0x3000,1,0,${MBUS_POLL}, "");
The driver is polling the device every MBUS_POLL ms. That is why you see those messages even when the record is Passive. There could be many records using the registers that are read by the NEG_EMODBUS_1_1_Rd_VTarget port driver. Some
might have SCAN=Passive, some might have SCAN=1 second, and some might have SCAN=I/O Intr. The poller therefore needs to always be running, since it does not know when you might change a record to SCAN=I/O Intr, and also because it is more efficient to read
a large block of registers rather than multiple individual calls.
Mark
From: Marco A. Barra Montevechi Filho <marco.filho at lnls.br>
Sent: Tuesday, July 26, 2022 1:50 PM
To: Mark Rivers <rivers at cars.uchicago.edu>; tech-talk at aps.anl.gov
Subject: Re: PINI field not working with modbus
Adding a few things i found out, if it helps in anything:
I added
> asynSetTraceMask NEG_EMODBUS_1_1_Rd_VTarget -1 9
To the end of my st.cmd file. The resulting behavior is not what i expected. When i set my record to
record(ai,
"${BL}:${H}:${EQ}:TargetVoltRead"){
field(DESC,
"Voltage set on target [V].")
field(INP,
"@asyn(NEG_EMODBUS_1_1_Rd_VTarget,0,1000)MODBUS_DATA")
}
i run the st.cmd and get constant 1-second-periodic updates such as:
iocRun: All initialization complete
#create_monitor_set("/usr/local/epics/apps/config/NEG/NEG_save_restore.req", 5, "BL=${BL}, H=${H}, EQ=${EQ}")
## Start any sequence programs
#seq sncxxx,"user=gabrielfedelHost"
epics> 2022/07/26 18:41:18.535 drvModbusAsyn::doModbusIO port NEG_EMODBUS_1_1_Rd_VTarget READ_REGISTERS
2022/07/26 18:41:18.535 drvModbusAsyn::readInt32 port NEG_EMODBUS_1_1_Rd_VTarget function=0x3, offset=00, value=0x4b0
2022/07/26 18:41:19.114 drvModbusAsyn::readInt32 port NEG_EMODBUS_1_1_Rd_VTarget function=0x3, offset=00, value=0x4b0
2022/07/26 18:41:19.583 drvModbusAsyn::doModbusIO port NEG_EMODBUS_1_1_Rd_VTarget READ_REGISTERS
2022/07/26 18:41:20.114 drvModbusAsyn::readInt32 port NEG_EMODBUS_1_1_Rd_VTarget function=0x3, offset=00, value=0x4b0
2022/07/26 18:41:20.631 drvModbusAsyn::doModbusIO port NEG_EMODBUS_1_1_Rd_VTarget READ_REGISTERS
and so on...
However, when i change my record scan to "Passive", i still get 1-second-periodic updates, but now in the format:
iocRun: All initialization complete
#create_monitor_set("/usr/local/epics/apps/config/NEG/NEG_save_restore.req", 5, "BL=${BL}, H=${H}, EQ=${EQ}")
## Start any sequence programs
#seq sncxxx,"user=gabrielfedelHost"
epics> 2022/07/26 18:44:34.525 drvModbusAsyn::doModbusIO port NEG_EMODBUS_1_1_Rd_VTarget READ_REGISTERS
2022/07/26 18:44:35.567 drvModbusAsyn::doModbusIO port NEG_EMODBUS_1_1_Rd_VTarget READ_REGISTERS
2022/07/26 18:44:36.602 drvModbusAsyn::doModbusIO port NEG_EMODBUS_1_1_Rd_VTarget READ_REGISTERS
2022/07/26 18:44:37.650 drvModbusAsyn::doModbusIO port NEG_EMODBUS_1_1_Rd_VTarget READ_REGISTERS
2022/07/26 18:44:38.697 drvModbusAsyn::doModbusIO port NEG_EMODBUS_1_1_Rd_VTarget READ_REGISTERS
even if the PINI field is in Passive. Am i supposed to receive this message every second even though there is no scan for this record? And it seems the modbus function was never actually called. Why is that?
Thanks for the help,
Marco
Of course!
it is defined in the st.cmd as:
drvModbusAsynConfigure("NEG_EMODBUS_1_1_Rd_VTarget",
"EMODBUS",
${MBUS_SL_ADDR},${MBUS_READ},0x3000,1,0,${MBUS_POLL},
"");
I append the full st.cmd file below. I also tried to define other functions PINI to YES and FNLK to
"${BL}:${H}:${EQ}:TargetVoltRead",
but to no avail.
Any suggestions on how to improve the st.cmd are also welcome.
#!/home/marco/work/cnpem_git/LCI/NEGPowerMINI/bin/linux-x86_64/NEG
< /home/marco/work/cnpem_git/LCI/NEGPowerMINI/iocBoot/iocNEG/envPaths
epicsEnvSet("EQ","NEGPowerMINI")
epicsEnvSet("IOCNAME","NEG")
# Configuração da linha de luz
< /home/marco/work/cnpem_git/LCI/NEGPowerMINI/iocBoot/iocNEG/NEG.config
epicsEnvSet("STREAM_PROTOCOL_PATH","${TOP}/db")
## Register all support components
dbLoadDatabase "dbd/NEG.dbd"
NEG_registerRecordDeviceDriver pdbbase
drvAsynIPPortConfigure("EMODBUS","10.20.41.90:502",0,0,1)
########NOT USED ANYMORE. KEEPING FOR HISTORICAL REASONS###
# Set up ASYN HYPPIE ports
# pxiCreateSM(asyn, shared memory name)
# drvasynPXIConfig(port, COM port, shared memory name, serial type)
#asynSetOption("EMODBUS", 0, "${BAUD}", "9600")
#asynSetOption("EMODBUS", 0, "bits", "8")
#asynSetOption("EMODBUS", 0, "parity", "none")
#asynSetOption("EMODBUS", 0, "stop", "1")
###############################################################################
###############################################################################
modbusInterposeConfig("EMODBUS",0,3000,0)
# drvModbusAsynConfigure(portName, => create a name
# tcpPortName, => defined before
# slaveAddress, => defined on equipament
# modbusFunction, => 3 : Read Holding Register (16-bit)
# modbusStartAddress, => adress of register
# modbusLength, => the length of data segment
# dataType, => default data type
# plcType); => Equipament name, not used
drvModbusAsynConfigure("NEG_EMODBUS_1_1_Rd_SoftwareVersion",
"EMODBUS",
${MBUS_SL_ADDR},${MBUS_READ},
0x1000, 1, 2, ${MBUS_POLL},
"");
drvModbusAsynConfigure("NEG_EMODBUS_1_1_Rd_HardwareVersion",
"EMODBUS",
${MBUS_SL_ADDR},${MBUS_READ},0x1002,1,2,${MBUS_POLL},
"");
drvModbusAsynConfigure("NEG_EMODBUS_1_1_Rd_PowerSuppIntState",
"EMODBUS",
${MBUS_SL_ADDR},${MBUS_READ},0x2000,1,0,${MBUS_POLL},
"");
drvModbusAsynConfigure("NEG_EMODBUS_1_1_Rd_LoggingState",
"EMODBUS",
${MBUS_SL_ADDR},${MBUS_READ},0x2001,1,0,${MBUS_POLL},
"");
drvModbusAsynConfigure("NEG_EMODBUS_1_1_Rd_SysUptime",
"EMODBUS",
${MBUS_SL_ADDR},${MBUS_READ},0x2002,2,0,${MBUS_POLL},
"");
drvModbusAsynConfigure("NEG_EMODBUS_1_1_Rd_InternalTemperature",
"EMODBUS",
${MBUS_SL_ADDR},${MBUS_READ},0x2004,1,0,${MBUS_POLL},
"");
drvModbusAsynConfigure("NEG_EMODBUS_1_1_Rd_PumpTemperature",
"EMODBUS",
${MBUS_SL_ADDR},${MBUS_READ},0x2005,1,0,${MBUS_POLL},
"");
drvModbusAsynConfigure("NEG_EMODBUS_1_1_Rd_OutVolt",
"EMODBUS",
${MBUS_SL_ADDR},${MBUS_READ},0x2006,1,0,${MBUS_POLL},
"");
drvModbusAsynConfigure("NEG_EMODBUS_1_1_Rd_OutCurr",
"EMODBUS",
${MBUS_SL_ADDR},${MBUS_READ},0x2007,1,0,${MBUS_POLL},
"");
drvModbusAsynConfigure("NEG_EMODBUS_1_1_Rd_TimeRunning",
"EMODBUS",
${MBUS_SL_ADDR},${MBUS_READ},0x2008,2,0,${MBUS_POLL},
"");
drvModbusAsynConfigure("NEG_EMODBUS_1_1_Rd_Alarms",
"EMODBUS",
${MBUS_SL_ADDR},${MBUS_READ},0x200A,2,0,${MBUS_POLL},
"");
drvModbusAsynConfigure("NEG_EMODBUS_1_1_Rd_TempAlarms",
"EMODBUS",
${MBUS_SL_ADDR},${MBUS_READ},0x200C,2,0,${MBUS_POLL},
"");
drvModbusAsynConfigure("NEG_EMODBUS_1_1_Rd_WorkTime",
"EMODBUS",
${MBUS_SL_ADDR},${MBUS_READ},0x200E,2,0,${MBUS_POLL},
"");
drvModbusAsynConfigure("NEG_EMODBUS_1_1_Rd_VTarget",
"EMODBUS",
${MBUS_SL_ADDR},${MBUS_READ},0x3000,1,0,${MBUS_POLL},
"");
drvModbusAsynConfigure("NEG_EMODBUS_1_1_Wr_VTarget",
"EMODBUS",
${MBUS_SL_ADDR},${MBUS_WRITE},0x3000,1,0,${MBUS_POLL},
"");
dbLoadRecords("db/dbNEG.db",
"BL=${BL}, H=${H},
EQ=${EQ}")
Thanks for the help 🙂
Marco
Can you show us how the NEG_EMODBUS_1_1_Rd_VTarget port is configured?
Hello all.
I have an analog in record for reading a modbus register from a device. The record is defined as follows:
record(ai,
"${BL}:${H}:${EQ}:TargetVoltRead"){
field(DESC,
"Voltage set on target [V].")
field(INP,
"@asyn(NEG_EMODBUS_1_1_Rd_VTarget,0,1000)MODBUS_DATA")
}
Which reads fine. However, if i set the PINI field to YES and the scan to passive:
record(ai,
"${BL}:${H}:${EQ}:TargetVoltRead"){
field(DESC,
"Voltage set on target [V].")
field(INP,
"@asyn(NEG_EMODBUS_1_1_Rd_VTarget,0,1000)MODBUS_DATA")
}
i get only 0 as value when cagetting the PV. Am i doing something wrong?
Thanks in advance.
Marco
Aviso Legal: Esta mensagem e seus anexos podem conter informações confidenciais e/ou de uso restrito. Observe atentamente seu conteúdo e considere eventual consulta ao remetente antes
de copiá-la, divulgá-la ou distribuí-la. Se você recebeu esta mensagem por engano, por favor avise o remetente e apague-a imediatamente.
Disclaimer: This email and its attachments may contain confidential and/or privileged information. Observe its content carefully and consider possible querying to the sender before
copying, disclosing or distributing it. If you have received this email by mistake, please notify the sender and delete it immediately.
|