\chapter{Motors}

All motor records in MX support a common set of operations that are
described in this chapter.  We describe first the set of record fields
found in the record description string in an MX database file
for a motor.

Motor records are divided into two subclasses, namely, \textit{stepper}
and \textit{analog} motors.  The two classes are distinguished by the format
of the numbers used to communicate with the underlying controller.
Motor controllers for which positions, speeds, etc. are specified in
integer units (\textit{steps or encoder ticks}) are called \textit{stepper}
motors by MX motor support.  Motor controllers for which positions, speeds,
etc. are specified in floating point units are called \textit{analog}
motors by MX motor support.

\section{Record Fields in the Record Description}

The following fields must be included in the record description for a record
in an MX database file.  They must appear in the order presented below.

\begin{center}
\begin{tabularx}{\textwidth}{|c|c|c|c|X|}
\hline
\MxTextFieldName & \MxTextFieldType & \MxTextNumDimensions &
  \MxTextSizes & \MxTextDescription \\
\hline
\textit{name} & string & 1 & 16 & The name of the record \\
\hline
\textit{mx\_superclass} & recordtype & 0 & 0 & The string ``device'' \\
\hline
\textit{mx\_class} & recordtype & 0 & 0 & The string ``motor'' \\
\hline
\textit{mx\_type} & recordtype & 0 & 0 & 
	The name of the motor driver for this motor. \\
\hline
\textit{label} & string & 1 & 40 & A verbose description of the record. \\
\hline
\textit{acl\_description} & string & 1 & 40 &
	Placeholder for an access control list \textit{(not yet implemented)}.\\
\hline
\textit{raw\_position} & \MxMotorStepperVsAnalog
	& 0 & 0 & The motor position in raw units.  Generally this value
	will be overwritten by the position read from the motor controller. \\
\hline
\textit{raw\_backlash\_correction}
	& \MxMotorStepperVsAnalog
	& 0 & 0 & The MX backlash correction in raw units.\\
\hline
\textit{raw\_negative\_limit}
	& \MxMotorStepperVsAnalog
	& 0 & 0 & The software negative limit in raw units.\\
\hline
\textit{raw\_positive\_limit}
	& \MxMotorStepperVsAnalog
	& 0 & 0 & The software positive limit in raw units. \\
\hline
\textit{raw\_move\_deadband}
	& \MxMotorStepperVsAnalog
	& 0 & 0 & The motion deadband in raw units.  A requested move
		is not performed unless the difference between
		the requested and the current positions is
		bigger than the deadband distance. \\
\hline
\textit{raw\_minimum\_speed\_limit}
	& \MxMotorStepperVsAnalog
	& 0 & 0 & The slowest raw speed that can be requested for this motor.
		Negative values have special meanings.  -1 means there are
		no restrictions on the requested raw speed.  -2 means that
		the speed cannot be changed. \\
\hline
\textit{raw\_maximum\_speed\_limit}
	& \MxMotorStepperVsAnalog
	& 0 & 0 & The fastest raw speed that can be requested for this motor.
		Negative values have the same meaning as for
		``raw\_minimum\_speed\_limit''. \\
\hline
\textit{scale} & double & 0 & 0 &
	The ``scale'' field is used together with the ``offset'' field
		to compute positions in user units using the formula:
		\textit{user\_units = scale * raw\_units + offset}. \\
\hline
\textit{offset} & double & 0 & 0 &
	See the description of the ``scale'' field. \\
\hline
\textit{units} & string & 1 & 16 &
	User units for the motor, such as \textit{um}, or \textit{deg}. \\
\hline
\end{tabularx}
\end{center}

An example motor record description for a ``disabled motor'' is shown below.

\begin{verbatim}
theta device motor disabled_motor "" "" 0 0 -20000000 20000000 0 -1 -1 5e-05 0 deg
\end{verbatim}

The disabled motor record was chosen for this example since it has
no type-specific fields.

\section{Motor Controllers}

MX currently supports a wide variety of motor controllers.  Motor controllers
typically have a lot of additional I/O devices that are associated with the
controller, such as digital and analog I/O.  For convenience, we describe all
of the MX drivers for a given motor controller here in one place.
