TOC PREV NEXT INDEX

Put your logo here!


2 USER'S GUIDE

This section describes the API functions and ACI commands provided by the mot and motci SW modules.

2.1 Overview

The Motor Control Module is designed for a standard LCU environment, consisting of a VMEbus system with a CPU board, running the VxWorks operating system. The MCM makes extensive use of the LCU Common Software facilities, such as Event, Error and Signal Handling, Time functions and, in particular Local Database access.

The Motor Control Module forms a service layer between application level and device driver level to provide a standardized, hardware independent interface between applications and motors. An application attaches the required motor(s) and performs operations with that/these motor(s) by means of the API routines or ACI commands without knowing details about drivers or boards.

In particular, the ACI, used in combination with the motei, provides a mean to the engineer to tune the motor configuration parameters and test the motions without having to write any code.

The following environment must be provided and set-up at boot-time to enable operation of the Motor Control Module.

All versions correspond to VLT Common Software Release OCT98, unless specified.

· CPU board Motorola MVME167 (MC68040) or MVME2604 (PowerPC 604e)
· motor hardware and corresponding VME boards
· DC or Stepper motor
· Servo Amplifier
ESO-VME4SA-X1
ESO-VME4ST
· Motion Controller
MACCON-MAC4-INC, from version 4.1A (recommended is 4.2A)
MACCON-MAC4-SSI, from version 4.1A (recommended is 4.2A)
MACCON-MAC4-STP, from version 2.0A
· Digital IO Board
ACROMAG Series 948x
· Time Interface Module
ESO-TIM
· VLT Common Software , backwards compatible with releases from DEC95
· device drivers, one for each board type:
· ampl, for the Servo Amplifier
· mcon, for the Motion Controller
· acro, for the digital I/O board
· tim, for the Time Interface module
· MCM ACI motci & API mot modules
· MCM SDL modules (see [4])
· local database containing entries for the motors to be used, (see section 4)

Note: The version of the Motor Control Module described in this manual works only with the above described versions of board firmware and device drivers. It is not possible to run the current version of the Motor Control Module together with older versions of the drivers.

Figure 1 shows the hardware and software environment of the MCM :

Figure 1 - Motor Control Module Environment

· The interface to the applications is covered by the modules mot (API ), and motci (ACI), which are described later in this document. The API provides a library of routines callable by LCU applications, while the ACI provides a LCU process implementing a set of commands which can be sent by LCU and WS applications (see also Figure 2).
· The interface to the device drivers, through which all hardware accesses are made, is covered by the so-called SDL modules. This interface is described in [4].
· The local database is accessed by dedicated routines, which are provided by the LCU Common Software [1] and by the Common Access Interface module [5].
· The facilities of the LCU Common Software are used whenever applicable for the needs of the Motor Control Module.
· The interface to the VxWorks operating system, i.e. to VxWorks specific system services is kept as small as possible.

Figure 2 - Role played by the various MCM components

2.2 Supported Configurations

This section describes the hardware components and configurations from the final-version point of view. The restrictions of the implementation of this version and the explicit identification of boards are described in the next section.

The motor hardware (i.e. the logical level below the driver level) can be divided into various groups. There are:

· LCU internal boards:
· motion controller
· amplifiers
· digital I/O boards
· analog I/O boards
· external encoder interfaces
· LCU external hardware:
· encoders
· limit switches
· reference switches
· motors:
· stepper motors
· DC motors

All the supported configurations are listed in Appendix A.

· VME boards: (see Appendix A)
The only mandatory board for motion control is the amplifier, which may not be controlled by MCM (Stand-Alone mode).

Important Note: In all the supported configurations but #21 to #23, the amplifier can be replaced by any kind of Maccon MAC4-compatible purely passive amplifier.

· Limit and reference switches: There may exist two sets of upper/lower limit switches and one reference switch. When only an amplifier controls the hardware then only one set of limit switches is allowed, otherwise each combination of one or two sets of limit switches and/or one reference switch are possible.
· Types of position encoders: serial and parallel encoders for linear and circular axis with absolute (type SSI) or incremental (type INC) coding, with and without zero pulse are supported. The use of an encoder requires a motion controller board or an external encoder interface to get the encoder value.
· Additional I/O-Signals like interlock, emergency stop, motion stop etc. can be configured. Such signals are connected to a LCU through I/O-Boards. The mot module uses the Common Software signal handling facilities to process such signals.

Note: Internally, the mot module has no practical limitation on the number of motors it can support. However, each motor occupies system resources (CPU, dynamic memory, database space, etc.) on a LCU, which limits the maximum number of motors to about 30. The MCM object modules need about 200 kBytes memory space.

In addition, each motor requires the following resources:

· approx. 20 kB database space
· about 1 kB dynamic memory, not counting the task stacks
· one device descriptor per driver
· up to three tasks, besides the application task
· up to seven (7) semaphores
· up to four (4) interrupts (depending on the HW)

In the above list the number of interrupt hooks is the strongest constraint because the hardware supports a maximum of 256 interrupts, which cannot be extended. All other resources can be extended by supplying more memory and configuring VxWorks appropriately.

2.2.1 Version Related Configurations

The MCM software supports all the configurations listed in Appendix A, but #21 and #23.

These configurations consist in:

· an amplifier (mandatory). If declared, the respective SDL is used. Otherwise, the MCM does not attempt to access any amplifier board. (see 4)
· optionally a motion controller.
· a serial incremental INC/absolute SSI encoder, connected to the controller or to an external interface board.
· optionally one set of limit switches connected to the controller.
· optionally one set of limit switches connected to the amplifier.

The MCM package supports DC and Stepper motors.

2.3 Motor Registration

2.3.1 Configuration

Depending on the way the database branch of the motor has been generated (see 5.3.1), one may need to load the configuration file (<motor>.dbcfg file) into the DB branch. The configuration files are part of the application software and generated via the Engineering tool motei. They shall be installed in the $INS_ROOT/SYSTEM/COMMON/CONFIGFILES path and the $INS_ROOT file system shall be NFS mounted as /INSROOT on the LCU. The function motInitDb(1) performs this initialization, as shown in the example below for the motor aliased M1:

Example:

ccsCOMPL_STAT status;
ccsERROR error;

...
if ((status = motInitDb( "M1","motor1.dbcfg", &error )) == FAILURE)
{
/* process error */
...
}

From the VxWorks shell, the installation of a motor is performed as shown below:

motInitDb("M1","motor1.dbcfg")

or

motInitDb("M1","/INSROOT/SYSTEM/COMMON/CONFIGFILES/motor1.dbcfg")

After this step has been successfully performed, the database branch of the motor has been initialized to the values contained in the file.

If no file name is provided, the file $INS_ROOT/SYSTEM/COMMON/CONFIGFILES/<alias>.dbcfg will be loaded (assumed it exists). It is also possible to give any valid absolute path, assumed it can be accessed via NFS from the LCU.

2.3.2 Installation

Before any operation on motors can be performed, all the motors connected to the LCU and intended to be accessed by the MCM, must be installed. The installation must be done only once for each motor and can be invoked either from the VxWorks Shell as a tool function, or within the application. The function motInstall() requires as parameter the alias (or the absolute path to the database branch) of the motor. It does various operations:

1. Allocate and initialize internal data structures
2. Check the database structure
3. Resolve direct addresses of database attributes for performance reasons
4. Call the SDL installation functions
5. Check and convert database information:
a. Resolution of the external functions (see HW-Initialization and Unit conversions): At installation time, the only requirement is that all external functions are resolved (their entry points have been found in the symbol table).
b. Unit conversion check
c. Conversion of the database attributes in board units: Database entries specified in user units are here converted to board units for performance.
6. Configure the I/O signals

Example:

ccsCOMPL_STAT status;
ccsERROR error;

...
if ((status = motInstall( "M1",&error )) == FAILURE)
{
/* process error */
...
}

From the VxWorks shell, the installation of a motor is performed as shown below:

motInstall("M1")

The tool function motPrintMotors displays all the installed motors (see 3.3.4), see also motMotors(3).

2.3.3 Deinstallation

Deregistration: a motor can be de-registered from the MCM, after it has been detached, by the function motDeinstall(), which offers the same interface as motInstall().

2.4 Application Programmatic Interface

The mot SW module consists in two parts: the API functions and the Server routines. The API functions are the one that are invoked by the application, the Server routines manage the interface to the SDL layer; they operate on a single motor (see Figure 2).

Two groups of functions have to be distinguished among the API routines:

· motion control : these functions are designed for operating on a set of motors
· unit conversion: these functions apply for a single motor.

The motor branches of the local database contain all information needed by the API routines for motion control. The direct access to the database by applications is foreseen only for maintenance purposes (i.e. motor parameters configuration) and for the special applications (e.g. UIF) to monitor the motor status. Parameter passing from the application to the MCM is made via the arguments of the API routines. No parameter passing through the Local Database is foreseen.

Hence, during normal operation, only the API routines are invoked by applications.

The access to motors is realized by so-called motor handles. A motor handle is a number, which is delivered by the mot SW module to an application attaching a motor and enables the access to this motor. The access to a set of motors is released by detaching them.

One application can access several motors and the same motor can be accessed simultaneously (with restrictions, described below) by several applications. Moreover, an application can pass a motor handle to another application to enable its access to the corresponding motor.

On attachment request, a motor is identified by its name, which corresponds to the alias of the main point of the motor branch in the local database (see section 4 ).

With exception of the install, clear, attach and unit conversion functions, a list of handles terminated by the value 0 has to be passed as first parameter to each mot API routine.

Furthermore, the last argument of each API routine to be passed is the address of a ccsERROR structure. In the case of an error the error reason and number are passed back to the calling routine by this structure. In general, the processing loop of the passed handle list is broken when the first error occurs.

Finally, each API routine returns a ccsCOMPL_STAT completion status. Further arguments of API routines are function dependent. Hence, the generic synopsis of an API routine is:

ccsCOMPL_STAT mot<Function>(motHANDLE *handle,...,ccsERROR *error)

where the ellipsis ... stands for the function dependent parameters.

The API functions available in the current version are:

1. motAttach attach motor
2. motCheckInterlock check interlock line
3. motCheckBrake check brake status
4. motCheckMove check validity of requested motion for a set of motors
5. motClampBrake clamp brake
6. motConnect connect motor electrically
7. motDetach detach motor
8. motDigToCurrent convert motor current from digital value to user specific unit
9. motDisable disable motion controller control loop
10. motDisconnect disconnect motor electrically
11. motEnable enable motion controller control loop
12. motEncToIndex convert position from encoder specific unit to a position index
13. motEncToName convert position from encoder specific unit to a position name
14. motEncToPos convert position from encoder specific unit to user specific unit
15. motEncToVel convert speed from encoder specific unit to velocity reference unit
16. motGetOpMode get actual operational mode
17. motGetParListAddress read the address of the user data structure from the Database
18. motGetHandle retrieve motor handle for external encoder handling
19. motGetSemIEV retrieve semaphore for external encoder handling
20. motGetStatus get actual motor status information
21. motInitHw initialize motor from the HW point of view
22. motInitSampling start motor status sampling
23. motInitSw initialize motor from the SW point of view
24. motLoadPar load parameter to amplifier/motion controller boards
25. motMove move motor
26. mot NameToEnc convert position name to encoder specific position unit
27. mot NameToVel convert speed name to encoder specific velocity unit
28. motPosToEnc convert position from user specific unit to encoder specific unit
29. motRefToVel convert speed from velocity reference unit to user specific unit
30. motResetAxis reset axis
31. motResetBoards reset boards
32. motRetrievePar retrieve amplifier /motion controller board parameter
33. motSetDefaultUnits set default user units
34. motSetMotionMode set motion mode
35. motSetOpMode set operational mode
36. motSetParListAddress write the address of the user data structure to the Database
37. motSetSection set section for named positions
38. motSetSwLimits set SW limits of a set of motors
39. motStop stop motor
40. motStopSampling stop status sampling task
41. motUnclampBrake unclamp brake
42. motVelToEnc convert speed from user specific unit to encoder specific unit
43. motVelToRef convert speed from user specific unit to velocity reference unit
44. motWaitInit wait for HW initialisation procedure completion
45. motWaitMove wait for motion completion
46. motWriteEncoderValue write encoder value to motion controller board

See section 3.1 for detailed information concerning each function.

Note 1 The priority of the calling task is free.
Note 2 In the following sections, various examples will be listed. The variables used will be declared with the appropriate type where they are needed. The variables, which have been previously declared, will not be declared again.

Database attributes will be referenced by <path>:SUB_POINT.attribute, where <path> is the path to the motor point (e.g. :INS1:DC_MOTOR1).

2.4.1 Access Control

To get access to a motor, an application must attach the requested motor. The function motAttach is the first function to call. It returns the motor handle, with which further operation is possible. The application can attach the motor in several modes:

· motread_only motions are not allowed, only the request of status and configuration parameters, the status sampling, unit conversions and waiting for motion to complete are authorized
· motexclusive all actions are allowed, no other application can perform motions on the motor
· motemergency everything allowed with highest priority (maintenance purpose, emergency case)

Only one application at a time can attach a motor in exclusive mode. Further attempts are rejected with an error. However, an arbitrary number of applications can attach in read-only mode. The emergency mode is always allowed without restrictions but shall really be used in case of emergency only.

The associated literals to the type motACCESS_MODE are defined in motDefines.h.

Table 1 shows the allowed combinations, where RO, EX and EM stand resp. for Read-Only, Exclusive and Emergency; [n] means many times, [1] once only.
Table 1 - Access mode combination matrix
from
\
to
RO
EX
EM
RO
OK [n]
OK [n]
OK [n]
EX
OK [1]
FAIL
OK [1]
EM
OK [1]
OK [1]
FAIL

A connection to a motor is released, i.e. the corresponding motor handle is freed by calling the function motDetach, which results in the application losing access to the motor.


Important Note: After a motor has been attached in Exclusive mode, it must be SW and HW initialized. Detaching an initialized motor from Exclusive mode leads to loose the initialization.

Example:

....
#include "mot.h"

ccsCOMPL_STAT myExample(....,ccsERROR *error)
{
/* handles for motor access */
motHANDLE handleEX[2] = {0,0};
motHANDLE handleRO[2] = {0,0};
/* database path to the motor to be attached */
dbSYMADDRESS motorName;
/* motor status data structure */
motSTATUS motorStatus;
....
ccsCOMPL_STAT status;
....

/*
* attach motor named DC_MOTOR1 in EXCLUSIVE access mode
* in motAttach a motor is identified by its name,
* in any other API function, a motor is identified by
* its handle returned by motAttach
*/
strcpy(motorName,":INS1:DC_MOTOR1");
status = motAttach(motorName,motEXCLUSIVE,&handleEX[0],error);
if (status == FAILURE)
{
/* process the error */
}

/*
* attach motor named DC_MOTOR1 in READ_ONLY access mode
*/
status = motAttach(motorName,motREAD_ONLY,&handleRO[0],error);
if (status == FAILURE)
{
/* process the error */
}
...
/*
* perform actions on the motor
*/
status = motInitSw(handleEX,TRUE,error);
if (status == FAILURE)
{
/* process the error */
}
...
/*
* get the motor status
*/
status = motGetStatus(handleRO,&motStatus,error);
if (status == FAILURE)
{
/* process the error */
}
...
/*
* get the motor status
*/
status = motGetStatus(handleEX,&motStatus,error);
if (status == FAILURE)
{
/* process the error */
}
...
/*
* detach motor
*/
status = motDetach(handleEX,error);
if (status == FAILURE)
{
/* process the error */
}
status = motDetach(handleRO,error);
if (status == FAILURE)
{
/* process the error */
}
...
return(status);
}

2.4.2 Operational Modes

Each motor can be used in several modes of operation:

The NORMAL mode is the standard operational mode and the only mode where motions are possible.
The SIMULATION mode is used for operation without hardware. No driver calls are made in this mode. The simulation mode is handled on the Single Device Library level (see [4]). The processing down to the level of driver calls is identical to the NORMAL mode. In simulation mode all hardware actions are simulated to be done instantaneously and successfully.
In HANDSET mode the motor is controlled manually through LCU boards. No motion can be started, but read access is granted for the current status.
The mode NOT AVAILABLE signals that a motor cannot be used. This state is entered by command after a malfunction is detected from the outside. No motion is allowed. Read access is granted for the current status.
The mode FIXED POSITION is internally treated in the same way as the NOT AVAILABLE mode. It is just for information of an application that the motor is available but cannot be moved.No motion is allowed. Read access is granted for the current status .

The operational mode can be set by an application through the motSetOpMode routine. It can be used regardless of the active operational mode. The associated literals to the type motOPMODE are defined in motDefines.h.It is not allowed to change the operational mode while a motor is moving.

The current operational mode can be requested through a motGetOpMode call.

Furthermore, the current operational mode is stored in the local database attribute <path>:STATUS.opMode.

On the first attachment, an initial operational mode is read from the database and activated:

attribute <path>:SERVER:CONF.motor(0,opMode).

Note : When a motor is not anymore attached by any application, its operational mode is set to the internal mode motDETACHED. This mode can not be selected by the application.

Note : When the operation mode of a motor is changed by an application, its initialization state is reset to motNOT_INIT.

2.4.3 Initialization Procedure

After the first attach in exclusive mode, a motor must be initialized before any motion can be performed.

The initialization is divided into two phases: software and hardware initialization.

The software initialization must be performed first. The motor configuration as stored in the database is loaded to the boards and the internal data structures are initialized.

Example:

vltLOGICAL mandatory;

mandatory = TRUE;
if ((status = motInitSw(handleEX,mandatory,error)) == FAILURE)
{
/* process the error */
}

If the logical variable mandatory is TRUE, the SW initialization will be performed in any case; if it is FALSE, the SW initialization will be performed only if the motor has not been initialized before.

On success, the attribute <path>:STATUS.initStatus is set to motSW_INIT. The associated literals to the type motINIT_STATUS are defined in motDefines.h. On failure, it is set back to motNOT_INIT.

The SW initialization completes when all parameters used by the user-defined functions are valid (see 2.4.12).

In the case the encoder is not connected to the Motion Controller board and the position information is available from the CPU (valid VME address), a special procedure must be implemented that updates the position information as requested by the Motion Controller (assumed the board can handle this feature; available on Maccon MAC4 from this release on). Detailed information is given in section 2.4.13.

This procedure must be invoked before any motion is initiated.

The hardware initialization performs a sequence of actions (motions and settings), necessary to bring the motor and its parameters to a known initial state. The wanted sequence must be defined in the LCU Local Database, attribute <path>:SERVER:INIT.actions. The number of actions is not limited. The associated literals to the type motACTION_TYPE are defined in motDefines.h:

· move the motor
· clamp the brake
· disconnect the motor
· initialize the actual position value
· set lower/upper software limits
· invoke a user-defined initialization procedure
· invoke a on-board HW initialization procedure
· delay the nex step

An action is defined by the following parameters:

1. actionType type of action (last entry must be motACTION_END)
2. userFctName name of the user-defined HW initialization procedure (see section 2.4.12)
3. userParList address of a data structure, which may be required by the user-defined function
4. initCode on-board HW initialization procedure number/delay in milliseconds
5. motionMode motion mode (see section 2.4.4)
6. position position to move to (see section 2.4.5)
7. posType positioning type (see section 2.4.5)
8. speed definition of the speed (see section 2.4.5)

A typical sequence of actions to initialize a motor could be

· move to reference switch
· initialize actual position value
· define upper and lower software limit
· move to a predefined starting-point

Example:

mandatory = TRUE;
if ((status = motInitHw(handleEX,mandatory,error)) == FAILURE)
{
/* process the error */
...
}

If the logical variable mandatory is TRUE, the HW initialization will be performed in any case; if it is FALSE, the HW initialization will be performed only if the motor has not been initialized before (i.e. the attribute <path>:STATUS.initStatus is motSW_INIT). While the HW initialization is running, the attribute initStatus is set to motHW_INIT_RUN. On success, the attribute initStatus is set to motINIT_DONE; on failure, it is set back to motSW_INIT.

The HW initialization completes when positions which have been defined relative to HW positions are fully resolved.

The HW initialization procedure may last some time, and the application may want to use this time for other operations. It would also like to know exactly when the HW initialization procedure is completed, without consuming CPU time. The function motWaitInit fulfills these expectations:

Example:

vltINT32 timeout = 300000; /* in milli-seconds */
status = motWaitInit(handle,timeout,&motStatus,error);
if (status == FAILURE)
{
if (error->errorNumber == motERR_TIMEOUT)
{
/* process the timeout */
...
}
else
{
/* process the error */
...
}
}

The function returns when all the motors of the handle list have completed their HW initialization procedure or a timeout has occurred, or immediately if an error occurred. The function returns SUCCESS when the HW initialization has been successfully completed within the given time; it returns FAILURE if a timeout has occurred (error number set to motERR_TIMEOUT), or if the procedure failed (the error number is then set appropriately).

The status of each specified motor is updated on function completion, regardless of the returned completion status.

On failure, the HW initialization procedure of the remaining motors is not interrupted.

Only one process can wait for the HW initialization procedure of a given motor to complete.

The timeout can also be set to WAIT_FOREVER (-1), this should be handled with care.

2.4.4 Motion Modes

In order to be able to move a motor, a motion mode must be set through the motSetMotionMode routine. Possible choices:

In motPOSITION_MODE mode, a motor can be moved to a position defined by a relative or absolute value.
In motDIRECT_MODE mode, a motor will be moved directly via the amplifier, whereby only the speed can be specified. The speed can be changed at any time by a further call to motMove.
In motTRACKING_MODE mode, a motor can be moved to a given absolute or a relative position, or at a given speed, whereby the next position/speed can be redefined at any time during the motion by a further call to motMove.
In motSPEED_MODE mode, a motion is defined by a speed and controlled by a motion controller. After starting a motion by motMove, the motor will move with the specified speed until a limit is reached or the motor is stopped by motStop. The speed can be changed at any time during the movement by a further call to motMove.

The associated literals to the type motMOTIONMODE are defined in motDefines.h.

Example:

motMOTIONMODE motionMode;
motMOTION motion;

motion.posType = motABSOLUTE;
motion.pos.how = motBY_INDEX;
motion.pos.index = 0;
motion.speed.how = motBY_NAME;
strcpy(motion.speed.name,"coarse");
motion.lastStep = TRUE;

/* perform an absolute motion to the named position indexed 0 */
/* in POSITION mode at the named speed "coarse" */
motionMode = motPOSITION_MODE;
status = motSetMotionMode(handle,&motionMode,error);
if (status == FAILURE)
{
/* process the error */
}
status = motMove(handle,&motion,error);
if (status == FAILURE)
{
/* process the error */
}

2.4.5 Motion Specification

A motion is specified via a motMOTION structure. A sequence of motions is specified by an array of such structures. The motMOTION structure type is defined in the motor control module include file mot.h. A motion structure consists of the following parameters:

· the position type
· the position specification
· the speed specification
· a flag indicating, when TRUE, that this structure is the last element of the motion sequence array.

The position type specifies how to interpret the specified position. The associated literals to the type motPOS_TYPE are defined in motDefines.h. Possible types are:

· motABSOLUTE The position value defines an absolute position.
· motRELATIVE The position value defines a relative position.
· motUPPER_LIMIT The position is the upper HW limit.
· motLOWER_LIMIT The position is the lower HW limit.
· motREFERENCE_SWITCH The position is the Reference Pulse
· motINDEX_PULSE The position is the Index Pulse.
· motHOME_POSITION The position is the Home position.
· motBY_SPEED The motion is defined merely by a speed.
· motTWO_STEP_ABS The motion is a two step absolute motion
· motTWO_STEP_REL The motion is a two step relative motion
· motHALF_TURN_ABS The motion is a two step absolute motion of half a turn
· motHALF_TURN_REL The motion is a two step relative motion of half a turn

Up to 10 steps may be defined in a sequence, but the position types motINDEX_PULSE, motTWO_STEP_ABS, motTWO_STEP_REL, motHALF_TURN_ABS and motHALF_TURN_REL extend to 2 entries, increasing the length of the sequence. If the sequence is longer than 10 entries, an error message will be logged (motERR_EXTRA_IGNORED), and the first ten entries of the sequence will be processed.

One additional position type is available for the HW Initialization only: motOFF_REFERENCE_SWITCH which operates in Position mode. The position of the motor is checked against the Reference Switch; if the Reference switch is not active, no motion is initiated, otherwise the motor is moved of the specified relative displacement off the Reference Switch.

For relative positioning, only positions specified by value are allowed (see below).

According to the definition of the motion modes, table 2 shows the possible combinations of motion mode and position type:

Table 2 - Motion mode vs. Motion type matrix
Position
Type


Motion
Mode
Motion
Absolute
/
Relative
Motion to
Up / Low
HW Limits
Motion to
Index Pulse, Home
&
Reference Switch
Motion

By Speed
Two Step
Half Turn
Absolute
/
Relative
motSPEED_MODE
No
Yes
Yes
Yes
No
motDIRECT_MODE
No
Yes
No
Yes
No
motPOSITION_MODE
Yes
Yes1
Yesa.
No
Yes
motTRACKING_MODE
Yes
No
No
Yes
No
1
Access via named positions table only (assumed these positions have been defined by name) or as relative motion from these positions (assumed the absolute position of these positions is known by the system).

The motion to the index pulse is performed in two steps: the first step is a coarse search made at the given speed, the second is made in reverse direction at the speed predefined in the database attribute <path>:SERVER:CONF.indexPulseSpeed. Depending on the motion controller board, this feature may not be supported; however, the mot SW module invoke twice the same call to the motion controller MoveToInd (see [4]), with successively the two speeds. The way the motion controller handles these calls is not in the scope of this manual.

The motion to the Home position is defined as being the overlap of the Reference Switch and of the Index Pulse of the encoder (this position can be reached only if the hardware has been configured so that these two positions overlap and assuming that the encoder delivers the Index Pulse signal (Incremental encoder only).

Two step motions are handled as normal steps in POSITION mode, but the motion is executed in two steps, whereby the second step is predefined in the database attribute <path>:SERVER:CONF.twoStepOffset. This offset is added to the target position for the first step, then the way is covered back at the predefined speed. This feature allows the positioning to be executed always from the same side of the target position (eliminating possible backlash effects).

Half Turn motions are handled as normal steps in POSITION mode for CIRCULAR axis only, but the motion is executed in two steps, whereby the second step is predefined in the database attribute <path>:SERVER:CONF.twoStepOffset. This absolute offset is subtracted to the target position for the first step, then the way is covered in the same direction at the predefined speed. This feature allows the positioning to be executed in a deterministic way.

However, for not optimized circular axis, the motor will not (per definition) cross the zero.

If the requested position (HW limit, Reference Switch, Index Pulse or Home position) is not available on the hardware or the action is not supported by the firmware/driver or SDL, the motion fails (see section 2.4.6).

The position and the speed can be specified in three, resp. four ways:

· by default, whereby the default speed is taken (index in named speed table).
· by value, whereby all information defining the position or the speed has to be provided by the user.
· by name, whereby only a position/speed name has to be provided by the user and any further information is retrieved from the database attributes:
<path>:SERVER:CONF.namedPositions/Speeds , containing up to 15 entries.
· by index, whereby only an index to the namedPositions/Speeds attribute of the motor in the local database has to be provided by the user and any further information is retrieved from the local database

The associated literals to the type motSPEC_TYPE are defined in motDefines.h,.

The following parameters have to be defined by the user specifying the target position or speed:

· by value: The position or speed is specified by a value and a unit (see data structure type motMETRIC in mot.h). For the speed, three additional parameters are required (see section 2.4.7 for explanation):
· pollInt Monitoring polling interval in ms of the far phase; the motor is moving to the target position
· endPollInt Monitoring polling interval in ms of the near phase; the motor is in the target window
· inPosTime Needed in-position time in ms for motion complete condition.

Example:
....
motMOTION motion;
.....
/*
* specify position by value
* next position to move 10 deg
*/
motion.posType = motABSOLUTE;
motion.pos.how = motBY_VALUE;
motion.pos.number.value = 10.0;
strcpy(motion.pos.number.unit, "deg");
...
/*
* specify speed by value
* requested speed 1deg/sec
* monitoring interval "far" phase 1000ms
* monitoring interval "near" phase 100ms
* in-position time interval 1000ms
*/
motion.speed.how = motBY_VALUE;
motion.speed.number.value = 1.0;
strcpy(motion.speed.number.unit, "deg/sec");
motion.speed.pollInt = 1000;
motion.speed.endPollInt = 100;
motion.speed.inPosTime = 1000;

/*
* specify position by value
* 10 deg below the upper HW limit
*/
motion.posType = motUPPER_LIMIT;
motion.pos.how = motBY_VALUE;
motion.pos.number.value = -10.0;
strcpy(motion.pos.number.unit, "deg");

· by name: for the position, an additional parameter is required specifying the offset to the named position: the so-called section (the offsets are defined for each namedPosition entry in the database). The associated literals to the type motSECTION are defined in motDefines.h:
· motOBSERVATION position as defined
· motMAINTENANCE observation position + maintenance offset.
· motUSER_DEFINED observation position + user offset
Example:
....
motMOTION motion;
.....
/*
* specify position by name
* next position to move is "RED", Maintenance position
*/
motion.posType = motABSOLUTE;
motion.pos.how = motBY_NAME
strcpy(motion.pos.name.posName, "RED");
motion.pos.name.section = motMAINTENANCE;
....
/*
* specify speed by name
* moving speed is "FAST"
*/
motion.speed.how = motBY_NAME
strcpy(motion.speed.name, "FAST");

· by index: The index number specifies the record number of the entry of the attribute named Positions/Speeds to be used.
For the position indexing, it is possible to specify the section (as for by name). The following macros are available:
motSET_OBSERVATION_INDEX(index) to access the Observation section
motSET_MAINTENANCE_INDEX(index) to access the Maintenance section
motSET_USERDEFINED_INDEX(index) to access the User-Defined section
The default section is Observation (for backwards compatibility).

Note: The first entry of a table corresponds to the record number 0.

Example:
....
motMOTION motion;
.....
/*
* specify position by index
* the requested position corresponds to the named position
* specified by the 4. entry (= record number 3) in the named
* position table, additionally in the MAINTENANCE section
*/
motion.posType = motABSOLUTE;
motion.pos.how = motBY_INDEX;
motion.pos.index = motSET_MAINTENANCE_INDEX(3);
....
/*
* specify speed by index
* the requested position corresponds to the named speed
* specified by the 2. entry (= record number 1) in the named
* speed table
*/
motion.speed.how = motBY_INDEX;
motion.speed.index = 1;
....

Important Note:

For the position specification by name or by index, the value stored in the field number is taken as an offset if the string defining the unit is not empty.
Example:
....
motMOTION motion;
.....
/*
* specify position by name + offset
* next position to move 10 deg above the named position
* "RED" in Maintenance section
*
*/
motion.posType = motABSOLUTE;
motion.pos.how = motBY_NAME
strcpy(motion.pos.name.posName, "RED");
motion.pos.name.section = motMAINTENANCE;
strcpy(motion.pos.number.unit,"deg");
motion.pos.number.value = 10.0;
....

2.4.6 Motion Control

Before trying to move a motor the following actions have to be performed:

· Attach the motor in EXCLUSIVE mode, calling motAttach (see section 2.4.1).
· Perform the SW and HW initialization of the motor, calling motInitSw and motInitHw (see section 2.4.3)
· Configure the motion mode according the intended movement, calling motSetMotionMode (see section 2.4.4).

After successful execution of these operations a single motion or sequence of motions of the motor can be started using the motMove function.

Motions are rejected, when the access mode is not EXCLUSIVE or EMERGENCY, the motor is not available because of hardware malfunctions, the brake is clamped, the interlock line is active or the initialization procedure failed.

An application can ask once or periodically for the status of a motor or a set of motors, by calling the routine motGetStatus (see also 2.4.8), or wait for the motion completion, by calling the routine motWaitMove, which works like motWaitInit. This function returns either on motion successful completion, time-out or abnormal event.

Two types of timeout may occur:

Motion step timeout The motion step could not be completed within the time within which any motion step shall complete. This time is defined in the database attribute <path>:SERVER:CONF.motor(0,timeout) in milliseconds.
Motion sequence timeout The motion sequence could not be completed within the time given to the motWaitMove function.

This routine returns a structure, containing the status of the motors. The associated literals to the type motMOTION_STATUS are defined in motDefines.h:

· motSTANDING The motor has reached the soll-target position,
· motMOVING The motor is moving,
· motTIMEOUT The motion is aborted due to timeout,
· motABORTED The motion is aborted due to an error, or has been interrupted,
· motREDEFINED The motion has been redefined while moving.

Example:

#include "mot.h"

ccsCOMPL_STAT myMoveExample (....,ccsERROR *error)
{
....
motHANDLE handle[2] = {0,0};
motMOTION motion;
motMOTIONMODE motionMode;
motSTATUS motStatus;
....
/* attach motor/fill motionSequence data structure */
status = motAttach("DC1",motEXCLUSIVE,handle,error);
....
/* initialize motor SW/HW */
status = motInitSw(handle,TRUE,error);
....
status = motInitHw(handle,TRUE,error);
....
/* fill motion sequence data structure */
motion.posType = motABSOLUTE;
motion.pos.how = motBY_INDEX;
motion.pos.index = 0;
motion.speed.how = motBY_NAME;
strcpy(motion.speed.name,"coarse");
motion.lastStep = TRUE;

/* perform an absolute motion to the named position indexed 0
* in POSITION mode at the named speed "coarse" */
motionMode = motPOSITION_MODE;
if (motSetMotionMode(handle,&motionMode,error) == FAILURE)
{
/* process the error */
...
}

/* initiate movement */
if (motMove(handle,&motion,error) == FAILURE)
{
....
}
/*
* wait for end of movement 10000 ms
*/
if (motWaitMove(handle,10000,&motStatus,error) == FAILURE)
{
if (error->errorNumber == motERR_TIMEOUT)
{
/* time-out reached */
....
}
else
{
/* an error has occurred */
....
}
}
/* movement successfully completed */
....
return(status);
}

An application can stop a motor by using the motStop routine. After the motor has stopped, another process waiting with motWaitMove is resumed and returns FAILURE. The motion status is set to STANDING; if in POSITION motion mode, the status flag inPosition is not set because the target position was not reached.

2.4.7 Motion Monitoring

From the point of view of the MCM a movement consists of two phases:

· the far phase, where the motor drives to the target position
· the near phase, where the target is almost reached, the motor is in the target window and the motor slowly moves to its end position

A movement is automatically supervised by a monitoring task, which periodically requests and evaluates the actual status. Three parameters have to be made available to the monitoring task:

· the polling interval in ms for the far phase
· the polling interval in ms for the near phase
· the value specifying the required "in position" time in ms for the motion complete condition

These parameters have to be specified either by the user via the motMOTION data structure passed to motMove (see section 2.4.5) or, if a named speed is used, in the corresponding namedSpeeds record of the local database.

For each motor a time-out value is configured in the local database, to specify when motions of this motor shall be treated as lasting too long and be timed-out. However, the motion monitor task does not undertake any actions on abnormal events or time-out but informs the application by setting the motor status in the local database accordingly.

If the motion completion is to be reported by an interrupt (see 2.4.10), it returns the motion status STANDING as soon the motion end event has been registered by the motion monitor (assumed the in Position time is larger than the target settle time, see motion controller mac4 parameter TT).

2.4.8 Status Sampling

The Motor Status Sampling facility performs monitoring and status sampling of any set of motors, no matter whether they are moving or initialized. The sampling is started by the routine motInitSampling. A sample period can be specified at which the general status data in the local database is updated. The motStopSampling routine is used to stop the sampling. For detailed information about the general status data section of a motor in the local database, see section 4.

The status sampling task is automatically spawned after the motor has been successfully SW initialized. The sampling task updates the status with the period specified in the database attribute <path>:SERVER:CONF.motor(0,timemon) in milli-seconds. The sampling task runs until the motor is detached or explicitly stopped by motStopSampling. The sampling task remains alive (regardless of any call to motStopSampling) as long a motor is at least SW Initialized. For Read-Only processes, calls to motStopSampling will have little effect.

Note: During all the time a motor is SW initialized, the status part of the database is automatically updated on change of any value, but the quantities defined in user units (speed, current, position, next position, position names and following error).
These fields are updated each time motGetStatus in invoked, thus when the status sampling is running.

The section in which the named position will be retrieved from is set by the section passed in the motion definition. If no section is specified, the actual section remains valid (target defined by value). The function motSetSection allows the setting of a new section, it remains valid until a motion referencing another section is initiated. It is however possible to invoke motGetStatus specifying a different section: the DB values will continue to be updated according to the actual section, but the returned status structure will be updated according to the section set in status.posSection (the section used for the nextPos fields is the same).

2.4.9 Unit Conversion Facility

The Motor Control Module allows the user to specify positions, speeds and electric currents in common user units (e.g. meters, meters/second or ampere). Internally, such values must be known in board specific units (e.g. encoder ticks, digital binary or velocity reference). Vice versa, the boards return run-time data in specific units which must be converted into user units.

Therefore, the mot SW module provides a set of unit conversion functions, which are used internally but also accessible from application level. The unit conversion facility is designed to transform user units for position, speed and electric current into board specific values and vice versa.

The mot API provides the following routines for unit conversion:

· motPosToEnc - convert position user unit to encoder values
· motEncToPos - convert encoder values to position user unit
· motNameToEnc - convert position name to encoder values
· motEncToIndex - convert encoder values to position index
· motEncToName - convert encoder values to position name
· motNameToVel - convert speed name to encoder values
· motVelToEnc - convert speed user unit to encoder values
· motEncToVel - convert encoder values to speed user unit
· motVelToRef - convert speed user unit to velocity reference
· motRefToVel - convert velocity reference to speed user unit
· motDigToCurrent - convert digital value to current unit

An application can specify a position, speed or current argument to a mot function in any appropriate user units. A user unit is of the type motUNIT and can be seven characters long at maximum. The speed unit must contain a slash '/'. Possible units are for example:

· "deg" for a position
· "deg/sec" for a speed
· "mA" for the motor current

The function motSetDefaultUnits allows the user to set the three user units to be used for every conversion from board to user unit. For each user unit, a conversion method must be defined in the local database motor section, to be able to convert a speed/position or motor current value to a board specific value and vice versa (see section 4). The board specific values and their units are:

· for a position value: encoder ticks ("Enc")
· for a speed value: encoder ticks per ms ("Enc/ms") for a motion controller board and velocity reference value ("Ref") for an amplifier board
· for a motor current value: a digital motor current value ("Dig")

The board units are defined in motDefines.h: motBOARD_UNIT_POS, motBOARD_UNIT_SPD, motBOARD_UNIT_REF and motBOARD_UNIT_CUR, resp. for position, speed (Motion Controller and Servo Amplifier related) and current.

For each motor all necessary user unit conversion methods have to be defined in the local database motor section, point <path>:SERVER:UNIT. This point contains the unit conversion table named "unitConversion", whereby each record defines a unit conversion method. The table must contain at least 4 methods, corresponding to the four default units. The name of the unit conversion is specified in the first field and is built up in the following way

unit conversion name = <from unit>To<to unit>

So, for example, the first field of the record specifying the unit conversion "deg" to "encoder ticks" (Enc) contains "degToEnc".

Thus for each user unit to be used for motions, the following unit conversions must be specified in the unit conversion table.

· for a position user unit
· <user unit>ToEnc (e.g. "degToEnc")
· for a speed user unit
· <user unit>ToEnc/ms (e.g. "deg/secToEnc/ms")
· <user unit>ToRef (e.g. "m/sToRef")
· for a user unit of the motor current
· <user unit>ToDig (e.g. "mAToDig")

Three methods for conversion are available:

· motLINEAR linear conversion

two parameters (slope and offset) define the conversion formula

· motINTERPOLATION linear interpolation

a vector of 50 pairs of coordinates (x,y) defines the domain of conversion.

the point coordinate x (or y) greater than or equal to the origin value x (or y) is searched, the interpolation is performed linearily between this point and its predecessor.
· motEXTERN by a user function (see 2.4.12)

Any position, speed or motor current is specified by a motMETRIC data structure containing

· the value <structure>.value (vltDOUBLE)
· the unit <structure>.unit (motUNIT)

Beside the unit conversion, the functions motNameToEnc, motEncToIndex and motEncToName allow to convert a named position to an encoder value and vice versa. Each named position to be used has to be defined in the "named positions table" in the configuration section of the local database, attribute <path>:SERVER:CONF.namedPositions.

The function motNameToVel provides the facility to convert a named speed into its value in Enc/ms. Each named speed to be used has to be defined in the "named speeds table" in the configuration section of the local database, attribute <path>:SERVER:CONF.namedSpeeds.

For relative positions, it is mandatory to give the position unit either as Enc or as the default position unit.

2.4.10 Emergency Handling and Abnormal Events

Abnormal events are caused and detected by hardware components. Up to 32 events may be configured. They can be processed by software, interrupt, signal or not processed. (Literals are defined type in motDefines.h). The database attribute <path>:SERVER:CONF.events contains the description of the event handling mechanism for all the supported events.

Interrupts are generated by the hardware. As configured in the local database, the internal interrupt service routine (motsrvIsr) can be connected to the given board in order to catch the interrupts, and inform the motion monitor about the event. If the event is to be connected to an interrupt, then the board generating this interrupt (Literals for the type motBOARD_TYPE in motDefines.h) and the name of the interrupt must be supplied.

The boards return status data which may contain information about abnormal events. This includes on-limit flags, board failure status, over-temperature and over-current. These data are stored in the local database STATUS section of each motor and updated on every motGetStatus call. The motion monitor calls this routine in every polling cycle and processes abnormal event information directly.

When an abnormal event is detected, the motion monitor writes error information into the local database STATUS, releases a motWaitMove or motWaitInit immediately and terminates. The application gets informed by motWaitMove/Init returning and the appropriate motion/init status in the motor status.

In case of emergency, a supervising task can get access to a motor by attaching it in EMERGENCY mode. This mode overrides even the EXCLUSIVE mode and enables all actions for the attaching task.

2.4.11 I/O Signals

Three digital I/O signals may be handled for a motor:

· Interlock Line The status of this line may be retrieved by the function motCheckInterlock, it is also updated in the status by the function motGetStatus. If this line is active, the motor is not accessible by other applications, even if it is detached or attached in read-only mode.
(database attribute <path>:STATUS.interlock)
· Brake Status The status of this line is updated in the status by the function motGetStatus. If this line is active, the motor cannot be moved.
(database attribute <path>:STATUS.brakeClamped)
· Brake Line The brake may be clamped or unclamped by the functions motClampBrake and motUnclampBrake. The brake status of the database is updated accordingly.

These signals are handled by the digital I/O board ACROMAG. They are mapped by one I/O line per signal (fully configurable: digital I/O device, line number and logical level) as described in the attribute <path>:SERVER:CONF.signals.

2.4.12 User Function Hooks

Two types of user-defined function hooks are available:

· in the HW initialization procedure,
· for the unit conversion facility.

A user-defined function may be invoked automatically from the API while performing the HW initialization procedure or for unit conversion, if the following requirements are satisfied.

2.4.12.1 HW Initialization Procedure

An action of type motACTION_USER_DEFINED must be created in definition of the HW initialization procedure in the database (see section 2.4.3) and the following two parameters have to be set:

· userFctName is the name of the function to be invoked,
· userParList is the address of a data structure to be passed to the function. Depending on the function, this parameter may be optional and the structure and content of the parameter list is under responsibility of the user.

The interface of the user-defined initialization functions must comply the following rule:

ccsCOMPL_STAT userInitFct( void *parList, ccsERROR *error)
2.4.12.2 Unit Conversion

A conversion method of type motEXTERN must be created in the database (see section 2.4.9) and the following two parameters have to be set:

· userFctName is the name of the function to be invoked,
· userParList is the address of a data structure to be passed to the function. Depending on the function, this parameter may be optional and the structure and content of the parameter list is under responsibility of the user.

The interface of the user-defined conversion function must comply the following rule:

ccsCOMPL_STAT userConvFct( motMETRIC *from, motMETRIC *to,
void *parList, ccsERROR *error)

Note : The function must provide the conversion in both directions.
2.4.12.3 Arguments Passing Mechanism

It is possible to pass the address of a user-defined data structure to the function. The addresses of the structures must be stored into the database before the function is invoked.

The enumeration type motUSER_FCT provides the necessary literals specifying the attribute to be accessed:

motUSER_INIT for <path>:SERVER:INIT.actions, and
motUSER_CONV for <path>:SERVER:UNIT.unitConversion.

For this purpose, two functions are available motSetParListAddress, that stores the address of the user-defined data structure into the database, and motGetParListAddress, that retrieves the address from the database.

Example for the HW Initialization Procedure:

Assumed one entry of the HW Initialization procedure is set as follows in the INIT part of the database:

· Action motACTION_USER_DEFINED
· FctName "myHwInitFunction"

The function expects the address of a structure containing the two parameters handle and param, as declared in the structure defined below:

typedef struct
{
motHANDLE handle;
vltUINT16 param;
} mtPARLIST;

The User HW Init function is:

ccsCOMPL_STAT myHwInitFunction( void *parList, ccsERROR *error )
{
TparList *list = parList;
motsrvHANDLEDATA *pHandle; /* pointer to handle data */
motDESCRIPTION *desc; /* pointer to motor descriptor */

/*
* get pointer to motor descriptor
*/
pHandle = (motsrvHANDLEDATA *)(list->handle);
desc = pHandle->motDesc;

mtPrintf("\nUser Init H/W Function : motor '%s', param = %i\n",
desc->motName,list->param);
return(SUCCESS);
}

The main code invoking the HW initialization will then be as follows:

TparList myParList;
...
myParList.handle = myHandle[0];
myParList.param = (vltUINT16)tickGet();
if (motSetParListAddress(myHandle[0],motUSER_INIT,1,"myHwInitFunction",
(vltUINT32)&myParList,error) == FAILURE)
return(FAILURE);
if (motInitSw(myHandle,TRUE,error) == FAILURE)
return(FAILURE);
if (motInitHw(myHandle,TRUE,error) == FAILURE)
return(FAILURE);
if (motWaitInit(myHandle,myTimeout,&motStatus,error) == FAILURE)
return(FAILURE);
...

Important note: The user parameter list must be set to a valid address or to NULL before invoking the user function. For the user initialization function before invoking motInitHw, for the user defined unit conversion function before invoking the function. It also strongly recommended to preset these addresses after installing a motor, at the latest before initializing the motor. The address is checked for validity when set (see motSetParListAddress), NULL is always accepted.

2.4.13 External encoder support

For the case, where the encoder is not connected directly to the standard motion controller and where the CPU shall provide the encoder value, a couple of dedicated actions must be initiated so that the CPU and the Motion Controller board get synchronized.

The attributes SERVER:CONF.encoder(0,board) must be set to motCPU_BOARD

and SDL:MAC4:CFG.configValues(IEV) = 192 (0xC0).

During the SW initialization, the motion controller is configured to deliver an interrupt every 2.5ms. On the CPU, the Interrupt Service Routine motsrvIEV is connected to this interrupt. It catches the interrupts and gives a semaphore. A dedicated task is to be spawned that waits on this semaphore, reads the encoder information (not in the scope of MCM) and writes the new encoder value to the Motion Controller.

The task must be spawned before the Software Initialization has been successfully performed.

Example:

#include "mot.h"

/* Address where to read the encoder value */
vltINT32 *<mod>EncAddr = 0xF0AAAE04;

ccsCOMPL_STAT <mod>Main ( char *motor, ccsERROR *error )
{
motHANDLE handle[] = {0,0};

/* Get handle of the motor, attached in EXCLUSIVE mode */
if (motGetHandle(motor,&handle[0],error) == FAILURE)
{
/* process error */
return FAILURE;
}
/* Spawn Encoder Task */
if (taskSpawn("<mod>EncoderTask",70,0x18,20000,<mod>EncoderTask,
handle[0],0,0,0,0,0,0,0,0,0) == ERROR)
{
/* process error */
return FAILURE;
}
/* Perform SW Initialization */
if (motInitSw(handle,TRUE,error) == FAILURE)
{
/* process error */
return FAILURE;
}
/* Perform HW Initialization */
if (motInitHw(handle,TRUE,error) == FAILURE)
{
/* process error */
return FAILURE;
}
...
etc...
...
return(SUCCESS);
}

Two functions are provided that:

· retrieves the handle of the motor, attached by another task: motGetHandle
· retrieves the address of the binary semaphore: motGetSemIEV
· writes the encoder value to the Motion Controller board: motWriteEncoderValue

The motor must be attached in motExclusive mode.

Example:

#include "mot.h"

/* Address where to read the encoder value */
extern vltINT32 *<mod>EncAddr;

ccsCOMPL_STAT <mod>EncoderTask ( char *motorName )
{
motHANDLE handle;
SEM_ID encSem;
vltINT32 encVal;
ccsERROR error;

/* Register to LCC */
if (ccsInit(taskName(0),0,NULL,NULL,&error) == FAILURE)
{
/* process error */
return FAILURE;
}
/* Get handle */
if (motGetHandle(motorName,&handle,&error) == FAILURE)
{
/* process error */
return FAILURE;
}
/* Get semaphore */
if (motGetSemIEV(handle,&encSem,&error) == FAILURE)
{
/* process error */
return FAILURE;
}
/* loop forever */
for (;;)
{
if (semTake(encSem,WAIT_FOREVER) == ERROR)
{
/* process error */
return FAILURE;
}
/* read encoder value */
encVal = *(vltINT32 *)<mod>EncAddr;
/* Give the value to the motion controller */
if (motWriteEncValue(handle,encVal,&error) == FAILURE)
{
/* process error */
return FAILURE;
}
}
}

When the motor is detached or set in another operational mode than motNORMAL, the interrupt is disabled. The semaphore is deleted, when the motor is de-installed. The task should terminate before the motor is detached (device is closed, handle is not valid any more).

2.5 Application Command Interface

The Application Command Interface (ACI) is implemented in the module motci and is available as a LCU process (motServer). It is based on the LCC Command Interpreter, implementing in form of commands most of the functions of the Application Programmatic Interface (API). The ACI is built on top of the API and adds two major advantages:

· It allows applications running on WS or LCU to deal directly with motors independently on the platform.
· It provides, in combination with the CCS Engineering Interfaces ccsei, or with the MCM Engineering Interface motei engineers with tools to configure motor parameters and test motors without having to write code.

The main concepts described in section 2.4 and sub-sections apply to the ACI module as well and will not be repeated here.

2.5.1 Commands

The commands supported in the current version are listed below, they are grouped by topic.They will not be described in detail; see section 2.12 and following of the LCC Common Software User Manual [1] for further explanations.

Most of the command refer to the notion of set. A set is a group of motors that are intended to be controlled simultaneously, but which may perform independent actions. The commands that apply to a set also apply to a single motor, but the commands handling the sets (1 to 5).

Set Handling

1. CREASET Create a set of motors
2. ADDMOT Add a motor to a set of motors
3. REMMOT Remove a motor from a set
4. DELSET Delete a set
5. GMOTSET Get number and list of motors in a set or in all the sets

Motor Handling

6. INSTALL Install a motor in MCM
7. DEINST Deinstall a motor or all motors from MCM
8. MOTORS Get number and list of installed motors
9. ATTACH Attach a motor or the motor(s) of the set
10. DETACH Detach a motor or the motor(s) of a set
11. CLEAR Clear internal data structures (emergency case only)

Commands

12. CHKLOCK Check the status of the interlock line
13. CHKBRAK Check the brake status
14. CLAMP Clamp the brakes of the motors of the set
15. CONNECT Connect the power lines to the motors of the set
16. DISABLE Enable the axis of the motors of the set
17. DISCON Disconnect the power lines from the motors of the set
18. ENABLE Disable the axis of the motors of the set
19. GENSTAT Get the general status of the motors of the set
20. GETOPMO Get the actual operational mode of the motors of the set
21. HWSTAT Get the hardware status of the motors of the set
22. INITDB Restore configuration file into DB branch
23. INITHW Perform the HW initialization procedure on the motors of the set
24. INITSAM Start the status sampling for the motors of the set
25. INITSW Perform the SW initialization of the motors of the set
26. LOADPAR Load parameters to the board(s) controlling the motors of the set
27. MOTMODE Set the motion mode for the motors of the set
28. MOTPAR Retrieve the actual motion parameters of the motors of the set
29. RESETSW Reset the axis of the motors of the set
30. RESETHW Reset the boards controlling the motors of the set
31. RETRPAR Retrieve board parameters
32. SECTION Set the section for named positions handling
33. SETADDR Set the address of the user-defined data structure in the database
34. SETLIM Set the SW limits for the motors of the set
35. SETOPMO Set the operational mode for the motors of the set
36. STATUS Get the complete status of the motors of the set
37. STOPSAM Stop status sampling for the motors of the set
38. UNCLAMP Unclamp the brakes of the motors of the set
39. WAITINI Wait for HW initialization procedure completion
40. WAITMOV Wait for motion completion

Speed definition and Sequence management

41. DEFSPD Define the speed for a motion step
42. DEFSTEP Define a motion step
43. REMSTEP Remove a step in the motion sequence
44. DELSEQ Delete a motion sequence

Motion control

45. MOVEABS Perform absolute motion
46. MOVEHOM Perform motion to the Home position
47. MOVEIND Perform motion to the Index-Pulse of the encoder
48. MOVELHW Perform motion to the Lower HW limit
49. MOVEREF Perform motion to the Reference Switch
50. MOVEREL Perform relative motion
51. MOVESEQ Perform motion sequence
52. MOVESPD Perform motion by speed
53. MOVEUHW Perform motion to the Upper HW limit
54. STOPMOT Stop the motors of a set

Unit conversion

55. DEFUNIT Set the default units
56. DIG2CUR Conversion Dig To Current
57. ENC2NAM Conversion Enc To Name
58. ENC2POS Conversion Enc To Pos
59. ENC2VEL Conversion Enc ToVel
60. NAM2ENC Conversion NameTo Enc
61. NAM2VEL Conversion NameTo Vel
62. POS2ENC Conversion Pos To Enc
63. REF2VEL Conversion Ref ToVel
64. VEL2ENC Conversion Vel To Enc
65. VEL2REF Conversion Vel To Ref

Version

66. VERSION Get MCM API and ACI Versions

General commands

67. INIT See LCC Command INIT (not implemented)
68. ONLINE See LCC Command ONLINE (not implemented)
69. SELFTST See LCC Command SELFTST (not implemented)
70. STANDBY Set the motors of the set in stand-by mode (not implemented)
71. STASIM Start SIMULATION mode (not implemented)
72. OFF See LCC Command OFF (not implemented)
73. STOP See LCC Command STOP (not implemented)
74. STOSIM Stop SIMULATION mode (not implemented)
75. EXIT See LCC Command EXIT (terminates motServer)
76. KILL See LCC Command KILL (not implemented)

For detailed information on commands see section 3.2 and on-line help using ccsei/motei.

2.5.2 Input Syntax

All enumerated input parameters can be given either as numerical value (e.g. 4) or as the corresponding string (e.g. Simulation). The command interpreter is case sensitive.

The command STATUS, MOTPAR, NAM2ENC and ENC2NAM accept the enumerated parameter section, specifying the position section to search in for the position and next position names (if any). If no name is found the string "None -1" is returned. This parameter can be defaulted, the value "No Section" is then passed, the actual section is then used.

Example: The sign > prefixes a command, the actual position is assumed as 'blue' in the Maintenance section.

>STATUS DC1,,PositionName

STATUS DC1 : blue Maintenance

>STATUS DC1,UserDefined,PositionName

STATUS DC1 : None -1

>STATUS DC1,Maintenance,PositionName

STATUS DC1 : blue Maintenance

The STATUS command accepts a parameter list as third parameter. If this list is empty, the complete status is returned. Otherwise, for each requested parameter (up to 10), the status value will be returned:

Example: The sign > prefixes a command

>STATUS DC1 returns the full status,

>STATUS DC1,Observation returns the full status but the names are searched in the Observation section,

>STATUS DC1,,MotionMode returns only the motion mode.

The WAITINI and WAITMOV commands are the only commands which do not return immediately the last reply. The first reply is the command acknowledge, the following replies are returned on function completion (in the meanwhile the command interpreter is available for other commands). One reply is returned for each specified motor. If an error occurred, an additional reply is returned containing the error message. The time-outs have to be given in seconds.

Example: The sign 12> prefixes the command #12

10>CREASET X,DC1,DC2 create a set containing the motors DC1 and DC2

10 REPLY CREASET

11>INITHW X perform HW initialization procedure,

11 REPLY INITHW

12>WAITINI X,300 wait max. 300s for completion

12 REPLY WAITINI command accepted

13>STATUS DC1,,MotionMode returns only the motion mode.

13 REPLY STATUS DC1 : Speed motor DC1 is in Speed mode

14>WAITINI DC1,5 wait 5 seconds for completion for DC1 only

14 REPLY WAITINI DC1 : ...,InitStatus H/W Initialization Running,...

14 ERROR WAITINI 0x0CF30003.1 mot (motWaitInit.c)

"motERR_MULTIPLE_WAIT : motor 'DC1', handle is 5023804 - Another application is already waiting for action completion" (Serious 40)

command rejected

12 REPLY WAITINI DC1 : ...,InitStatus Initialization Done,...

12 REPLY WAITINI DC2 : ...,InitStatus Initialization Done,...

2.5.3 Output Syntax

The output syntax is built as follows:

For all the commands, but STATUS, MOTPAR, GENSTAT and HWSTAT, one reply is returned; otherwise one reply per motor is returned.

<reply>: command <motor>[,<motor>]m
<motor>: motName : <param>[,<param>]p
<param>: [parName] parValue [parUnit]

where p>=0 and m>=0.

For commands that query a single parameter (e.g. GETOPMO), the field parName is omitted. For position names, the field parValue takes the position name, the field parUnit takes the section; if no name can be found the fields parValue and parUnit take the value "None" and "-1", resp.

Example: The sign > prefixes a command

>CREASET X,DC1,DC2

>GETOPMO X

GETOPMO DC1 : Simulation,DC2 : Normal

>STATUS X,,OperationalMode MotionMode

STATUS DC1 : OperationalMode Simulation,MotionMode Direct

STATUS DC2 : OperationalMode Normal,MotionMode Direct

2.5.4 Output Format

The commands that query information from the motors accept an additional parameter (which may be ignored). This integer parameter takes the values 0 or 1 and is defaulted with 0. It influences the output format for enumerated parameters only:

0 : The returned values are given by their literals.
Example: "Simulation" for the operational mode SIMULATION. (Macro motSIMULATION_STRING).
1 : The returned valued are given by their numerical value.
Example: 4 for the operational mode SIMULATION (Macro motSIMULATION).

All literals for status parameter values are defined in motDefines.h.

The names of the status parameters are defined in motciDefines.h.

Example: The sign > prefixes a command

>SETOPMO DC1,Simulation

>SETOPMO DC2,5

>GETOPMO X

GETOPMO DC1 : Simulation,DC2 : Normal

>GETOPMO X,1

GETOPMO DC1 : 4,DC2 : 5



Quadralay Corporation
http://www.webworks.com
Voice: (512) 719-3399
Fax: (512) 719-3606
sales@webworks.com
TOC PREV NEXT INDEX