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  2022  2023  <20242025  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  <20242025 
<== Date ==> <== Thread ==>

Subject: Re: [SPAM] Re: autoConnect could not connect when reading a register by modbus relative addressing
From: Zhibang Shen via Tech-talk <tech-talk at aps.anl.gov>
To: "Mark Rivers" <rivers at cars.uchicago.edu>
Cc: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Sat, 23 Nov 2024 06:47:26 +0800 (GMT+08:00)

And sorry for mistakenly directing this issue towards relative addressing!



Best regards,

Zhibang

----------
发件人: "Mark Rivers" <rivers at cars.uchicago.edu>
发送时间: 2024-11-22 23:03:21 
收件人: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>, 沈治邦 <shenzb at ihep.ac.cn>
主题: [SPAM] Re: autoConnect could not connect when reading a register by modbus relative addressing

I think I see the problem.

  • drvModbusAsynConfigure("DM2C_1_1_In_Word", "L0", 1, 3, 24576, 2, 0, 0, "DM2C_stepper")
That creates a driver that will use function code 3 to read from register location  24576 (0x6000).  It will read 2 registers (the Modbus length argument), so it will read registers 0x6000 and 0x6001.

  • status = pC_->readReg16(44, &read_val, DEFAULT_CONTROLLER_TIMEOUT);

However, here you are telling it to read relative register 44 (0x2c) which is absolute register 0x602c. That is invalid because you only configured the driver to read 2 registers.  You need to increase the number of registers in the drvModbusAsynConfigure to include all registers you will be accessing.

Mark




From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of 沈治邦 via Tech-talk <tech-talk at aps.anl.gov>
Sent: Friday, November 22, 2024 4:31 AM
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: autoConnect could not connect when reading a register by modbus relative addressing
 

Hi,


I am encountering an issue while developing a modbus communication-based motor controller program, similar to the module motorAMCI.


I am attempting to read the values in registers with function code 3 by relative address. For instance, if I want to read the value located in 0x602C, which represents the current position of the motor. I set the starting address to 0x6000 by the command in st.cmd


drvModbusAsynConfigure("DM2C_1_1_In_Word", "L0", 1, 3, 24576, 2, 0, 0, "DM2C_stepper")


Then to read the motor position, I called the function in driver.cpp with sentence


status = pC_->readReg16(44, &read_val, DEFAULT_CONTROLLER_TIMEOUT);


24657 is 0x6000 and 44 is 0x2C, then I believe that the value at 0x602c could be accessed.


The definition of the readReg16 is the same with the method ANG1Controller::readReg16()


Consequently, I am unable to retrieve the correct register value, and an error is showed:


2024/11/22 17:57:00.751 DM2C_1_1_In_Word 2 autoConnect could not connect:


Could someone please help me figure out what might be causing this issue? 


Thank you!



Best regards,

Shen Zhibang


References:
autoConnect could not connect when reading a register by modbus relative addressing 沈治邦 via Tech-talk
Re: autoConnect could not connect when reading a register by modbus relative addressing Mark Rivers via Tech-talk

Navigate by Date:
Prev: Re: [SPAM] Re: autoConnect could not connect when reading a register by modbus relative addressing Zhibang Shen via Tech-talk
Next: RE: [SPAM] Re: autoConnect could not connect when reading a register by modbus relative addressing Mark 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  2021  2022  2023  <20242025 
Navigate by Thread:
Prev: Re: Re: Re: Re: RE: Re: autoConnect could not connect when reading a register by modbus relative addressing Zhibang Shen via Tech-talk
Next: EPICS support for SAES NEG POWER pump controller Hudson, Lee (DLSLtd,RAL,LSCI) 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  2022  2023  <20242025 
ANJ, 30 Nov 2024 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions ·
· Download · Search · IRMIS · Talk · Documents · Links · Licensing ·