STEPSER - Software Driver For INT-xx Range of Intelligent Stepper Drive Units

User Manual



Contents

1. Stepser - Driver For Int-01
1.1 Installation and Usage
1.2 Description of Functions
1.2.1 int SetComPort (int  nPort )
1.2.2 int SetSlaveId ( int nAxis,  int nId )
1.2.3 int SetTimeOut ( int  nTimeout )
1.2.4 int StepInit ( void )
1.2.5 int LoadAxisStart ( int nAxis , MOTOR *m1 )
1.2.6 int LoadAxisWait ( int nAxis , MOTOR *m1 )
1.2.7 int StartAxisSync( )
1.2.8 int  EnableDrive(int nAxis)
1.2.9 int DisableDrive(int nAxis)
1.2.10 int StopAxis(int nAxis)
1.2.11 int StopAxisSync( void )
1.2.12 int StepsLeft(int  nAxis, int *nSteps)
1.2.13 int StepsOver(int  nAxis, int *nSteps)
1.2.14 int QuerySlave(int  nAxis)
1.2.15 int ReadLimitStatus ( int  nAxis , char  *cStatus)
1.2.16 int HomeAxis (int  nAxis , int nLimit )
1.2.17 int EnableLimits ( int nAxis )
1.2.18 int DisableLimits ( int nAxis )


1. Stepser - Driver For Int-01

The  new INT-01 series intelligent stepper motor drives offer an easy interface to program movements through the serial port of any host computer.  The STEPSER library offers easy access to the various features of the drive by providing routines linkable to higher level languages running on an IBM PC-AT.  The standard version of STEPSER is available for operation of 3 drives.  However, the hardware link used for communication can support up to 31 units and an advanced version of STEPSER is required for operation/supervision.

Each drive is assigned an ID number by setting the jumper in the drive.  Ids may be 1,2 or 3. Messages including the ID number to which they are addressed to are sent through the serial port of the PC which are received by all the drives.  Only that drive which has been assigned that ID number by jumper setting will respond to that message and perform the indicated action.   If the action includes a return message, the drive sends out a message including its own ID.  Thus addressable bidirectional communication is achieved in true RS485 format between the drives and the host computer.

1.1 Installation and Usage

The package consists of 4 files :
 

  1. STEPSER.LIB - Containing the routines
  2. STEPSER.H - Containing data structure definitions and global variables
  3. EXMPL1.C - Turbo C example program
  4. EXMPL1.PRJ - Make file for example program
  5. TESTAXIS.EXE - Demonstration program


Installation is done by copying these onto the target computer.

The  library  module  is linkable to Turbo C programs. The user program should be  a LARGE or HUGE memory model program. It is recommended

This package consists of routines for the following operations :

  1. Setting up of parameters
    1. Specifying serial port to be used
    2. Specifying the Slave ID numbers for each axis.
    3. Setting up of timeouts for communication
  2. Initialising the communication link
  3. Control Operations
    1. Programming a movement
    2. Start/stop
    3. Enabling or Disabling Motor Power
    4. Enabling or Disabling software movement limits
    5. Homing/Zeroing operation
  4. Readback operations
    1. Steps left
    2. Steps over
    3. Current speed of the motor
    4. Read the status of the limit switches
    5. Status of the previous movement programmed
All  programs  using the functions in the library  are  prototyped  in  STEPSER.H  and  this file should be included in the  source  file.  The  important  data  structure defined in this include file is  the  MOTOR  type  structure  which  is  used for passing  data  to  the  LoadAxis (...) routine.

1.2 Description of Functions

This  section  describes the functions included in the  library.   The  names  of  the routines are mentioned in the same format as  they  are  prototyped  in the library. All the names are case sensitive  and  are  available publicly with preceding underbars.

Each function description consists of the function name. The  variable  name  given with the function name is a dummy name and given  for  the  purposes of illustration. A short summary of the operations  performed  by  the routine is provided followed by a clear indication  of  inputs  and  outputs to the routines. Special considerations  are  illustrated  with examples.

1.2.1 int SetComPort (int  nPort )

This  function informs other routines in STEPSER  of the communication port which is to be used for communcating with the slaves. This routine does not, however, initialise the serial port parameters.  The port is initialised only when StepInit(...) is called.  Do not use this routine after StepInit(...) has been called as this may lead to improper communications.

Call with :
                    nPort  :  Serial port used (0 for COM1 and 1       for COM2)

Return Value :
                     0      Always

The COM1 port is used by default.

Example :

     status = nSetComPort(0)  /** Sets COM1 **/

     status = nSetComPort(1)  /** Sets COM2 **/
 

1.2.2 int SetSlaveId ( int nAxis,  int nId )

This routine assigns the ID numbers connected to each axis. The three axes supported by the library are numbered 0 to 2.  However, the drive connected to the respective axis may have any other ID.  This function informs the library the ID of the drive, nId connected to the axis nAxis. It should be ensured that no two axis have the same ID slave connected.  Multiple Ids may not be assigned to the same drive nor may there be drives of identical numbers connected in a system. Refer to the INT01 documentation for information on setting the ID number of the drive.

Call with
  nAxis  : Axis number 0,1 or 2
  nId  :        ID number set on the drive

Return Value :

  0      Always
 

By default, Ids 1,2 and 3 are assigned to axis 0,1 and 2 respectively.  This routine is most likely to be used while interchanging drives between the axes.

Example :

The following program segment sets the axis 0 to work with ID 2, axis 1 with ID 3 and axis 2 with ID 1.

 SetSlaveId(0,2) ;
 SetSlaveId(1,3) ;
 SetSlaveId(2,1) ;

1.2.3 int SetTimeOut ( int  nTimeout )

In case of malfunctioning of the communication link or the slave, the slave unit may not transmit any return messages.  In such a condition, the host computer will permanently  wait for a return message.  To avoid this situation a programmable timeout has been provided through this function.  Any STEPSER routine will wait for nTimeout milliseconds before returning or retrying.  This routine also calibrates the delay loops inside the library with respect to the PC speed to avoid problems of portablility to faster or slower machines.  The routine takes about 2 seconds (depending upon your PC’ to return and hence should be used only once in the beginning of the application programme before calling StepInit().

Call with

       nTimeout     :     Time out in milli seconds.

Return Value
     0      Always
 

Default value of  timeout is  5 milliseconds, which will be sufficient for a IBM-PC-386 running at 16 Mhz.  For a 486 at 30 Mhz, a value of 10 ms would be more appropriate.

Example : To set a ramping frequency of 50 milliseconds

     SetTimeOut( 50 ) ;   /** sets 50 ms timeout **/

1.2.4 int StepInit ( void )

This function initialises the internal data structures of the library, intitialises the communication port and enables the power to the motors.

Call with:
  No parameters

Return value

                0      always successful
 

This routine is generally called once in the beginning of the program.  However, it may be called any number of times without causing major problems to the program. No example has been given for this routine, as it is self explnatory.

1.2.5 int LoadAxisStart ( int nAxis , MOTOR *m1 )

The movement to be executed is programmed with this routine.  The routine informs the slave associated with the axis number nAxis as to the movement parameters in the structure m1.  The MOTOR structure is defined in the include file SERSTEP.H and its form is as follows:

 typedef struct mot_dat
 {
  float speed     ;
  char direction  ;
  char resolution ;
  char rampflg    ;
  unsigned int movement ;
 } MOTOR ;
 

In this structure the field speed is the speed at which the movement is to take place, direction may be CLOCK or ACLOCK, resolution may be HALF or FULL and the amount of movement in steps is gien in movement.  The field rampflg is not used in this release of the library.  Ramping is always provided for all movement commands.

Call with
       axis     : Axis number
       m1  :     Pointer to the MOTOR structure

Return value
                0      Always successful

The routine only sends a message to the appropriate slave.  However, it is possible that the message did not reach the slave properly due to any reason such as improper communication link, slave already busy etc., then the the movement will not take place.  To ensure that the program has reached the slave, a call to this routine should be followed by a call to the QuerySlave routine which will return that the slave is busy if the movement has been taken congnizance of.  The following example and the example for the next library routine highlight the situation.

Example: For moving Axis 0 at speed 2000 sps for 10000 steps in the clockwise direction, the following program segment will suffice:

 m.speed = 2000 ;
 m.movement = 10000 ;
 m.direction = CLOCK ;
 m.resolution = HALF ;
 LoadAxisStart(0,&m) ;  delay(10) ;

1.2.6 int LoadAxisWait ( int nAxis , MOTOR *m1 )

This function is similar to the previous one, except that the drive does not start the movement on receipt of this program.  It may required to synchronise the movem+ents of various axis, for example, during linear interpolation in machine tools.  In such a case, the drives may be programmed using this routine for a given movement and then the StartAxisSync() function called for synchronised start of all the axis.  The calling sequence is the same as for LoadAxisStart(). The action of the routine is otherwise similar to the LoadAxisStart(...) function.  The StopAxis() routine may be used to call off an incorrect motion programmed previously.

1.2.7 int StartAxisSync( )

Subsequent to a call to LoadAxisWait(), this function is called to start the movement in the drive.  All drives that are programmed with a previous call will start the motion.  However, incomplete motion will not start again with this call.

Call with

       None

Return Value

     0      Always

1.2.8 int  EnableDrive(int nAxis)
1.2.9 int DisableDrive(int nAxis)

These routines enables or disables the drive indicated by nAxis. However, whenever a movement is programmed, the drives is automatically enabled.  The initialialisation routine StepInit(...) enables the drives.  When disabled, the motor is free and no current is passed through the coils.

Call with
       axis : Axis number ( 0,1 or 2)

Return Value

                0      Always successful

1.2.10 int StopAxis(int nAxis)
1.2.11 int StopAxisSync( void )

The StopAxis routine stops the movement in the axis nAxis. Other axes which may be moving at that time are not stopped.  The stopping action is immediate and without any ramping.  The loaded values are not reset and the amount of movement which has been performed before stopping may be read back using the StepsLeft(...) and StepsOver(...) routines.

In the case of StopAxisSync(), all the axes which may be moving are stopped.  Read back may then be implemented individually from each axes.

Call with
  axis  : Axis number ( 0,1 or 2 )

Return Value
                0      Always successful

This routine may also be used to cancel a previously programmed movement with LoadAxisWait() but not started.

1.2.12 int StepsLeft(int  nAxis, int *nSteps)
1.2.13 int StepsOver(int  nAxis, int *nSteps)

These  routines  report the status of a programmed motion,  while  the  motion is being performed or after executing StopAxis(...). StepsLeft() returns the number of steps still left in the previously programmed movement and StepsOver() returns the number of steps moved.

Call with
  nAxis    : Axis Number ( 0,1 or 2)
  *nSteps : Pointer to unsigned integer

Return Value

   0 :   Error in Communication
     No response from slave
   1 : Successful, nSteps has value
   2 : Reserved, no meaning
   3 : Error in Communication
     Corrupted Data

It is to be mentioned that as the number of slaves that are interrogated for status increases, the feedback rate should not be very high, as this will lead to increased bus activity and finally loss in communication.

Example : Continuing  the  example  for  load_axis, to  display  the  amount  of  movement made, the following change can be made

1.2.14 int QuerySlave(int  nAxis)

This  routine reports the status of the slave. The routine may be used for

· Checking if the slave is communicating properly and is active.
· Report the status of the previously programmed motion.
· Diagnose the fidelity of the communication link.

Call with
  nAxis : Axis Number (0,1 or 2)

Return Value

       0    No Communication from slave
       1    Motion complete and slave is idle
       2    The previously programmed motion is incomplete.
       3    Data error in communication

This routine can be used in conjunction with LoadAxisWait() to ensure that the programmed motion has been recognised by the slave.

1.2.15 int ReadLimitStatus ( int  nAxis , char  *cStatus)

This  routine reports the status of the end limits.  This function is typically used in implementing jogging or manual motion.  If the operator tries to travel beyond the end limits, the slave stops the motion and reports IDLE when queried.  If a doubt exists as to whether the axis stopped after the programmed movement is over or after hitting the end limits, reading the limit switch status will resolve it.

Call with
nAxis : Axis Number (0,1 or 2)
*cStatus : Pointer to character
 

Return Value
       0   No Communication from slave
       1   Motion complete and slave is idle
       2   Reserved. Not used.
       3   Data error in communication

The values returned in cStatus are:
 

Value (hex) Meaning
      01  Motor Side Limit Free, End Cut
      02  Motor Side Limit Cut, End Free
      03  Both sides Free
      00  Both sides Cut
 

1.2.16 int HomeAxis (int  nAxis , int nLimit )

Referencing is executed by this routine.  The function is implemented by first enabling limits, programming a motion equivalent to the total allowable travel of the axis and waiting for the slave to report IDLE when queried.  Once the the movement stops, the limits are read and checked for the proper value.

Call with:
nAxis   :   Axis Number (0,1 or 2)
nLimit : Direction in which to reference.
 

Return Value:
     0      No Communication from slave
     1      Homing complete
     2      Motion stopped but unable to read limits incomplete.
     3      Unable to move axis

1.2.17 int EnableLimits ( int nAxis )
1.2.18 int DisableLimits ( int nAxis )

The drives provide for automatic checking of over driving in either directions beyond the limits set by the limit switches.  The default status of this checking is OFF for all the axes.  The above routines provide for enabling (disabling) such checking in any specific axis.

In case of running with the limits checking enabled, and the motor hitting the limit switch in the specified direction, the query call will indicate that the drive is idle.  However, StepsLeft() will return the proper values which indicates the number of steps remaining to be moved when the limit was hit.

Call to these functions may not be made  while axis is in motion and will be ignored.

Call with: nAxis  :  Axis on which to enable or disable limit operation
Return : Always 0