TOC PREV NEXT INDEX

Put your logo here!


3 REFERENCE

3.1 Introduction

This chapter provides a detailed description of the Maccon driver module interface to the user, namely functions, commands, include files and tools.

These functions are described in UNIX man-page format and are organized in a functional order. Below is an index of the routines in the same order.

· mconDrv to install the Maccon driver
· mconDevCreate to add a Maccon device to the driver
· open to open a channel
· close to close a channel
· ioctl to issue a control command
· mconOpen which is called by open
· mconClose which is called by close
· mconIoctl which is called by ioctl

Each of these calls returns a status code which signals the success of the call. A zero value always means "successful completion", while a negative one indicates an error. The value -1 stands for "general error" and originating in VxWorks while other values signal a specific error reason and are returned by the driver itself. Literals of all error codes can be found in the header-files lcudrvErrors.h and mconErrors.h.

3.2 Functions

As mentioned above, the Maccon driver uses the standard VxWorks I/O system calls open, close, ioctl to interface to the user. These functions are described in the following sections with respect to their special meaning in the Maccon driver context. For more general informations see the "VxWorks Programmers Guide".

3.2.1 Installation Functions

These functions are used to install the driver and devices at system start-up. They must not be invoked more than once.

3.2.2 mconDrv(3)
NAME
mconDrv - Install the MACCON driver


SYNOPSIS
#include "mcon.h"
int mconDrv ( int devices, int channels, int timeout)



DESCRIPTION
This function installs the MACCON device driver.
It is called only once at startup. It hooks up the various
I/O service calls to the diver's functions, assigns the driver number,
and adds the driver to the driver table.

devices - number of supported devices by the driver
channels - number of channels that can be simultanously opened
timeout - access timeout value (in ticks) or NO_WAIT or WAIT_FOREVER



RETURN VALUES
lcudrvOK - driver successfully installed
lcudrvERROR_DRIVER_EXISTS - the driver is already installed
lcudrvERROR_NO_MEMORY - there is not enough memory for dynamic
data structures
lcudrvERROR_INVALID_ARGUMENT - the value of one of the parameters is
out of range


CAUTION
'timeout' should always be > 0 and effectively around 0.1 - 1 second.
This value is applied for semaphore-waits, the total command execution
time is additionally checked after completion with '4 * timeout'.
NO_WAIT and WAIT_FOREVER should only be used for test purposes.


SEE ALSO
mconDevCreate(3), mconOpen(3), mconClose(3), mconIoctl(3),
lcudrvInitDCT(3),
iosLib(1), iosDrvInstall(2), open(2), close(2), ioctl(2)




- - - - - -
Last change: 19/05/95-16:19

3.2.3 mconDevCreate(3)
NAME
mconDevCreate - Add a device to the MACCON driver


SYNOPSIS
#include "mcon.h"
STATUS mconDevCreate (const char *devName,
const void *baseAddrA24,
int devNumber,
int backplaneAddr,
u_char vectorOutputNbr,
u_char vectorNbrDriveFault,
u_char vectorNbrMotionEnd,
u_char vectorNbrEmergencyStop,
int intrLevel
int mac4Version)



DESCRIPTION
This function is called at startup once for each device (i.e. each
axis controlled by a MACCON controller) to be installed.
It adds a device to the driver, making it available for subsequent open
operations.

devName - device name (must be "/mconX" X>=0, e.g. "/mcon0")

baseAddrA24 - VMEbus base address of the board in the A24 standard
address space [0x00000000..0x00ffffff]
(upper 8 address-bits are ignored, but should be zero)
0xffffffff: map board space into main memory for simulation

devNumber - number of board channel used for the device [1..4]

backplaneAddr - backplane address (jumpered board number code)

vectorOutputNbr - interrupt vector number of output
vectorNbrDriveFault - interrupt vector number of drive fault
vectorNbrMotionEnd - interrupt vector number of motion end
vectorNbrEmergencyStop - interrupt vector number of emergency stop

intrLevel - interrupt-level used for the device [1..7]

mac4Version - firmware and hardware version of the MAC4 controller,
'0' means don't care

Note: See CAUTION for interrupt vectors, '0' means 'no interrupt'.


RETURN VALUES
lcudrvOK - successful completion
lcudrvERROR - there is a general VxWorks I/O error

lcudrvERROR_NO_DRIVER - MACCON driver not installed
lcudrvERROR_INVALID_DEVICE - invalid device name or device number
lcudrvERROR_DEVICE_EXISTS - device already installed
lcudrvERROR_NO_SEMAPHORE - failed to create semaphore
lcudrvERROR_NO_MEMORY - failed to create object in memory
lcudrvERROR_TIMEOUT - failed to take semaphore before timeout
lcudrvERROR_INVALID_ARGUMENT - Maccon controller baseaddress,
version or backplane-address not valid

mconERROR_START_TIMER - failed to start VxWorks watchdog timer
mconERROR_STOP_TIMER - failed to stop VxWorks watchdog timer
mconERROR_QUEUE_FULL - failed to send command to the controller
mconERROR_SYNC_TIMEOUT - failed to take synchr.-semaphore, i.e.
no "answer ready"-intr. before timeout
mconERROR_NO_REPLY - failed to read reply from queue although
intr. indicates that reply is available
mconERROR_WRONG_REPLY - reply contains not the same axis number
as the command (maybe interrupt vectors
are not properly assigned)

mconERROR_STATUS_INVALID_AXIS - controller detected invalid axis number
mconERROR_STATUS_SYNTAX - controller detected invalid command no.
mconERROR_STATUS_PARAM_RANGE - controller detected invalid parameter,
e.g. value/position out of limits
mconERROR_STATUS_UNEXP_COMMAND -controller detected unexpected command,
e.g. wrong sequence in initialisation
mconERROR_STATUS_FOLLOWING_ERROR - max. following error exceeded
mconERROR_STATUS_ENCODER_FAULT - read encoder value out of limits
mconERROR_STATUS_DRIVE_FAULT - drive-fault signal is active,
e.g. amplifier not in normal-mode
mconERROR_STATUS_COMM - communication error, i.e.
controller watchdog timeout



CAUTION
Access protection semaphores for critical data are created on a
per-board basis, i.e. only one device per board can be accessed at a
given time. If a command is specified as 'protected' in the cmd-table,
then the access is locked until the reply for this command is issued,
otherwise multiple commands can be entered in the input-queue.
Accesses to the queue itself are always protected.
Synchronisation semaphores are created seperately for each channel and
are connected to the "answer ready" interrupt of the channel.

The interrupt-vector of EmergencyStop is common to all devices on one
controller-board. Therefore either the vectors of all devices must be
set equal or only the vector of the first device must be set to a
non-zero value and the rest to zero (then the other devices effectively
use the same vector as the first device)


SEE ALSO
mconDrv(3), mconOpen(3), mconClose(3), mconIoctl(3),
iosLib(1), iosDevAdd(2), open(2), close(2), ioctl(2)




- - - - - -
Last change: 19/05/95-16:19

3.2.4 VxWorks System Calls

The following functions are used after driver and device installation to open and close a channel to a specific device and send commands to it. They are part of the VxWorks I/O-system and route the call to the respective mcon routine described in section 3.2.8.1

3.2.5 open(2)
NAME
open - open a channel to a Maccon device

SYNOPSIS
#include "mcon.h"
int open (char *deviceName, int openMode, int *status)

DESCRIPTION
This operation opens the device corresponding to deviceName, in read-only mode or in one of the three read-write modes described below. The read accesses are always granted for any open modes.
· deviceName specifies the device (e.g. "/mcon0").
· openMode can be :
· lcudrvOPEN_READONLY
Read only mode.
· lcudrvOPEN_SHARED
Shareable read and write mode. Write access is granted to a defined number of processes to use this open mode. Exceeding this number or requesting this mode for a device already opened in Exclusive write mode returns an error.
· lcudrvOPEN_EXCLUSIVE
Exclusive read and write mode. Write access is granted to the process using this open mode. Requesting this mode for a device already opened in Exclusive or Shareable write mode returns an error.
· lcudrvOPEN_TEST
Test read and write mode. Write access is granted to the process using this open mode regardless of the status of the device. Requesting this mode for a device already opened in Test mode returns an error.
RETURN VALUES
· A positive file descriptor number, which shall be used for subsequent close and ioctl operations.
· A value of -1 signals a general error. The specific error reason is provided in the argument status which can be:
· lcudrvERROR_INVALID_DEVICE
If the specified device name is invalid.
· lcudrvERROR_INVALID_OPEN_MODE
If open mode is invalid.
· lcudrvERROR_NO_CHANNEL
No more channel is available.
· lcudrvERROR_ACCESS_CONFLICT
The requested open mode is conflicting with the open modes of already existing channels. This error is caused by one of the following reasons:
Shared mode requested and device already open in Exclusive mode.
Exclusive mode requested and the device is already open in Exclusive and Shared mode.
Test mode requested and the device is already open in Test mode.
· The zero value should never be returned.
EXAMPLE
int fd;
...
fd = open ("/mcon0", lcudrvOPEN_READONLY);
if (fd < = 0)
{
/* error process */
}
else
{
/* normal process */
}
CAUTIONS
· Device names shall not be longer than 15 characters. They shall be defined by use of the function mconDevCreate at start-up.
· The number of 'shared' channels for each device is currently limited to 20.
· This function is not queued by the driver, it always returns with the file descriptor or an error type.
· The returned file descriptor can be shared by several applications.
· Applications can have the same device opened several times, using different file descriptors. Furthermore, open modes can be mixed according to the rules previously described.
· As only one process can open a device for Exclusive write mode at any one time, and the number of channels is limited, applications should issue a close call if no action on the device has to be performed.
VxWorks
· The VxWorks include file "configAll.h" contains two literals used by iosInit function: NUM_DRIVERS which defines the maximum number of drivers allowed, and NUM_FILES, the maximum number of opened files. They are respectively defined as 20 and 50.
· The VxWorks command "iosDrvShow" shows all drivers of the system, and their basic i/o entry_points. The commands "iosFdShow" shows all currently used file descriptors, and "iosDevShow" (or "devs") all devices.
3.2.6 close(2)
NAME
close - close a channel to a Maccon device

SYNOPSIS
#include "mcon.h"
int close (int fileDescriptor)

DESCRIPTION
This operation closes a channel to an opened device, and frees the file descriptor. fileDescriptor must correspond to one of those obtained previously by an open call.

RETURN VALUES
· lcudrvOK if successfully done.
· lcudrvERROR if the file descriptor does not exist (e.g. device already closed).

EXAMPLE
int fd;
int closeError;
...
fd = open ("/mcon0", lcudrvOPEN_TEST);
...
closeError = close (fd);
if (closeError != lcudrvOK)
{
/* error process */
}
else
{
/* normal process */
}

CAUTIONS
This function is not queued by the driver, it always returns one of the above two states.
3.2.7 ioctl(2)
NAME
ioctl - send an ioctl command to a Maccon device

SYNOPSIS
#include "mcon.h"
int ioctl (int fileDescriptor, int command, void *argument)

DESCRIPTION
This function commands the driver to perform the specified operation on the device. The commands are divided into read and write commands. Read commands are allowed in each open mode, while write commands will be rejected if the channel was not previously opened in Shared, Exclusive or Test mode.
· fileDescriptor must correspond to one of those obtained previously by an open operation.
· command is an integer identifying a Maccon command to be sent to the driver. The values identifying a command are defined in the include file mconCommands.h.
· argument is the address of the command argument, or NULL if no argument is used. For 'Write' commands, argument contains the values to be written, for 'Read' commands, argument contains the value read.
Arguments, when used, can only be an integer. Exceptions are for the commands to connect an interrupt service routine to emergency stop, drive fault or motion end event, where argument shall be a pointer of the structure mconCONFIG_INT.

RETURN VALUES
· lcudrvOK if the command is successfully transmitted and performed by the device.
· lcudrvERROR_ACCESS_CONFLICT if the write command can not be executed by use of a file descriptor previously obtained with a read-only open mode.
· lcudrvERROR_INVALID_COMMAND if command code is invalid.
· lcudrvERROR_TIMEOUT if access protection timed out.
· lcudrvERROR_CHANNEL_NOT_OPEN if the requested channel is not opened.
· Other driver specific values returned by the driver are described for each ioctl command in section 3.3 and a full description of errors can be found in chapter 5.

EXAMPLE
int fd;
int arg;
int ioctlError;
...
fd = open ("/mcon0", lcudrvOPEN_TEST);
...
arg = 30;
ioctlError = ioctl (fd, mconCMD_SET_TIMOUT_TICK, &arg);
if (ioctlError != lcudrvOK)
{
/* error process */
}
else
{
/* normal process */
}

CAUTIONS
· This function is protected by semaphores, and commands are queued by application priorities rather than by First-in First-out. The timeout value is applied for tasks which are blocked on a semaphore. This delay, expressed in ticks, is initialized at start-up, and can be set/got at run-time by two additional commands: set/get timeout.
· A VxWorks-timer is implemented to check the permissible maximum execution delay of a command. This delay is derived from the above timeout-value. An error is returned when the execution-time of a command was longer than the delay (see section 3.2.1).

3.2.8 Interface Functions

These function represent the interface between the VxWorks I/O system calls open(), close() and ioctl() to the controller-hardware. Therefore they are not directly used by application programs.

3.2.9 mconOpen(3)
NAME
mconOpen - Open a channel to a MACCON device


SYNOPSIS
#include "mcon.h"
int mconOpen ( void *device, char *remainder, int mode, int *status )



DESCRIPTION
This function is installed in the I/O-system of VxWorks and is
called via open() when a channel to a MACCON device shall be opened.
It represents an interface routine between the MACCON driver
routines and the general lcudrv driver routines.

device - pointer to the descriptor of the required device
remainder - remainder of the device name; should be blank
mode - open mode, specifiying the access to the device
status - pointer to the returned status value (NULL: not returned)


RETURN VALUES
channel number (> 0) - successful completion
lcudrvERROR - error (detailed in '*status')

In '*status':
lcudrvERROR_INVALID_DEVICE - remainder not blank/invalid name
lcudrvERROR_ACCESS_CONFLICT - open mode not consistent
lcudrvERROR_NO_CHANNEL - no more channel available
lcudrvERROR_INVALID_OPEN_MODE - unknown open mode


SEE ALSO
mconClose(3), mconIoctl(3),
lcudrvOpen(3),
open(2), close(2), ioctl(2)




- - - - - -
Last change: 19/05/95-16:19

3.2.10 mconClose(3)
NAME
mconClose - Close a channel to a MACCON device


SYNOPSIS
#include "mcon.h"
int mconClose ( int channel )



DESCRIPTION
This routine is called when a channel of a MACCON device shall be
closed. It represents a interface routine between the special
MACCON driver routines and the general lcudrv driver routines.

channel - channel to be closed


RETURN VALUES
lcudrvOK - successful completion
lcudrvERROR_INVALID_ARGUMENT - invalid channel number
lcudrvERROR_NO_CHANNEL - channel was not open


SEE ALSO
mconOpen(3), mconIoctl(3),
lcudrvClose(3),
open(2), close(2), ioctl(2)




- - - - - -
Last change: 19/05/95-16:19

3.2.11 mconIoctl(3)
NAME
mconIoctl - Send a control command to a MACCON device


SYNOPSIS
#include "mcon.h"
int mconIoctl ( int channel, int command, void *argument )



DESCRIPTION
This routine is called when a control command is send to a MACCON
device via ioctl(). It validates the command request, performs a
semphore protection if required and calls the command procedure to
be executed.

channel - channel number as returned by the mconOpen() function
command - number identifying the operation to be performed by the
driver (as defined in 'mconCommands.h')
argument - address of the command argument or NULL if no argument is
used. For commands needing multiple arguments it is the
address of a specific data structure.


RETURN VALUES
lcudrvOK - successful completion
lcudrvERROR_INVALID_ARGUMENT - invalid channel number
lcudrvERROR_CHANNEL_NOT_OPEN - channel was not open
lcudrvERROR_INVALID_COMMAND - command code invalid
lcudrvERROR_ACCESS_CONFLICT - insufficient access rights
lcudrvERROR_TIMEOUT - failed to take semaphore before timeout

mconERROR_START_TIMER - failed to start VxWorks watchdog timer
mconERROR_STOP_TIMER - failed to stop VxWorks watchdog timer
mconERROR_QUEUE_FULL - failed to send command to the controller
mconERROR_SYNC_TIMEOUT - failed to take synchr.-semaphore, i.e.
no "answer ready"-intr. before timeout
mconERROR_NO_REPLY - failed to read reply from queue although
intr. indicates that reply is available
mconERROR_WRONG_REPLY - reply contains not the same axis number
as the command (maybe interrupt vectors
are not properly assigned)

mconERROR_STATUS_INVALID_AXIS - controller detected invalid axis number
mconERROR_STATUS_SYNTAX - controller detected invalid command nr.
mconERROR_STATUS_PARAM_RANGE - controller detected invalid parameter,
e.g. value/position out of limits
mconERROR_STATUS_UNEXP_COMMAND -controller detected unexpected command,
e.g. wrong sequence in initialisation
mconERROR_STATUS_FOLLOWING_ERROR - max. following error exceeded
mconERROR_STATUS_ENCODER_FAULT - read encoder value out of limits
mconERROR_STATUS_DRIVE_FAULT - drive-fault signal is active,
e.g. amplifier not in normal-mode
mconERROR_STATUS_COMM - communication error, i.e.
controller watchdog timeout



CAUTION
Automatic EXECUTE:
For some commands there is an EXECUTE-command appended, to activate
the settings automatically (see Maccon User Manual).

Automatic CLEAR:
If one of the 'mconERROR_STATUS_...' codes is returned, then there was
an automatically issued CLEAR-command before, to acknowledge the
error in the controller. The status flags are therefore cleared.
Any error during the CLEAR-command itself is discarded.



BUGS
Some command numbers may be processed inside the ioctl() function of
VxWorks. For these numbers the driver will be bypassed!
In VxWorks version 5.1.1, at least the command 'FIOGETNAME' (number 18)
is handled in this way. There might be differences for other versions.
All conflicting command numbers must be translated.



SEE ALSO
mconOpen(3), mconClose(3)
lcudrvCheckChannel(3),
open(2), close(2), ioctl(2)




- - - - - -
Last change: 19/05/95-16:19

3.3 Ioctl Control Commands

This section describes all the control commands which can be invoked by use of the VxWorks ioctl() function (see section 3.2.7). The parameter command specifies which operation has to be performed by the driver while the parameter argument passes the address of an argument to the command handler. In cases where multiple arguments are needed the address of a structure which contains those is passed.

All command literals and argument data structures are defined in the include file mconCommands.h. Read commands are allowed in each open mode, while Write commands are only allowed in Shared, Exclusive or Test mode.

This section lists all control commands supported by the driver. The list also contains a short description of each command, its literal and the possible special error codes sent in case of an error. Default, maximum and minimum values for parameters are stated in the controller manuals [2]. These values are in many cases different for each controller version.

Before a command is executed by the driver, the access rights and several states of the Maccon board are checked. Also a timer is started before and stopped after command execution to control the temporal run down of command execution. In case of an error the command is rejected.

For all commands passed to the controller board the following return codes are possible:

· mconERROR_STATUS_INVALID_AXIS
Invalid axis number passed to the controller
· mconERROR_STATUS_SYNTAX
Syntax error (invalid command) is indicated by the controller board
· mconERROR_STATUS_PARAM_RANGE
An invalid parameter was detected by the controller
· mconERROR_STATUS_UNEXP_COMMAND
The controller detected an invalid sequence of commands
· mconERROR_STATUS_FOLLOWING_ERROR
The controller detected a following error
· mconERROR_STATUS_ENCODER_FAULT
The controller detected a fault in an external encoder
· mconERROR_STATUS_DRIVE_FAULT
The controller detected that the drive-fault signal is active (e.g. amplifier not in normal-mode)
· mconERROR_STATUS_COMM
The controller watchdog detected a communication error
· mconERROR_START_TIMER
Command timer cannot be started
· mconERROR_STOP_TIMER
Currently running timer cannot be cancelled
· mconERROR_SYNC_TIMEOUT
Time-out on waiting for reply from the controller
· mconERROR_COMMAND_TIMEOUT
Time-out detected after command execution has completed
· mconERROR_QUEUE_FULL
A command could not be passed to the controller because the queue is full
· mconERROR_NO_REPLY
The reply from the controller cannot be fetched from the queue
· mconERROR_WRONG_REPLY
The reply from the controller contains a wrong axis number

See chapter 5 for a complete list. For read-commands the returned value is in general undefined if an error is reported. Only in case of the error-codes beginning with mconERROR_STATUS_ the user-status (see page 51) is returned instead of the requested value.

3.3.1 General Commands

· Clear Command
To acknowledge an error condition in the controller and to clear all status error flags. It is automatically appended by the driver to an issued command if a status error occurs.
Command literal: mconCMD_CLEAR
Argument: none
· Execute Command
To start a positioning or change of mode or to activate written parameters. It is automatically appended by the driver to all "Set ... Mode" commands. See section 5.2 for details.
Command literal: mconCMD_EXECUTE
Argument: none
· Enable axis
The axis will be enabled and the control loop activated.
Command literal: mconCMD_MODE_ENABLE_AXIS
Argument: none
· Disable axis
The axis will be disabled and the analog output of the axis will have the voltage zero.
Command literal: mconCMD_MODE_DISABLE_AXIS
Argument: none
· Reset all devices
This command will reset all devices on the board and is equivalent to a hardware reset to the controller. This command should be used with care, as not only this device (axis) but also the other devices controlled by the board, are reset. All controller data will be lost, only parameters necessary for basic communication will be re-initialized.
The execution time for the Reset is longer than for other commands, therefore a timeout error will normally occur if the timeout-value specified at driver-installation is less than needed for this command. The error can then be avoided by increasing the timeout-value temporarily (see 3.3.20 on page 53).
Command literal: mconCMD_RESET
Argument: none
· Initialize controller
This command must be given after configuration of controller parameters.
· Command literal: mconCMD_INIT
Argument: none
· Deinitialize controller
This command must be given before modifying system specific parameters, see [2], if the axis is already initialized.
Command literal: mconCMD_DEINIT
Argument: none
· Switch "On-Fly" on
"On-Fly" is switched on by default. See [2] for a description of this operation-modus.
Command literal: mconCMD_FLY_MODE_ON
Argument: none
· Switch "On-Fly" off
Command literal: mconCMD_FLY_MODE_OFF
Argument: none

3.3.2 Speed and Brake Mode

· Set speed mode
In this mode the axis will accelerate with the defined acceleration ramp (given by the parameter <sa>) until it reaches the maximum speed defined by the parameter <sv>. The axis will continue until it is stopped by a command or reaches the limit- or stop-switch.
Command literal: mconCMD_MODE_SPEED
Argument: none
· Set brake mode
An axis running in speed mode will start braking with the defined deceleration ramp (defined by <sd>) until the axis has stopped.
Command literal: mconCMD_MODE_BRAKE
Argument: none
· Write speed mode acceleration parameter <sa>
Command literal: mconCMD_WRITE_SPEED_MODE_ACCEL
Argument: pointer to an integer containing the value to be set
· Read speed mode acceleration parameter <sa>
Command literal: mconCMD_READ_SPEED_MODE_ACCEL
Argument: pointer to an integer
· Write speed mode maximum velocity parameter <sv>
Command literal: mconCMD_WRITE_SPEED_MODE_SPEED
Argument: pointer to an integer containing the value to be set
· Read speed mode maximum velocity parameter <sv>
Command literal: mconCMD_READ_SPEED_MODE_SPEED
Argument: pointer to an integer
· Write speed mode deceleration parameter <sd>
Command literal: mconCMD_WRITE_SPEED_MODE_DECEL
Argument: pointer to an integer containing the value to be set
· Read speed mode deceleration parameter <sd>
Command literal: mconCMD_READ_SPEED_MODE_DECEL
Argument: pointer to an integer

3.3.3 Positioning Mode

· Set positioning mode
In this mode the axis will move to the position given by the parameter <ap> with a trapezoidal profile. Acceleration is defined by the parameter <pa>, the speed by the parameter <pv> and the deceleration by the parameter <pd>. The absolute position can be given absolute or relative.
Command literal: mconCMD_MODE_POSITIONING
Argument: none
· Write positioning mode acceleration parameter <pa>
Command literal: mconCMD_WRITE_POS_ACCEL
Argument: pointer to an integer containing the value to be set
· Read positioning mode acceleration parameter <pa>
Command literal: mconCMD_READ_POS_ACCEL
Argument: pointer to an integer
· Write positioning mode velocity parameter <pv>
Command literal: mconCMD_WRITE_POS_SPEED
Argument: pointer to an integer containing the value to be set
· Read positioning mode velocity parameter <pv>
Command literal: mconCMD_READ_POS_SPEED
Argument: pointer to an integer
· Write positioning mode deceleration parameter <pd>
Command literal: mconCMD_WRITE_POS_DECEL
Argument: pointer to an integer containing the value to be set
· Read positioning mode deceleration parameter <pd>
Command literal: mconCMD_READ_POS_DECEL
Argument: pointer to an integer
· Write positioning mode absolute position parameter <ap>
Command literal (absolute): mconCMD_WRITE_ABSOLUTE_POS
Command literal (relative): mconCMD_WRITE_RELATIVE_POS
Argument: pointer to an integer containing the value to be set
· Read positioning mode absolute position parameter <ap>
Command literal: mconCMD_READ_ABSOLUTE_POS
Argument: pointer to an integer

3.3.4 Search Index Coarse Mode

This mode is not available for the MAC4-SSI controller version.

· Set search index coarse mode
The axis will search for the next index pulse. The acceleration, speed and deceleration is defined by the parameters <ca>, <cv> resp. <cd>. The axis will stop when the index pulse is found. The accuracy depends on the speed selected. Compare also 'Search index mode'.
Command literal: mconCMD_MODE_SEARCH_INDEX_COA_ADJUST
Argument: none
· Write velocity parameter <cv>
Command literal: mconCMD_WRITE_COARSE_SPEED
Argument: pointer to an integer containing the value to be set
· Read velocity parameter <cv>
Command literal: mconCMD_READ_COARSE_SPEED
Argument: pointer to an integer
· Write acceleration parameter <ca>
Command literal: mconCMD_WRITE_COARSE_ACCEL
Argument: pointer to an integer containing the value to be set
· Read acceleration parameter <ca>
Command literal: mconCMD_READ_COARSE_ACCEL
Argument: pointer to an integer
· Write deceleration parameter <cd>
Command literal: mconCMD_WRITE_COARSE_DECEL
Argument: pointer to an integer containing the value to be set
· Read deceleration parameter <cd>
Command literal: mconCMD_READ_COARSE_DECEL
Argument: pointer to an integer

3.3.5 Search Index Mode

This mode is not available for the MAC4-SSI controller version.

· Set search index mode
The axis will search for the next index pulse from the incremental encoder. The acceleration, speed and deceleration is defined by the parameters <ia>, <iv> resp. <id>. In the last phase the speed defined by <lv> is used (`low-velocity', see page 48). The position of the index pulse will be determined with an accuracy depending on the value of <lv>.
Command literal: mconCMD_MODE_SEARCH_INDEX
Argument: none
· Write velocity parameter <iv>
Command literal: mconCMD_WRITE_INDEX_SPEED
Argument: pointer to an integer containing the value to be set
· Read velocity parameter <iv>
Command literal: mconCMD_READ_INDEX_SPEED
Argument: pointer to an integer
· Write acceleration parameter <ia>
Command literal: mconCMD_WRITE_INDEX_ACCEL
Argument: pointer to an integer containing the value to be set
· Read acceleration parameter <ia>
Command literal: mconCMD_READ_INDEX_ACCEL
Argument: pointer to an integer
· Write deceleration parameter <id>
Command literal: mconCMD_WRITE_INDEX_DECEL
Argument: pointer to an integer containing the value to be set
· Read deceleration parameter <id>
Command literal: mconCMD_READ_INDEX_DECEL
Argument: pointer to an integer

3.3.6 Home Mode

This mode is not available for the MAC4-SSI controller version.

· Set home mode
The axis moves to the reference switch. The acceleration, speed and deceleration is defined by the parameters <ha>, <hv> resp. <hd>. In the last phase the speed defined by <lv> is used (`low-velocity', see page 48).
Command literal: mconCMD_MODE_HOME
Argument: none
· Write velocity parameter <hv>
Command literal: mconCMD_WRITE_HOME_SPEED
Argument: pointer to an integer containing the value to be set
· Read velocity parameter <hv>
Command literal: mconCMD_READ_HOME_SPEED
Argument: pointer to an integer
· Write acceleration parameter <ha>
Command literal: mconCMD_WRITE_HOME_ACCEL
Argument: pointer to an integer containing the value to be set
· Read acceleration parameter <ha>
Command literal: mconCMD_READ_HOME_ACCEL
Argument: pointer to an integer
· Write deceleration parameter <hd>
Command literal: mconCMD_WRITE_HOME_DECEL
Argument: pointer to an integer containing the value to be set
· Read deceleration parameter <hd>
Command literal: mconCMD_READ_HOME_DECEL
Argument: pointer to an integer

3.3.7 Find Edge Mode

· Set find edge mode
The axis will go to a predefined reference. The speed and for search reference switch the direction is defined by <fv>, acceleration and deceleration by <fa> resp. <fd>. For the last phase <lv> is used (`low-velocity', see page 48). The parameter <dl> defines the destination to search:
0: search reference switch
1: search lower limit
2: search upper limit
Command literal: mconCMD_MODE_FIND_EDGE
Argument: none
· Write define limit switch parameter <dl>
Command literal: mconCMD_WRITE_DEFINE_LIMIT
Argument: pointer to an integer containing the value to be set
· Read define limit switch parameter <dl>
Command literal: mconCMD_READ_DEFINE_LIMIT
Argument: pointer to an integer
· Write velocity parameter <fv>
Command literal: mconCMD_WRITE_FIND_EDGE_SPEED
Argument: pointer to an integer containing the value to be set
· Read velocity parameter <fv>
Command literal: mconCMD_READ_FIND_EDGE_SPEED
Argument: pointer to an integer
· Write acceleration parameter <fa>
Command literal: mconCMD_WRITE_FIND_EDGE_ACCEL
Argument: pointer to an integer containing the value to be set
· Read acceleration parameter <fa>
Command literal: mconCMD_READ_FIND_EDGE_ACCEL
Argument: pointer to an integer
· Write deceleration parameter <fd>
Command literal: mconCMD_WRITE_FIND_EDGE_DECEL
Argument: pointer to an integer containing the value to be set
· Read deceleration parameter <fd>
Command literal: mconCMD_READ_FIND_EDGE_DECEL
Argument: pointer to an integer

3.3.8 Velocity Tracking Mode

The parameter <vt> specifies the velocity which the axis shall reach within the next sampling period. Can be used for user-defined speed profiles.
· Set veleocity tracking mode
Command literal: mconCMD_SPEED_TRACKING
Argument: none
· Write velocity tracking parameter <vt>
Command literal: mconCMD_WRITE_TRACK_SPEED
Argument: pointer to an integer containing the value to be set
· Read velocity tracking parameter <vt>
Command literal: mconCMD_READ_TRACK_SPEED
Argument: pointer to an integer

3.3.9 Position Tracking Mode

The parameter <at> specifies the position which the axis shall reach within the next sampling period.
· Set position tracking mode
Command literal: mconCMD_POSITION_TRACKING
Argument: none
· Write absolute tracking parameter <at>
Command literal (absolute): mconCMD_WRITE_TRACK_POS
Command literal (relative): mconCMD_WRITE_TRACK_POS_REL
Argument: pointer to an integer containing the value to be set
· Read absolute tracking parameter <at>
Command literal: mconCMD_READ_TRACK_POS
Argument: pointer to an integer

3.3.10 Test Mode

The parameter <da> specifies the value written into the DAC in test mode.
· Set test mode
Command literal: mconCMD_SET_TEST_MODE
Argument: none
· Write DAC-offset parameter <da>
Command literal: mconCMD_WRITE_DAC_OFFSET
Argument: pointer to an integer containing the value to be set
· Read DAC-offset parameter <da>
Command literal: mconCMD_READ_DAC_OFFSET
Argument: pointer to an integer

3.3.11 Axis Configuration

· Write axis type parameter <sh>
Three axis type values are defined for this parameter:
0: OFF
1: linear (default)
2: circular
3: circular optimized (see corresponding controller manual)
Command literal: mconCMD_WRITE_AXIS_TYPE
Argument: pointer to an integer containing the value to be set
· Read axis type parameter <sh>
Command literal: mconCMD_READ_AXIS_TYPE
Argument: pointer to an integer

A linear axis is limited by software in positive and negative direction by values defined in parameters <lp> and <ln>, with <lp> > <ln>.

· Write positive limit parameter <lp>
Command literal: mconCMD_WRITE_MAX_POSITIVE
Argument: pointer to an integer containing the value to be set
· Read positive limit parameter <lp>
Command literal: mconCMD_READ_MAX_POSITIVE
Argument: pointer to an integer
· Write negative limit parameter <ln>
Command literal: mconCMD_WRITE_MAX_NEGATIVE
Argument: pointer to an integer containing the value to be set
· Read negative limit parameter <ln>
Command literal: mconCMD_READ_MAX_NEGATIVE
Argument: pointer to an integer

A circular axis does not have a positive or negative software limit. However, the number of increments for the total range is defined by the parameter <cr>.

· Write circular range parameter <cr>
Command literal: mconCMD_WRITE_CIRC_RANGE
Argument: pointer to an integer containing the value to be set
· Read circular range parameter <cr>
Command literal: mconCMD_READ_CIRC_RANGE
Argument: pointer to an integer

3.3.12 Encoder Configuration

· Write encoder type parameter <et>
The values for this parameter are defined differently for each controller version. See the corresponding controller manual [2],.
Command literal: mconCMD_WRITE_ENC_TYPE
Argument: pointer to an integer containing the value to be set
· Read encoder type parameter <et>
Command literal: mconCMD_READ_ENC_TYPE
Argument: pointer to an integer
· Write encoder address parameter <ea>
This value - if not default - defines the controller-internal address where the actual encoder position shall be read, instead of using the on-board encoder interface.
Command literal: mconCMD_WRITE_EXT_ENCODER_ADDR
Argument: pointer to an integer containing the value to be set
· Read encoder address parameter <ea>
Command literal: mconCMD_READ_EXT_ENCODER_ADDR
Argument: pointer to an integer
· Write encoder bits parameter <eb>
Command literal: mconCMD_WRITE_ENC_BITS
Argument: pointer to an integer containing the value to be set
· Read encoder bits parameter <eb>
Command literal: mconCMD_READ_ENC_BITS
Argument: pointer to an integer
· Write encoder offset parameter <eo>
Command literal: mconCMD_WRITE_ENC_OFFSET
Argument: pointer to an integer containing the value to be set
· Read encoder offset parameter <eo>
Command literal: mconCMD_READ_ENC_OFFSET
Argument: pointer to an integer
· Write encoder counts parameter <ec>
Command literal: mconCMD_WRITE_ENC_COUNTS
Argument: pointer to an integer containing the value to be set
· Read encoder counts parameter <ec>
Command literal: mconCMD_READ_ENC_COUNTS
Argument: pointer to an integer

Only for MAC4-SSI:

· Write encoder shift counter parameter <sc>
Command literal: mconCMD_WRITE_ENC_SHIFT
Argument: pointer to an integer containing the value to be set
· Read encoder shift counter parameter <sc>
Command literal: mconCMD_READ_ENC_SHIFT
Argument: pointer to an integer

Only for MAC4-STP:

· Write encoder steps parameter <es>
Command literal: mconCMD_WRITE_ENC_STEPS
Argument: pointer to an integer containing the value to be set
· Read encoder steps parameter <es>
Command literal: mconCMD_READ_ENC_STEPS
Argument: pointer to an integer

3.3.13 Control Loop Configuration

Information about the control-loop can be found in [2]. Not applicable to the MAC4-STP controller version.

· Set proportional gain factor parameter <ga>
Set proportional gain factor of the PID filter.
Command literal: mconCMD_WRITE_PROPOR_GAIN
Argument: pointer to an integer containing the value to be set
· Set zero factor parameter <ze>
Set the zero of the closed loop filter.
Command literal: mconCMD_WRITE_ZERO_FACTOR
Argument: pointer to an integer containing the value to be set
· Set integral gain factor parameter <ki>
Set the integration factor for the PID filter
Command literal: mconCMD_WRITE_INTEGRATION_GAIN
Argument: pointer to an integer containing the value to be set
· Set integral gain shift count parameter <ki_sc>
Set the number of bits for right-shift operation of <ki>.
Command literal: mconCMD_WRITE_INT_GAIN_SHIFT
Argument: pointer to an integer containing the value to be set
· Set pole factor parameter <po>
Set the pole of the closed loop filter.
Command literal: mconCMD_WRITE_POLE_FACTOR
Argument: pointer to an integer containing the value to be set

· Get the proportional gain factor parameter <ga>
This command returns the value of the proportional gain factor.
Command literal: mconCMD_READ_PROPOR_GAIN
Argument: pointer to an integer value
· Get the zero factor parameter <ze>
This command returns the value of the zero factor.
Command literal: mconCMD_READ_ZERO_FACTOR
Argument: pointer to an integer value
· Get the integral gain factor parameter <ki>
This command returns the value of the integral gain factor.
Command literal: mconCMD_READ_INTEGRATION_GAIN
Argument: pointer to an integer value
· Get the integral gain shift count parameter <ki_sc>
This command returns the value of the shift count for <ki>.
Command literal: mconCMD_READ_INT_GAIN_SHIFT
Argument: pointer to an integer value
· Get the pole factor parameter po>
This command returns the value of the pole factor of the closed loop filter.
Command literal: mconCMD_READ_POLE_FACTOR
Argument: pointer to an integer value

The calculated current value given to the DAC and then to the motor can be limited by the following command:

· Write limit torque parameter parameter <lt>
Limits the velocity reference output. Value in DA-steps.
Command literal: mconCMD_WRITE_MAX_VELOCITY_REF
Argument: pointer to an integer containing the value to be set
· Read limit torque parameter parameter <lt>
Command literal: mconCMD_READ_MAX_VELOCITY_REF
Argument: pointer to an integer

3.3.14 Signal Configuration

Commands for the configuration of limit switches, reference switches, and "drive fault" signals. By default all switch-signals are "low-active". This can be changed by the argument passed to the commands:
Parameter Value
Configuration

0

Off

1

Low-active

2

High-active

· Write positive limit switch configuration parameter <ps>
Command literal: mconCMD_WRITE_UPPER_LIMIT_LEVEL
Argument: pointer to an integer containing the value to be set
· Read positive limit switch configuration parameter <ps>
Command literal: mconCMD_READ_UPPER_LIMIT_LEVEL
Argument: pointer to an integer
· Write negative limit switch configuration parameter <ns>
Command literal: mconCMD_WRITE_LOWER_LIMIT_LEVEL
Argument: pointer to an integer containing the value to be set
· Read negative limit switch configuration parameter <ns>
Command literal: mconCMD_READ_LOWER_LIMIT_LEVEL
Argument: pointer to an integer
· Write reference switch configuration parameter <rs>
Command literal: mconCMD_WRITE_REF_SWITCH_LEVEL
Argument: pointer to an integer containing the value to be set
· Read reference switch configuration parameter <rs>
Command literal: mconCMD_READ_REF_SWITCH_LEVEL
Argument: pointer to an integer
· Write drive fault switch configuration parameter <df>
Command literal: mconCMD_WRITE_DRIVE_FAULT_LEVEL
Argument: pointer to an integer containing the value to be set
· Read drive fault switch configuration parameter <df>
Command literal: mconCMD_READ_DRIVE_FAULT_LEVEL
Argument: pointer to an integer

3.3.15 Interrupt Configuration

Three interrupts are available for user-defined routines:

· Drive Fault - The Drive Fault input of the MAC4 is activated
· Motion End - The motion end status bit in the status of the MAC4 is activated
· Emergency Stop - The HW emergency STOP input of the MAC4 is activated

Each interrupt can be independently configured, enabled and disabled. Because every command can have only one parameter, the argument to all interrupt `config' commands is the address of a data structure of type mconCONFIG_INT, which contains the fields:

· routine - the routine to be executed in case of an interrupt
· parameter - a parameter to be passed to this routine

By default (without a config-command) a dummy handler routine is executed in case of an enabled interrupt, which prints a message on the screen.

The interrupt-vectors are defined at device-installation and cannot be changed by the user.

A description to configure the board-hardware for interrupts can be found in [2].

Another interrupt is also available when the encoder data are given by the host to the MAC4 controller (see command mconCMD_WRITE_ENCODER_VALUE, section 3.3.19).

The interrupt can be independently configured, enabled and disabled. Because every command can have only one parameter, the argument to the interrupt `config' commands is the address of a data structure of type mconINT_ENC_VAL, which contains the fields:

· routine - the routine to be executed in case of an interrupt. This routine executes on interrupt level.
· parameter - a parameter to be passed to this routine
· vector - the interrupt vector (range 1-255).

· Configure drive fault interrupt
When enabled will give an interrupt when the Drive Fault input of the MAC4 is activated. Input parameter is the address of a user supplied routine to be called on the interrupt. The interrupt vector is defined at the installation of the device. The user routine will run in task level context.
Command literal: mconCMD_CONFIG_INTERRUPT_DRIVE_FAULT
Argument: address of mconCONFIG_INT data structure
· Configure motion end interrupt
When enabled will give an interrupt when the `in position' or `adjusting finished' status bit in the user-status of the MAC4 is activated (see section 3.3.18). Input parameter is the address of a user supplied routine to be called on the interrupt. The interrupt vector is defined at the installation of the device. The user routine will run in task level context.
Command literal: mconCMD_CONFIG_INTERRUPT_MOTION_END
Argument: address of mconCONFIG_INT data structure
· Configure emergency stop interrupt
When enabled will give an interrupt when the STOP input of the MAC4 is activated. Input parameter is the address of a user supplied routine to be called on the interrupt. The interrupt vector is defined at the installation of the device. The user routine will run in task level context.
The emergency stop interrupt is common to all devices of one controller board! Therefore only one configuration is allowed that applies automatically to all devices of a board.
Command literal: mconCMD_CONFIG_INTERRUPT_EMERGENCY_STOP
Argument: address of mconCONFIG_INT data structure
· Configure encoder value interrupt
When enabled will give an interrupt each time the MAC4 controller has performed the control loop, e.g. every 2.5 ms for the present version of the controller. The interrupt must be configured and enabled and the correct encoder configuration must be set before the mconCMD_INIT command is given.
Command literal: mconCMD_CONFIG_INTERRUPT_ENCODER_VALUE
Argument: address of mconINT_ENC_VAL data structure

Enabling and disabling of interrupts is done with the following commands:

IMPORTANT: like any other parameter value, the interrupt enable-status (i.e. the interrupt vector) remains unchanged in the controller until an explicit EXECUTE command is issued. This is not done automatically by the driver. The value obtained by a "read interrupt vector" command represents only the current parameter setting, and not necessarily the enable-status of the controller.

· Enable drive fault interrupt
This command enables the drive fault interrupt.
Command literal: mconCMD_ENABLE_INTERRUPT_DRIVE_FAULT
Argument: none
· Disable drive fault interrupt
This command disables the drive fault interrupt.
Command literal: mconCMD_DISABLE_INTERRUPT_DRIVE_FAULT
Argument: none
· Enable motion end interrupt
This command enables the motion end interrupt.
Command literal: mconCMD_ENABLE_INTERRUPT_MOTION_END
Argument: none
· Disable motion end interrupt
This command disables the motion end interrupt.
Command literal: mconCMD_DISABLE_INTERRUPT_MOTION_END
Argument: none
· Enable emergency stop interrupt
This command enables the emergency stop interrupt.
Command literal: mconCMD_ENABLE_INTERRUPT_EMERGENCY_STOP
Argument: none
· Disable emergency stop interrupt
This command disables the emergency stop interrupt.
Command literal: mconCMD_DISABLE_INTERRUPT_EMERGENCY_STOP
Argument: none
· Enable encoder value interrupt
This command enables the encoder value interrupt.
Command literal: mconCMD_ENABLE_INTERRUPT_ENCODER_VALUE
Argument: none
· Disable encoder value interrupt
This command disables the encoder value interrupt.
Command literal: mconCMD_DISABLE_INTERRUPT_ENCODER_VALUE
Argument: none
· Read drive fault interrupt vector parameter <irq_vec3>
This command returns the present setting of the interrupt vector parameter, i.e. either 0 or the value predefined at installation (range 1..255). Note that this value might not reflect the controller's current enable-status!
Command literal: mconCMD_READ_DRIVE_FAULT_IRQ
Argument: pointer to an integer
· Read motion end interrupt vector parameter <irq_vec4>
This command returns the present setting of the interrupt vector parameter, i.e. either 0 or the value predefined at installation (range 1..255). Note that this value might not reflect the controller's current enable-status!
Command literal: mconCMD_READ_MOTION_END_IRQ
Argument: pointer to an integer
· Read emergency stop interrupt vector parameter <irq_vec5>
This command returns the present setting of the interrupt vector parameter, i.e. either 0 or the value predefined at installation (range 1..255). Note that this value might not reflect the controller's current enable-status!
Command literal: mconCMD_READ_EMERGENCY_STOP_IRQ
Argument: pointer to an integer
· Read encoder value interrupt vector parameter <irq_vec6>
This command returns the present setting of the interrupt vector parameter, i.e. either 0 or the value set at interrupt configuration (range 1..255). Note that this value might not reflect the controller's current enable-status!
Command literal: mconCMD_READ_ENCODER_VALUE_IRQ
Argument: pointer to an integer

The interrupt vector parameters for "command buffer empty" (parameter <irq_vec1>) and "answer available" (parameter <irq_vec2>) are used by the driver internally and are not foreseen for user interactions.

3.3.16 Auxiliary Parameters and Commands

· Set watchdog time parameter <wd>
If an axis is moving and no command is issued to the controller within the time specified by this parameter, then all axes will be stopped. The time-unit is milli-seconds. A value of zero turns the watchdog off (default).
Command literal: mconCMD_WRITE_WATCHDOG
Argument: pointer to an integer containing the value to be set
· Get watchdog time parameter <wd>
Command literal: mconCMD_READ_WATCHDOG
Argument: pointer to an integer value
· Set maximum position error parameter <mf>
When this value is exceeded the axis will be stopped (also called following error). The position error is the difference between the actual position and the calculated profile. Value in increments.
Command literal: mconCMD_WRITE_MAX_POS_ERROR
Argument: pointer to an integer containing the value to be set
· Get the maximum position error parameter <mf>
This command returns the value of the maximum allowed deviation between the actual position and the calculated profile. If this value is exceeded the axis will be stopped. Value in increments.
Command literal: mconCMD_READ_MAX_POS_ERROR
Argument: pointer to an integer value
· Set emergency deceleration parameter <ed>
Set the deceleration value used in the following cases:
· Software emergency stop
· Hardware emergency stop
· Limit switch reached
· Maximum following error exceeded
· "drive fault" signal active
Command literal: mconCMD_WRITE_EM_DECEL
Argument: pointer to an integer containing the value to be set
· Get emergency deceleration parameter <ed>
Command literal: mconCMD_READ_EM_DECEL
Argument: pointer to an integer value
· Set low velocity parameter <lv>
Set the low-velocity value used in the following modes:
· Search Index (see section 3.3.5)
· Home (see section 3.3.6)
· Find Edge (see section 3.3.7)
Command literal: mconCMD_WRITE_CORR_SPEED
Argument: pointer to an integer containing the value to be set
· Get low velocity parameter <lv>
Command literal: mconCMD_READ_CORR_SPEED
Argument: pointer to an integer value
· Set the target error parameter <tr>
Set the target radius defining a window around the target position. If the difference between the calculated position and the target position is smaller than this parameter for a duration longer than <trt> (see below), then the bit 'in position' in the user-status word will be set (see section 3.3.18). The target radius is only valid in mode POSITIONING (see section 3.3.3).
Command literal: mconCMD_WRITE_TARGET_RADIUS
Argument: pointer to an integer containing the value to be set
· Get the target error parameter <tr>
Command literal: mconCMD_READ_TARGET_RADIUS
Argument: pointer to an integer value
· Set the target settling time parameter <trt>
This parameter specifies the time in milliseconds that the axis must stay within the target radius before the user-status bit `in position' (see section 3.3.18) is set and the interrupt `motion end' (see sections 3.3.15 and 3.5) is issued. Note that it may happen that the described condition cannot be met, e.g. in case of an instable axis, and the `in position' status is never reached.
Command literal: mconCMD_WRITE_TARGET_SETTLING_TIME
Argument: pointer to an integer containing the value to be set
· Get the target settling time parameter <trt>
Command literal: mconCMD_READ_TARGET_SETTLING_TIME
Argument: pointer to an integer value
· Set the scaling factor parameter <sf>
The scaling factor can be applied on parameter values in order to use fractions of increments:
<scaled parameter> = <parameter> / 2<sf>
CAUTION: If <sf> is set to a non-zero value then most parameters (speed, acceleration, deceleration) will be scaled!
Command literal: mconCMD_WRITE_SCALE_FACTOR
Argument: pointer to an integer containing the value to be set
· Get the scaling factor parameter <sf>
Command literal: mconCMD_READ_SCALE_FACTOR
Argument: pointer to an integer value
· Set the current position
The argument passed with this command is assigned to the current position. An explicit EXECUTE command is needed in order to make the new setting valid.
Command literal: mconCMD_WRITE_INIT_POS
Argument: pointer to an integer containing the value to be set
· Set reverse polarity
This command reverses the polarity of the velocity reference. This can be used during test of the first setup if the amplifier or encoder is not properly connected.
Note: This command should only be used for test and verification purposes!
Command literal: mconCMD_POLARITY_REVERSE
Argument: none
· Set normal polarity
This is the reverse of the previous command.
Note: It must be made sure, that "normal polarity" is used for normal operation.
Command literal: mconCMD_POLARITY_INITIAL
Argument: none
· Set polarity
This executes one of the two previous commands depending on the specified argument.
Command literal: mconCMD_WRITE_POLARITY
Argument: 0 = normal polarity, 1 = reverse polarity

3.3.17 Stepper Motor Specific Parameters

These parameters are additionally available for the MAC4-STP controller version. Detailed information can be found in [2].

· Set motor steps parameter <ms>
Defines the number of steps for one rotation.
Command literal: mconCMD_WRITE_MOTOR_STEPS
Argument: pointer to an integer containing the value to be set
· Get motor steps parameter <ms>
Command literal: mconCMD_READ_MOTOR_STEPS
Argument: pointer to an integer value
· Set start-stop-frequency parameter <ssf>
Defines the start/stop-frequency of the motor.
Command literal: mconCMD_WRITE_START_STOP_FREQ
Argument: pointer to an integer containing the value to be set
· Get start-stop-frequency parameter <ssf>
Command literal: mconCMD_READ_START_STOP_FREQ
Argument: pointer to an integer value
· Set boost-time parameter <bt>
Command literal: mconCMD_WRITE_BOOST_TIME
Argument: pointer to an integer containing the value to be set
· Get boost-time parameter <bt>
Command literal: mconCMD_READ_BOOST_TIME
Argument: pointer to an integer value
· Set step-counts parameter <stc>
Additional parameter used in the last phase of positioning-mode.
Command literal: mconCMD_WRITE_CREEP_DIST
Argument: pointer to an integer containing the value to be set
· Get step-counts parameter <stc>
Command literal: mconCMD_READ_CREEP_DIST
Argument: pointer to an integer value
· Set servo wait time parameter <sw>
Time to wait after motion-end before a check of reached position is performed.
Command literal: mconCMD_WRITE_SERVO_WAIT_TIME
Argument: pointer to an integer containing the value to be set
· Get servo wait time parameter <sw>
Command literal: mconCMD_READ_SERVO_WAIT_TIME
Argument: pointer to an integer value
· Set turbo-mode
Command literal: mconCMD_STP_TURBO_MODE
Argument: pointer to an integer containing the value to be set

3.3.18 Status Commands

· Get the controller version
This command returns a 32 bit value containing the controller type and version:
Bit 31-24: Controller Type, 23-16: Hardware Release,
Bit 15-8/7-0: Software Version/Release
Command literal: mconCMD_READ_MCON_VERSION
Argument: pointer to an integer value
· Get the current position
This command returns the current position. Value in increments.
Command literal: mconCMD_READ_CURRENT_POSITION
Argument: pointer to an integer value
· Get the actual velocity
This command returns the value of the actual velocity.
Command literal: mconCMD_READ_ACTUAL_VELOCITY
Argument: pointer to an integer value
· Get the position error
This command returns the actual position error. Value in increments.
Command literal: mconCMD_READ_ERROR_POS
Argument: pointer to an integer value
· Get the encoder count
This command returns the encoder value.
Command literal: mconCMD_READ_ENC_COUNTER
Argument: pointer to an integer value
· Get the encoder counter (raw value)
This command returns the raw value of the encoder counter.
Command literal: mconCMD_READ_ENC_COUNT_RAW
Argument: pointer to an integer value
· Get the user status
This command returns the user status of the controller.
Command literal: mconCMD_READ_USER_STATUS
Argument: pointer to an integer value, which has the following meaning:
Bits 0..7 Actual mode of operation with the meaning:
value 0: Disable
value 1: Enable
value 2: Search Index Coarse
value 3: Search Index
value 4: Home mode
value 5: Find Edge
value 6: Speed mode
value 7: Brake mode
value 8: Positioning mode
value 9: Velocity Tracking
value 10: Test mode
value 11: Position Tracking
value 12: Reset
Bit 8 Drive is enabled.
Bit 9 Reverse output.
Bit 10 In position.
Bit 11 Adjusting finished.
Bit 12 Command INIT executed.
Bit 13 Syntax error.
Bit 14 Limit error.
Bit 15 Unexpected command.
Bit 16 Encoder fault.
Bit 17 Drive fault.
Bit 18 Maximum position error exceeded.
Bit 19 On negative limit switch.
Bit 20 On positive limit switch.
Bit 21 On negative software limit.
Bit 22 On positive software limit.
Bit 23 Reference switch active.
Bit 24 Unused.
Bit 25 "on fly" mode on
Bit 26 Unused.
Bit 27 SSI encoder type jumper setting: 0 = Binary, 1 = Gray-Code (only for SSI).
Bit 28..31 Unused.
· Get the system status
This command returns the system status of the controller.
Command literal: mconCMD_READ_SYSTEM_STATUS
Argument: pointer to an integer value, which has the following meaning:
Bit 0 Command ready.
Bit 1 Phase 1
Bit 2 Phase 2
Bit 3 Phase 3
Bit 4 Phase 4
Bit 5..6 used for MAC4-INC and MAC4-STP, see [2].
Bit 7 Unused.
Bit 8 Unused.
Bit 9 Encoder initialized.
Bit 10..18 used for MAC4-STP, see [2].
Bit 19..31 Unused.
· Get the common status
This command returns the common status of the controller.
Command literal: mconCMD_READ_COMMON_STATUS
Argument: pointer to an integer value, which has the following meaning:
Bit 0 Emergency stop. Unit stopped by the hardware input 'STOP'.
Bit 1 Invalid axis number.
Bit 2 Watchdog error
Bit 3..5 Backplane address
Bit 6 Unused.
Bit 7 In service mode.
Bit 8..31 Unused
· Read DAC/Output value
This command reads the current value from the DAC (for INC and SSI) resp. the current output value in steps per sampling period (for STP).
Command literal: mconCMD_READ_DAC_VALUE
Argument: pointer of an integer value
· Read current encoder position (STP only)
This command reads the current value from the encoder in increments.
Command literal: mconCMD_READ_CUR_POS_INC
Argument: pointer of an integer value

3.3.19 Direct Controller Access

These commands bypass the normal queue mechanism of the controller. They operate directly with the dual-ported RAM.

· Write direct encoder value
The host-system can provide an external encoder information (32-bit value) to the controller. In this case the address containing this value must be set in the parameter <ea> (see sections 3.3.12 and 3.3.15) to:
Axis
Address <ea>

1

0x330A

2

0x370A

3

0x3B0A

4

0x3F0A


Command literal: mconCMD_WRITE_ENCODER_VALUE
Argument: pointer of an integer value containing the value to be set
· Software emergency stop
This command requests an immediate stop for the drive.
Note: The emergency stop interrupt is only activated by a hardware emergency stop.
Command literal: mconCMD_EMERGENCY_STOP
Argument: none
· Flush the controller's reply-queue
This command resets the reply-queue back to a defined state. It should only be used when the reply-queue got corrupted, indicated by the error mconERROR_WRONG_REPLY (see section 5.4.2).
Note: This affects all devices on the same board!
Command literal: mconCMD_FLUSH_QUEUE
Argument: none

3.3.20 Driver-related Commands

These commands are processed inside the driver and work independently from the controller.

· Get the driver version
This command returns the driver version as an integer value in the format:
Bit 31-16: major version number, Bit 15-0: minor version number.
Command literal: mconCMD_GET_DRIVER_VERSION
Argument: pointer to an integer value, e.g. 0x00020003 means version `2.3'.
· Set the driver timeout value
This command sets the timeout of the driver. The value must be specified in system clock ticks.
Note: The driver timeout is totally independent from the controller and its watchdog. It is only used to check if the controller responds to a command within the specified time.
Command literal: mconCMD_SET_TIMEOUT_TICK
Argument: pointer of an integer value containing the value to be set
· Get the driver timeout value
This command returns the driver timeout value in ticks.
Command literal: mconCMD_GET_TIMEOUT_TICK
Argument: pointer to an integer value
· Simulate blocking of access protection semaphore
This command can be used to simulate a task which blocks the access to the controller for a time specified by the given argument in ticks.
Command literal: mconCMD_BLOCK_SEMAPHORE
Argument: pointer of an integer value containing the value to be set
· Free the device
The purpose of this command is to free the device when a process which has opened the device in exclusive read/write mode is blocked or has terminated without closing the device. In this case it is not possible to send a write command to the device. This command frees the device and enables another process to open the device in read/write mode. The intention is that this command shall only be used 'manually' by an operator, to free the device and should not be used by processes which wants to send ioctl write commands to the device.
Command literal: mconCMD_FREE_DEVICE
Argument: none
Return values:
· OK - successful completion
· mconERROR_NO_EXCLUSIVE - no channel opened in exclusive mode

3.4 Logging

The MAC4 driver makes use of the common logging facility, i.e. the lculog module for debugging and tracing purposes. Therefore the lculog task must be loaded and spawned before the MAC4 driver is used.

The logging facility simply prints messages to the VxWorks shell. There are several different types of messages:

· Errors These are printed always.
· Warnings These are printed always.
· Logs These are printed always.
· Debug These are printed only if debug-option is enabled.
· Trace These are printed only if the trace-option is enabled.

The debug- and trace-option can be switched on by issuing the following commands to the VxWorks shell: LCU_debug and LCU_trace. Both functions should return the value 1.

To switch the logging and tracing facilities off just issue the corresponding commands again and this time they should return the value 0.

3.5 Interrupts

The emergency stop, drive fault and motion end events are configured to generate interrupts. By default, they are disabled, and for each device, dummy interrupt routines are previously connected at start-up.

If applications use interrupts, they must first provide interrupt handler routines, which are installed by the commands:

· mconCMD_CONFIG_INTERRUPT_DRIVE_FAULT
· mconCMD_CONFIG_INTERRUPT_MOTION_END
· mconCMD_CONFIG_INTERRUPT_EMERGENCY_STOP

Then they can be enabled/disabled by the commands:

· mconCMD_ENABLE_INTERRUPT_DRIVE_FAULT
· mconCMD_DISABLE_INTERRUPT_DRIVE_FAULT
· mconCMD_ENABLE_INTERRUPT_MOTION_END
· mconCMD_DISABLE_INTERRUPT_MOTION_END
· mconCMD_ENABLE_INTERRUPT_EMERGENCY_STOP
· mconCMD_DISABLE_INTERRUPT_EMERGENCY_STOP

The interrupt vector parameters can be read by the commands:

· mconCMD_READ_DRIVE_FAULT_IRQ
· mconCMD_READ_MOTION_END_IRQ
· mconCMD_READ_EMERGENCY_STOP_IRQ

IMPORTANT: See the notes in section 3.3.15 about these commands!

Applications can provide one interrupt routine per event and per device, except for the "emergency stop" interrupt, which is common to all devices on the same controller board2. The handler routines are executed in task context, not in interrupt context.

Unlike the previous version 1.2, when an interrupt occurs, it will NOT be disabled by the driver.

3.6 Tools

The MAC4 driver includes a number of tools which can be used from the VxWorks shell. These tools are intended to be used by a system manager to ease maintenance and troubleshooting. All tools take one argument except otherwise noted, namely the number of the device (e.g. `2' for device "/mcon2"). The VxWorks shell sets unspecified arguments automatically to zero.

· mconVersion
prints the version of the driver and the version of the associated controller board.
· mconSt, mconSSt, mconCSt
prints the user/system/common status data structure of the device specified.
· mconStAll
prints the status data structures of all installed devices (no argument).
· mconPos
performs a read of several position parameters from the controller and prints them.
· mconPar, mconParMode, mconParDC, mconParSSI, mconParStep, mconParAux
performs a read of several configurations parameters from the controller and prints them. The command has different versions for printing common parameters, only mode-relevant parameters, additional specialized parameters for the several controller versions (DC-motors, SSI-encoders, Stepper-motors), and additional auxiliary parameters.
· mconDevShow
prints all devices installed to the driver with their base addresses.
· mconProbe
tests, if address exists for the device (axis) specified by unit
· mconSizeofPrint
print the sizes of the most important, internal driver data structures
· mconErrorPrint (errorCode)
decodes an error code to the corresponding text
· mconTest(char *name, int cmd, int *argument)
performs
· an open of the device name
· the command cmd with the argument(s) argument is pointing to
· a close of the device name

All the tools require that the MAC4 driver is already installed and at that the specified device is created.

All output is directed on the standard output, i.e. either to the system console or to a host terminal.

The following sections give more detailed information for the usage of the tools.

3.6.1 mconTools(1)
NAME
mconTools - Tools for the MACCON driver


SYNOPSIS
void mconVersion (int axis);
void mconSt (int axis);
void mconSSt (int axis);
void mconCSt (int axis);
void mconStAll ();
void mconPos (int axis);
void mconPar (int axis);
void mconParMode (int axis);
void mconParDC (int axis);
void mconParStep (int axis);
void mconParSSI (int axis);
void mconParAux (int axis);
void mconDevShow (void);
void mconSizeofPrint ();
void mconErrorPrint (int err);
STATUS mconProbe (int device);



DESCRIPTION
These functions represent a number of tools enabling the user
to get comprehensive information about a MACCON (axis) device
and driver.

mconVersion () - print the versions of controller and driver
mconSt () - print user status data structure of device
mconSSt () - print system status data structure of device
mconCSt () - print common status data structure of device
mconStAll () - print status data structure of all devices
mconPos () - print the position, position command, position
error and actual velocity of axis
mconPar () - print all parameters of an axis
mconParMode () - dto. but only parameters of the current mode
mconParDC () - dto. for DC motor parameters
mconParStep () - dto. for stepper parameters
mconParSSI () - dto. for SSI parameters
mconParAux () - dto. for auxiliary parameters
mconDevShow () - print the devices and adresses of the driver
mconSizeofPrint () - print size of data structures of MCON driver
mconErrorPrint () - print error message belonging to error code err
mconProbe () - test if address exists for device

err - error code
axis, device - device number = axis number


RETURN VALUES
None




- - - - - -
Last change: 19/05/95-16:19
3.6.2 mconTest(1)
NAME
mconTest - Functions to test the provided operations of the
MACCON driver


SYNOPSIS
int mconTest (char *devName, int req, int *argPtr)
int mconTest0 (int req, int argum_0, int argum_1)
int mconTest1 (int req, int argum_0, int argum_1)
int mconTest2 (int req, int argum_0, int argum_1)
int mconTest3 (int req, int argum_0, int argum_1)
int mconTestOpen ( char *fileName, int openMode)
int mconTestIoctl (int fd, int command, int value)
void mconTestLoop1 (char * devName)
void mconTestLoop2 (char * devName)
STATUS mconTestClose (int fd)
STATUS mconTestInterrupt (int fd, int command,
VOIDFUNCPTR routine, int parameter)



DESCRIPTION
These functions represent a sum of tools to test the MACCON driver.

mconTest () - open any device, execute specified command, close device
mconTest0 () - open "/mcon0"-device , execute command, close device
mconTest1 () - open "/mcon1"-device , execute command, close device
mconTest2 () - open "/mcon2"-device , execute command, close device
mconTest3 () - open "/mcon3"-device , execute command, close device
mconTestLoop1 () - open specified device, execute read/write commands,
compare input-output
mconTestLoop2 () - open specified device, execute ....
mconTestOpen () - open specified device
mconTestClose () - close specified device
mconTestIoctl () - execute specified command
mconTestInterrupt () - test interrupt handling

devName - device name
req - command code
argPtr - pointer to argument data structure to be passed to
command function
argnum_i - arguments (1,2,..i)
fileName - device name to open
openMode - open mode
fd - file descriptor
value - argument to be passed to command function
routine - routine to be executed in case of an interrupt
parameter - parameter to be passed to the interrupt routine


RETURN VALUES
OK - successful completion
ERROR - error occured during operation
IOCTL specific errors - see USER MANUAL




- - - - - -
Last change: 19/05/95-16:19

3.7 Include Files

Beside VxWorks include files, driver applications must include "mcon.h" to interface the MAC4 driver. Board dependent, this file declares as prototypes the operations provided by the driver library, and includes other files themselves.

· "mconCommands.h" defining the literals of the MAC4 driver commands and data structures for multiple argument commands as used with the ioctl() procedure.
· "mconErrors.h" defining the literals of the MAC4 driver errors returned by ioctl().
· "lcudrv.h" defining the error literals common to all drivers.
· The necessary VxWorks header files.

1
The generic descriptions of the VxWorks system calls can be found in [4]

2
This affects installation and configuration of this interrupt. See sections 3.2.1, 3.3.15 and 4.3.



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