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  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: AsynInt32 device support and mbbo records
From: Mark Rivers <[email protected]>
To: "'Florian Feldbauer'" <[email protected]>
Cc: EPICS Tech Talk <[email protected]>
Date: Fri, 15 Feb 2013 16:10:56 +0000
Hi Florian,

OK, I understand.  What you are doing sounds like a reasonable way to handle it.

Since this device is a motor driver/controller, you might be interested in the new "Model 3" support for motors in the synApps "motor" application.

In motorApp/motorSrc there are C++ base classes, asynMotorController and asynMotorAxis.  These are based on asynPortDriver.  To write a new driver you just need to implement a few methods from these base classes, e.g. asynMotorAxis::move(), asynMotorAxis::poll(), etc.  There are example Model 3 drivers for the Newport XPS (motorApp/NewportSrc/XPSController.cpp, XPSAxis.cpp) and for the ACS MCB-4B (motorApp/AcsSrc/MCB4BDriver.cpp).  It is easy to support additional parameters in addition to those in the motor record, and the XPS has an example of that for the "Jerk" parameter.

This is the header file for MCBDriver:

**************************
#include "asynMotorController.h"
#include "asynMotorAxis.h"

#define MAX_MCB4B_AXES 4

// No controller-specific parameters yet
#define NUM_MCB4B_PARAMS 0  

class MCB4BAxis : public asynMotorAxis
{
public:
  /* These are the methods we override from the base class */
  MCB4BAxis(class MCB4BController *pC, int axis);
  void report(FILE *fp, int level);
  asynStatus move(double position, int relative, double min_velocity, double max_velocity, double acceleration);
  asynStatus moveVelocity(double min_velocity, double max_velocity, double acceleration);
  asynStatus home(double min_velocity, double max_velocity, double acceleration, int forwards);
  asynStatus stop(double acceleration);
  asynStatus poll(bool *moving);
  asynStatus setPosition(double position);
  asynStatus setClosedLoop(bool closedLoop);

private:
  MCB4BController *pC_;          /**< Pointer to the asynMotorController to which this axis belongs.
                                   *   Abbreviated because it is used very frequently */
  asynStatus sendAccelAndVelocity(double accel, double velocity);
  
friend class MCB4BController;
};

class MCB4BController : public asynMotorController {
public:
  MCB4BController(const char *portName, const char *MCB4BPortName, int numAxes, double movingPollPeriod, double idlePollPeriod);

  void report(FILE *fp, int level);
  MCB4BAxis* getAxis(asynUser *pasynUser);
  MCB4BAxis* getAxis(int axisNo);

friend class MCB4BAxis;
};
**************************

Mark


-----Original Message-----
From: Florian Feldbauer [mailto:[email protected]] 
Sent: Friday, February 15, 2013 8:45 AM
To: Mark Rivers
Cc: EPICS Tech Talk
Subject: Re: AsynInt32 device support and mbbo records

Hey Marc,

the TMCM142_SAP in my example below is exactly what you suggest, only to 
code a different value.
The motor driver needs 3 parameters:
1) Byte 0 is the command number which codes things like "Move to 
position" or in the example below "Set axis parameter" (here I'm using 
pasynUser->reason).
2) Byte 1 Type/Parameter number. Some commands like "Set Axis Parameter" 
use this field to determine
     which axis parameter to read/write. In my opinion this is also a 
good candidate for the addr parameter.
3) Motor/Bank number. Axis related commands use this to distinguish 
between multiple axes, but our device
     doesn't support this.
    From the hard- and firmware of the TMCM142 this parameter is 
currently only used by 2 commands,
    Set/Get global parameter, and only to access "user defined" global 
parameters.

Of course one could use the addr to code the 3rd parameter and use 
reason to code command and parameter numbers, but then you would end up 
with something around 500 strings or so...

Or is there any other way to pass a third paramter from the IOC to an 
asynPortDriver?
I also thought about using the timeout, but that would be too confusing 
for others to use...

Best regards,
Florian

Am 15.02.2013 15:25, schrieb Mark Rivers:
> Hi Florian,
>
> In general I would recommend using pasynUser->reason for the "parameter number" and using the addr parameter for the "motor number".  That is more in the spirit of how they are intended to be used, and allows your driver to work with the next version of your motor controller which might support multiple axes.
>
> Your db file would then look like:
>
> record(ao, "$(P)$(R)Velocity) {
>    field(DTYP, "asynInt32")
>    field(OUT, "($(PORT),$(ADDR))VELOCITY")
> }
>
> ADDR is the motor number (0 for the current controller) and VELOCITY is the asynDrvUser parameter.
>
> Your driver would implement the asynDrvUser interface to convert the string "VELOCITY" into the appropriate "parameter number", which it places in pasynUser->reason.
>
> Mark
>
> ________________________________________
> From: [email protected] [[email protected]] on behalf of Florian Feldbauer [[email protected]]
> Sent: Friday, February 15, 2013 3:14 AM
> To: EPICS Tech Talk
> Subject: AsynInt32 device support and mbbo records
>
> Hey,
>
> I have written an AsynPortDriver for the TMCM142 1 axis stepper
> driver/controller
> The motor driver is connected via CAN bus and expects a message with 7
> bytes of data:
> byte 0: command number
> byte 1: parameter number (I'm using the addr parameter from the asyn
> interface)
> byte 2: motor number (only one motor can be connected to the driver so
> it is always 0)
> byte 3-6: data (32 bit signed int)
>
> For setting the microstep resolution of the motor driver the data has to
> be a number between
> 0 and 11, each coding a different resoultion.
> I wanted to use a mbbo record, which looks like this:
>
> record( mbbo, "PANDA:$(subsys):MOTOR:$(SECTOR):SAP:USTEPRESOLUTION" ) {
>     field( DTYP, "asynUInt32" )
>     field( OUT,  "@asyn($(BUS),27,1)TMCM142_SAP" )
>
>     field( ZRST, "2048 micro steps" )
>     field( ONST, "1024 micro steps" )
>     field( TWST, "512 micro steps" )
>     field( THST, "256 micro steps" )
>     field( FRST, "128 micro steps" )
>     field( FVST, "64 micro steps" )
>     field( SXST, "32 micro steps" )
>     field( SVST, "16 micro steps" )
>     field( EIST, "8 micro steps" )
>     field( NIST, "4 micro steps" )
>     field( TEST, "2 micro steps" )
>     field( ELST, "1 micro steps" )
> }
>
> Unfortunately, the value inside my writeInt32 function from the
> asynPortDriver is always 0.
> Do I have to set the ZRVL,...,ELVL fields for asynInt32? Or do I need
> another asyn interface for
> this record?
>
> Best regards,
> Florian
>
> --
> ----------------------------------------
> | Dr. Florian Feldbauer                |
> |                                      |
> | Helmholtz-Institut Mainz /           |
> | Johannes Gutenberg-Universität Mainz |
> | Johann-Joachim-Becher-Weg 45         |
> | D-55128 Mainz                        |
> |                                      |
> | Office: 01/217                       |
> | Phone:  (+49)6131 / 39-25829         |
> ----------------------------------------
>



References:
AsynInt32 device support and mbbo records Florian Feldbauer
RE: AsynInt32 device support and mbbo records Mark Rivers
Re: AsynInt32 device support and mbbo records Florian Feldbauer

Navigate by Date:
Prev: Re: record info field in which epics version? Andrew Johnson
Next: Has anyone converted AllenBradley (scanner) driver and device support to EPICS OSI? Luchini, Kristi L.
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: AsynInt32 device support and mbbo records Florian Feldbauer
Next: New version of LabVIEW-EPICS-interface CA Lab 1.4.1.0 Carsten Winkler
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 20 Apr 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·