Hi Mark,
This is how I understand what you wrote.
My motor driver does not know anything about the modbus driver.
The connection between my motor driver and the modbus driver is made in
the IOC, where both drivers are used. I don't understand how calling
pasynInt32SyncIO-read(...) will invoke anything in the modbus driver.
There must be some connection via asyn here. Is that correct and if so,
how is the connection made? If not then how is it done?
Can you also elaborate a bit more about the MODBUS_DATA command. As far
as I can think on this project, all I need to be able to do is to read
from a register and write to a register. I don't need readwrite
function. Also, I am not sure what is the drvInfo field that you
mention. I feel that I should know and yet nothing comes to mind.
Thanks for helping,
Zen
On 05/18/13 16:38, Mark Rivers wrote:
Hi Zen,
Actually I don't think I need to expose any data structures in the Modbus driver. Your motor driver should be able to communicate with the Modbus driver using only the following information:
- The name of the Modbus port
- The asyn "address" field, which is the offset of the register relative to the first register address for that port
- The asyn interface (e.g. asynInt32, etc.)
- The asyn drvInfo field, which you may not need if the default MODBUS_DATA is sufficient
With the above information your motor driver will probably do something like the following:
pasynInt32SyncIO->connect(port, addr, &pasynUser, drvInfo); // In your driver's constructor
pasynInt32SyncIO->write(pasynUser, value, timeout); // In your driver's I/O routines
pasynInt32SyncIO->read(pasynUser, &value, timeout);
With the above scheme you will need a number of pasynUser structures (one for each port/addr pair). You could also use the pasynInt32SyncIO->writeOnce and readOnce methods, which are less efficient but don't require storing multiple pasynUser structures.
Mark
________________________________________
From: Zenon Szalata [[email protected]]
Sent: Saturday, May 18, 2013 1:55 PM
To: Mark Rivers
Cc: [email protected]
Subject: Re: More on Modbus
Hi Mark,
This is just a short follow up on my last email.
After looking at my Pico driver implementation and digging a bit more
into drvModbusAsyn.c file, it seems to me that you might need to expose
the data structures that are created for each port and then I should be
able to call pasynOctetSyncIO routines as needed. Is that approximately
what you had in mind?
Thanks for helping me with this,
Zen
P.S. At this point I have a reasonably well working implementation, all
in a collection of records in a database, about 1000 of them. The only
problem is that one has to pay attention to reads and writes to the
hidden registers as these sometimes go wrong.
With that said, some people here are getting somewhat excited, because
Beckhoff offers a very inexpensive hardware solution compared to XPS.
And the XPS controllers are not problem free.
On 05/18/13 08:45, Mark Rivers wrote:
Hi Zen,
Hi Zen,
I think I see a solution that should allow you to stop the poller thread when you want to access the same Modbus addresses in another thread. The solution is to have the poller thread take the asyn port driver lock (pasynManager->lockPort()) for its operation loop. Your other thread can then also lock the port, which will block the poller thread while you do a sequence of write and read operations. This will work fine if your motor code is written as a C/C++ driver. But if it is just a collection of records in a database I'm not sure how to do it.
Since the problematic Beckhoff devices are motor controllers, you could write a real driver in C++ using the asynMotorController and asynMotorAxis base classes, which are themselves derived from asynPortDriver. There are quite a few examples of relatively simple drivers using that model in the synApps motor module now. Such drivers are normally used with the synApps motor record, but this is NOT required. Since the driver uses standard asyn interfaces it is possible to just use standard records to move the motor, control the velocity, read the status, etc. You lose the "state machine" aspect of the motor record (backlash correction, retries, etc.). But for a simple controller the standard records may be fine. In your C++ driver you will then call lockPort() for the underlying Modbus driver when needed.
I can make the appropriate minor change to the Modbus driver for you to test if this seems like a reasonable approach to you.
Mark
________________________________________
From: Zenon Szalata [[email protected]]
Sent: Friday, May 17, 2013 4:39 PM
To: Mark Rivers; [email protected]
Subject: More on Modbus
Hi Mark,
Some of what I wrote in my previous email is no longer relevant. I have
since played with controlling the polling timeout to reduce the
interference between the reads done in the polling thread and the
write-reads that I am attempting from my rather complicated set of EPICS
records. I have reached a conclusion, hopefully correct, that what I
really need is a Modbus device driver that would give me a full control
when and in which order register read and write operations are performed.
Is this possible with the existing Modbus support module?
I am thinking that it would be very nice to have a C++ base class like
asynPortDriver, or perhaps a subclass of asynPortDriver, which would
implement all the details of Modbus protocol and basic IO.
Have you thought of writing something like that?
Do you think such a class would be useful?
Beckhoff are the only modbus devices that I have written software for
and the stepper motor controllers are the only devices for which I find
your Modbus support module too limited. For that reason I am a bit
hesitant to start a new project, that is to write the C++ class. Could
you offer your insight on this?
Thanks in advance,
Zen
- References:
- More on Modbus Zenon Szalata
- RE: More on Modbus Mark Rivers
- Re: More on Modbus Zenon Szalata
- RE: More on Modbus Mark Rivers
- Navigate by Date:
- Prev:
RE: More on Modbus Mark Rivers
- Next:
PowerPC VME boards with RTEMS Jiro Fujita
- 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: More on Modbus Mark Rivers
- Next:
Re: More on Modbus Zenon Szalata
- 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
|