Experimental Physics and Industrial Control System
Hi everyone,
I have started to use Modbus (Asyn) driver (CARS:Modbus, Mark Rivers) and so far it looks great. I’ve gone through instructions under http://cars9.uchicago.edu/software/epics/modbusDoc.html and successfully got comms going.
Now that I’m starting to work further and actually create records I realised that I have a bit of a problem.
What I’m planning to use the driver for is only WRITING values from EPICS to PLC (Siemens S7-1500 in case you’re interested).
The values are only written when IOC changes them (for example user pushes the button on GUI), i.e. asynchronously. Therefore I want to use Modbus function 6 (write single register).
As per instructions I added the following to my command file to create modbus port:
drvModbusAsynConfigure("modbuswrite", $(PLCNAME), 0, 6, 0, 123, 0, 0, "S7-1500")
where 6 is the modbus function, 0 is memory offset, and 123 is the number of words.
And this is when I realised I have an issue. In this set up I have to specify offset and length. These parameters make perfect sense for Modbus function 3 (where the driver will poll all these registers), but (as far as I know Modbus protocol) for Modbus function 6 they are actually not required at all. The modbus message looks like:
06 0001 0003 XXXX(CRC)
06 - function
0001 - modbus address to write to
0003 - value to write
Basically Modbus allows writing to ANY offset on the fly. So what I’m trying to understand is why does the driver force me to specify offset and length for FC03?
The reason it is a problem for me is that I will have a lot more than 123 words to write, therefore currently it looks like I will have to repeat drvModbusAsynConfigure quite a few times, have multiple Modbus port names and then write my records accordingly (recalculating offsets for every next port). This is going to be very painful.
I was trying to be sneaky and use:
drvModbusAsynConfigure("modbuswrite", port1, 0, 6, 0, 0, 0, 0, "S7-1500")
hoping the driver has allowed for that, the response was
drvModbusAsyn::drvModbusConfigure, port modbuswrite memory length<=0
I also tried
drvModbusAsynConfigure("modbuswrite", port1, 0, 6, 0, 124, 0, 0, "S7-1500")
the response was
drvModbusAsyn::drvModbusConfigure, port modbuswrite memory length=124 too large, max=123
So, clearly, there are some checks in driver code there.
So, what I’m trying to understand is why does the driver require offset and length for FC06? Is it really necessary, etc.?
I was almost thinking that something like:
drvModbusAsynConfigure("modbuswrite", port1, 0, 6, 0, 0, 0, 0, "S7-1500")
can just create the connection and then driver would form Modbus message based on the offset from the record.
I sincerely hope I haven’t made this too confusing and it makes sense. I’d love to get community's thoughts on this.
Thank you in advance!
Regards,
Nick Levchenko
Control Systems Engineer
Integrated Control System Division
European Spallation Source ERIC
P.O Box 176, SE-221 00 Lund, Sweden
Visiting address: Tunavägen 24, Lund
Mobile: +46 721 79 23 64
Phone: +46 46 888 33 64
E-mail: [email protected]
www.esss.se
- Replies:
- RE: CARS:Modbus - function 06 (write single register) issue Mark Rivers
- Navigate by Date:
- Prev:
Re: Problem with procServ on RHEL6 Ralph Lange
- Next:
RE: CARS:Modbus - function 06 (write single register) issue Mark Rivers
- 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
- Navigate by Thread:
- Prev:
RE: drvAsynIPPort, asynOctetSyncIO and multithreading Mark Rivers
- Next:
RE: CARS:Modbus - function 06 (write single register) issue Mark Rivers
- 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