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  <20232024  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  <20232024 
<== Date ==> <== Thread ==>

Subject: =?gb18030?b?u9i4tKO6UkU6IEEgcXVlc3Rpb24gb24gbW9kYnVz?=
From: =?gb18030?b?QW1iZXI=?= via Tech-talk <tech-talk at aps.anl.gov>
To: "=?gb18030?b?TWFyayBSaXZlcnM=?=" <rivers at cars.uchicago.edu>, "=?gb18030?b?dGVjaC10YWxr?=" <tech-talk at aps.anl.gov>, "=?gb18030?b?vfG35y7PuNPq?=" <48960501 at qq.com>
Date: Thu, 13 Jul 2023 11:31:14 +0800
Hello Mark,

    It works well. 
    Thank you so much. Your help makes me understand more about this module.

Best reguards,
Kevin

------------------ 原始邮件 ------------------
发件人: "Mark Rivers" <rivers at cars.uchicago.edu>;
发送时间: 2023年7月11日(星期二) 晚上11:48
收件人: "Amber"<279762081 at qq.com>;"tech-talk"<tech-talk at aps.anl.gov>;
主题: RE: A question on modbus

Hi Kevin,

 

  • There is another command to open the device, which should write " \x01 \x05 \x00 \x00 \xFF \x00  \x8C \x3A" to the device.

 

That is a standard Modbus command.  It uses function code 5 (write single coil) using data="" to address=0.  The value 0xff00 is what the Modbus standard requires to be written to a single coil for the bit value 1.

You need to create another driver with this command:

 

drvModbusAsynConfigure("V1","Init", 1,5,0,1,0,0, "Init")

 

You can create a template file called modbusInit.template in the same directory with your startup script.

 

record(bo,"$(P)$(R)") {

    field(DTYP,"asynUInt32Digital")

    field(OUT,"@asynMask($(PORT) 0 0x1)")

    field(VAL, “1”)

    field(PINI, “YES”)

}

 

That record will process during iocInit (because PINI=YES).  It will write the value 0xff00 to address 0 using function code 5.

 

Load that file in your startup script with the command

 

dbLoadRecords(modbusInit.template”, “P=power:,R=init,PORT=V1”)

 

Mark

 

 

From: Tech-talk <tech-talk-bounces at aps.anl.gov> On Behalf Of Amber via Tech-talk
Sent: Tuesday, July 11, 2023 3:04 AM
To: tech-talk <tech-talk at aps.anl.gov>
Subject: A question on modbus

 

Hello everyone,

 

I am using a device with Modbus-RTU protocol. The communication data is transmitted in hexadecimal words.

I want to use the modbus module in epics to solve this problelm.

 

When reading device data, the follwing sentence is used in the .cmd file:

 

drvModbusAsynConfigure("V1","Power", 1,3,0,1,0,1000, "Power")

 

and in the substitution file:

 

file "../../db/ai.template" { pattern

{P,         R,      PORT,               OFFSET, BITS,  EGUL,  EGUF,   PREC,   SCAN}

{power:,    V_read,   V1,   0,      16,    0.,   655.35,     2,      "I/O Intr"}

}

 

There is another command to open the device, which should write " \x01 \x05 \x00 \x00 \xFF \x00  \x8C \x3A" to the device.

Command

01

05

00

00

FF

00

8C

3A

Address

Function code

Register address 0

Data 0

CRC

Reply

Be same with command

 

After reading all the examples I still don't know how to send this command with modbus module correctly. I think I didn't understand them clearly.

Would you like to give me some advice?  Is it suitable to use modbus module?  How to realize it?

Thank you very much.

 

with my best wishes,

Kevin

 

 


References:
A question on modbus Amber via Tech-talk
RE: A question on modbus Mark Rivers via Tech-talk

Navigate by Date:
Prev: Re: Suspended thread Andrew Johnson via Tech-talk
Next: Xspress3 INP error lynn 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  <20232024 
Navigate by Thread:
Prev: RE: A question on modbus Mark Rivers via Tech-talk
Next: mrfioc2/devlib2 PCI device resource file error Steve Kinder - STFC UKRI 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  <20232024 
ANJ, 13 Jul 2023 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·