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

Subject: RE: How to support a new stepper motor controller?
From: Mark Rivers <rivers@cars.uchicago.edu>
To: Paramveer Jain <paramveerjain89@gmail.com>, Rod Nussbaumer <bomr@triumf.ca>
Cc: "tech-talk@aps.anl.gov" <tech-talk@aps.anl.gov>
Date: Thu, 9 Feb 2017 17:49:41 +0000
Hi Paramveer,

> 1 >  what are controller specific parameters. ? How can I get my controller specific Parameters ?

You only need to worry about these if your controller has some features that you want to use that are not included in the standard set of features that the motor records supports.  Let's assume you don't have any such extra features to support at least to start with.

>  sprintf(pC_->outString_, "%s STX P1 %f %f CR", axisName_, maxVelocity/pulsesPerUnit_, position/pulsesPerUnit_);
> How will I assign value for maxVelocity and position ???

The maxVelocity and position will be passed to your driver from the values in the motor record.  You will configure those values in the template file that you load in your startup script.

Here is an example in the motor/iocBoot/iocWithAsyn directory:

corvette:motor/iocBoot/iocWithAsyn>more motor.substitutions.mcb4b
file "$(TOP)/db/basic_asyn_motor.db"
{
pattern
{P,    N,   M,         DTYP,     PORT, ADDR,  DESC,     EGU,   DIR,   VELO,  VBAS, ACCL, BDST, BVEL, BACC,    MRES, PREC,   DHLM, DLLM, INIT}
{IOC:, 1, "m$(N)", "asynMotor",  MCB4B1,  0, "Bottom",   mm,   Pos,    2.0,   0.1,  .2,    0,    1,   .2,    -.001,    3,   16,    0,    ""}
{IOC:, 2, "m$(N)", "asynMotor",  MCB4B1,  1, "Top",      mm,   Pos,    2.0,   0.1,  .2,    0,    1,   .2,    -.001,    3,   16,    0,    ""}
{IOC:, 3, "m$(N)", "asynMotor",  MCB4B1,  2, "Inboard",  mm,   Pos,    2.0,   0.1,  .2,    0,    1,   .2,    -.001,    3,   16,    0,    ""}
{IOC:, 4, "m$(N)", "asynMotor",  MCB4B1,  3, "Outboard", mm,   Pos,    2.0,   0.1,  .2,    0,    1,   .2,    -.001,    3,   16,    0,    ""}

In this case VELO=2.0 and MRES=-0.001 so the value that will be passed to your driver would be VELO*fabs(MRES) = 2000 steps/second.  The position will be based on where you tell the motor to go by writing into the VAL field of the motor.  That value is in engineering units.  The motor record will convert it to steps using the DIR, OFF and MRES fields.

Note that your format string ends with CR.  That is probably not correct, it should probably be the Carriage Return character, which is written as \r in a format string.

> 3> which method in .cpp is responsible for communication between database(.db files) and driver. ?

That is handled by motor/motorApp/motorSrc/devMotorAsyn.c,  It is a generic device support file that works with all model 3 drivers, so you don't need to worry about it.

> 4> What is importance of following code.?
> asynStatus PXController::readBinaryIO()

That is code that is specific to the ACR controller which is has programmable digital I/O lines.  It is not needed in your driver and should be removed.

I have attached modified versions of your driver where I removed the ACR specific parameters and functions for binary I/O.

Note that you need to implement the poll() and stop() functions for your axis class or the motor record won't work correctly.

Mark






________________________________
From: tech-talk-bounces@aps.anl.gov [tech-talk-bounces@aps.anl.gov] on behalf of Paramveer Jain [paramveerjain89@gmail.com]
Sent: Thursday, February 09, 2017 1:16 AM
To: Rod Nussbaumer
Cc: tech-talk@aps.anl.gov
Subject: Re: How to support a new stepper motor controller?

Hello all,
            I have gone through the documentation you suggested. After understanding most of the coding I am here with some doubts.

1 >  what are controller specific parameters. ? How can I get my controller specific Parameters ?

2> in method
 asynStatus PXAxis::move(double position, int relative, double minVelocity, double maxVelocity, double acceleration)
{
  asynStatus status;
  // static const char *functionName = "moveAxis";

  sprintf(pC_->outString_, "%s STX P1 %f %f CR", axisName_, maxVelocity/pulsesPerUnit_, position/pulsesPerUnit_);
  status = pC_->writeController();
  return status;
}

How will I assign value for maxVelocity and position ???


3> which method in .cpp is responsible for communication between database(.db files) and driver. ?

4> What is importance of following code.?


asynStatus PXController::readBinaryIO()
{
  asynStatus status;

  // Read the binary inputs
  sprintf(outString_, "?P%d", binaryInReg_);
  status = writeReadController();
  if (!status) {
    binaryIn_ = atoi(inString_);
    setUIntDigitalParam(0, PXBinaryIn_, binaryIn_, 0xFFFFFFFF);
  }

  // Read the binary outputs
  sprintf(outString_, "?P%d", binaryOutReg_);
  status = writeReadController();
  if (!status) {
    binaryOutRBV_  = atoi(inString_);
    setUIntDigitalParam(0, PXBinaryOutRBV_, binaryOutRBV_, 0xFFFFFFFF);
  }
  callParamCallbacks(0);
  return status;
}



I am attaching my .cpp and .h files.

thank you in advance.

On Tue, Feb 7, 2017 at 11:55 PM, Rod Nussbaumer <bomr@triumf.ca<mailto:bomr@triumf.ca>> wrote:
We've gone that route (streamDevice) for the relatively pedestrian requirements for the Galil motor controllers we use. No coordinated motion, or programmed movements; just discrete single axis motion with switches at each limit. The polling generates a lot of traffic, so we put the controllers on dedicated LANs. We did attempt to provide functionality that is similar to the motor record functions that we previously used in older applications with OMS VME motor controllers, by using logic in EPICS base records.

So far, we've only encountered a few hiccups and were able to address them easily.

Rod Nussbaumer
TRIUMF
Vancouver, Canada



On 02/07/2017 09:04 AM, Kevin Peterson wrote:
In general, the recommendation to write a model 3 driver is a good one.
Under some circumstances, however, that is far from the easiest option.

If the controller doesn't have a status command that allows queries of
the moving state, it can be awkward and inefficient to make the model 3
driver work well with the motor record, which expects the driver to
reliably set the done bit of the MSTA field.

If the goal is EPICS support and the motor record is not required, I
have found that StreamDevice support
(http://epics.web.psi.ch/software/streamdevice/) is a much better fit
and significantly easier to write.

Kevin

On 2/7/17 3:53 AM, Ralph Lange wrote:
Dear motion specialists,

I am writing on behalf of Paramveer Jain (in CC) who has contacted me
with this issue, but as I have never done motion control integration
with EPICS, I'd rather throw this ball up than send him into the wrong
direction.

He is being tasked with developing EPICS support for a locally developed
motor controller.

The hardware setup can be summarized as:

   * Moxa embedded TCP-to-serial converter (NE4110S)
   * Serial connection (RS-232)
   * Homemade motor controller (based on an AT89C52)
   * Ark Motion AMS 3630 stepper motor driver.

The controller software talks ASCII in command/response fashion, e.g.:

   * Read position (rotary encoder)
     Command: STX U<CR>
     Response: STX U pppppp<CR>
     pppppp = six digit hex (divide by 640 to get millimeter)
   * Go to position (rotary encoder)
     Command: STX P1 sss pppppp<CR>
     Response: \06 (ACK)
     sss = three digit hex (speed in mm/s multiplied by 240)
     pppppp = six digit hex (millimeter multiplied by 640)
   * ...

What's the best/easiest way to do this? What are the caveats?
Is there a tutorial he could follow?
Is there existing support for another motor that he could start from?

Thanks a lot for your help!
~Ralph






--
With Regards,

Paramveer Jain

Attachment: PXMotorDriver.cpp
Description: PXMotorDriver.cpp

Attachment: PXMotorDriver.h
Description: PXMotorDriver.h


References:
How to support a new stepper motor controller? Ralph Lange
Re: How to support a new stepper motor controller? Kevin Peterson
Re: How to support a new stepper motor controller? Rod Nussbaumer
Re: How to support a new stepper motor controller? Paramveer Jain

Navigate by Date:
Prev: Re: MCB-4B Motor WriteInt32 Errors Caleb Marshall
Next: RE: MCB-4B Motor WriteInt32 Errors 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
Navigate by Thread:
Prev: Re: How to support a new stepper motor controller? Torsten Bögershausen
Next: FEMTO amplifier DLPCA-200 Ibrahim Saleh
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
ANJ, 14 Feb 2017 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·