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  2021  <20222023  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  2021  <20222023  2024 
<== Date ==> <== Thread ==>

Subject: Re: PINI field not working with modbus
From: Mark Rivers via Tech-talk <tech-talk at aps.anl.gov>
To: "Marco A. Barra Montevechi Filho" <marco.filho at lnls.br>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Wed, 27 Jul 2022 11:52:01 +0000
Hi Marco,

I think I understand why you are not seeing the correct value when you use PINI=YES and SCAN=Passive.  The problem is a race condition.

As I said in a previous message, it appears that you have set the MBUS_POLL macro to 1000, which means the poller for that Modbus driver is running every 1000 ms (1 second).  The poller waits for this delay at the beginning of the poll loop.  The poller thread is started when your startup script calls drvModbusAsynConfigure().  When the record processes during iocInit() because PINI=YES it just gets the most recent value from the poller.

However, in your case because you have a slow polling rate of 1 second it is likely that the poller has not yet done the first poll when the record is processed during iocInit, so there is no value to use.

I believe you can fix the problem by adding this line to your startup script just before iocInit()

epicsThreadSleep(1.0)

Mark



From: Mark Rivers
Sent: Tuesday, July 26, 2022 6:37 PM
To: Marco A. Barra Montevechi Filho <marco.filho at lnls.br>; tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: RE: PINI field not working with modbus
 

Hi Marco,

 

Please start the IOC with TargetVoltRead.SCAN=Passive and .PINI=YES.  Set the asynTraceMask for the NEG_EMODBUS_1_1_Rd_VTarget driver to 9, but do that immediately after you create the driver, not at the end of the startup script.  Then when the startup is complete type the following command and send the output.  Also send the output of all driver trace messages that occur before you type dbpf.

 

dbpf TargetVoltRead 2

 

Of course you need to add all of the prefixes for TargetVoltRead.

 

Mark

 

From: Marco A. Barra Montevechi Filho <marco.filho at lnls.br>
Sent: Tuesday, July 26, 2022 9:10 AM
To: Mark Rivers <rivers at cars.uchicago.edu>; tech-talk at aps.anl.gov
Subject: Re: PINI field not working with modbus

 

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("BL","LCI")

epicsEnvSet("H","X")

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")

 

cd ${TOP}

 

## 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")                      

 

###############################################################################

###############################################################################

 

## Configure

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

#                       pollMsec,

#                       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}, "");

 

## Load record instances

dbLoadRecords("db/dbNEG.db", "BL=${BL}, H=${H}, EQ=${EQ}")

 

cd ${TOP}/iocBoot/${IOC}

iocInit


Thanks for the help
🙂

Marco


From: Mark Rivers <rivers at cars.uchicago.edu>
Sent: 26 July 2022 10:33
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>; Marco A. Barra Montevechi Filho <marco.filho at lnls.br>
Subject: Re: PINI field not working with modbus

 

Hi Marco,

 

Can you show us how the NEG_EMODBUS_1_1_Rd_VTarget port is configured?

 

Mark

 


From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Marco A. Barra Montevechi Filho via Tech-talk <tech-talk at aps.anl.gov>
Sent: Tuesday, July 26, 2022 7:45 AM
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: PINI field not working with modbus

 

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(DTYP, "asynInt32")

    field(EGU, "V")

    field(ASLO, 0.01)

    field(INP, "@asyn(NEG_EMODBUS_1_1_Rd_VTarget,0,1000)MODBUS_DATA")

    field(SCAN, "1 second")

}


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(DTYP, "asynInt32")

    field(EGU, "V")

    field(ASLO, 0.01)

    field(INP, "@asyn(NEG_EMODBUS_1_1_Rd_VTarget,0,1000)MODBUS_DATA")

    field(SCAN, "Passive")

    field(PINI, "YES")

}



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.


Replies:
Re: PINI field not working with modbus Marco A. Barra Montevechi Filho via Tech-talk
Re: PINI field not working with modbus bob dalesio via Tech-talk
References:
PINI field not working with modbus Marco A. Barra Montevechi Filho via Tech-talk
Re: PINI field not working with modbus Mark Rivers via Tech-talk
Re: PINI field not working with modbus Marco A. Barra Montevechi Filho via Tech-talk
RE: PINI field not working with modbus Mark Rivers via Tech-talk

Navigate by Date:
Prev: PVA and Docker on Mac Juan F. Esteban Müller via Tech-talk
Next: Re: PINI field not working with modbus Marco A. Barra Montevechi Filho 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  2021  <20222023  2024 
Navigate by Thread:
Prev: RE: PINI field not working with modbus Mark Rivers via Tech-talk
Next: Re: PINI field not working with modbus Marco A. Barra Montevechi Filho 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  2021  <20222023  2024 
ANJ, 14 Sep 2022 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·