AR(IV)                              8/9/75                              AR(IV)

NAME
	ar - AR11 analog/digital, digital/analog driver

DESCRIPTION
	The ar driver provides a user interface to the AR11 real-time
	analog to digital and digital to analog conversion device.  The
	device has a real-time clock which permits sampling, at a program-
	selectable rate, up to 16 analog channels.  While the AR11
	hardware can be used in a number of different modes - e.g., as
	an interval timer independent of the A/D converter - only the
	usage described below is supported by the driver.

	There are five entry points to the AR11 driver, corresponding to
	the UNIX OPEN, CLOSE, READ, WRITE, and STTY functions.  OPEN and
	CLOSE perform the usual initialization and termination functions.
	READ reads the most recent sample number and the corresponding
	converted values, WRITE sends data to the D/A converters, and STTY
	is used to control the sampling rate and the number of channels.

USAGE
	The AR11 is an exclusive use device.  That is, after being
	opened, it must be closed before other OPENS will be accepted.

	When the AR11 is opened [open (II)], the sampling rate, the sample
	number, and all sixteen sample values are set to zero; they remain
	unchanged until sampling is begun by means of an stty (II) call,
	as described below.

	After opening the AR11, the sequence

			int xy[2];
			...
			write (arfildes, xy, 4);

	will cause the two values in xy[2] to be D/A converted.  The
	values are treated as ten bit twos complement numbers; the high
	order six bits are ignored.  If more than four bytes are written,
	those after the fourth will be ignored; if fewer than four bytes
	are written, unpredictable values will be supplied. An "intensify"
	signal, useful for driving an oscilloscope display, will be
	produced in any case.

	The stty (II) function is used to start A/D conversion (sampling)
	on a specified number of channels at a specified rate, and in
	a specified range.  The three word integer parameter array is
	treated as follows:

		word       data
		 1   Sampling period --
		      hi byte is mantissa, lo byte is negative exponent of
		      sampling period.
			 Example:
			   5<<8 | 3  is 5*(10**-3) seconds (5 milliseconds
				     between samples.
		 2   Lo byte is highest numbered channel to be sampled.
			     Example: 3 to sample channels 0, 1, 2, and 3.
		 2   Hi byte is non-zero if A/D range is unipolar (0-5 volts);
			     zero if bipolar (-2.5 to 2.5 volts).
		 3   Reserved

	The sampling rate is restricted to lie between .002 seconds and 2.56
	seconds to prevent the sampling from consuming all of the available
	machine cycles, but use of the device at sampling periods exceeding
	.02 seconds will impose a considerable load on the system. If the
	sampling rate exceeds the above limits, an error is returned (-1
	from C) and the sampling rate is set to zero.  Otherwise, sampling
	is begun, and continues until another stty call changes the rate
	or until the AR11 is closed [close (II)]. The sampling proceeds
	at the specified rate, whether or not each sample is read.

	Each read (II) of the AR11 results in the transfer of at most 34
	bytes to the user.  The first two bytes constitute an unsigned
	integer sample number (modulo 65536), and the following bytes are
	the samples of successive A/D channels.  Note that it is possible
	to detect missed or multiply-read samples by inspecting successive
	the sample numbers.  The user should recognize that missed samples
	are very likely, since sampling proceeds even when the user process
	reading the samples is not running (e.g., when it is swapped out.
	Nevertheless, the sample number provides an indication of the real
	sample time.

FILES
	/dev/ar - the AR11 special device

SEE ALSO
	PDP/11 Peripherals Handbook
	AR11 Manual
	read(II), write(II), open(II), close(II), stty(II)

BUGS
	Don't expect real-time performance when UNIX is heavily loaded.
	(A heavy load is defined for the use of the AR11 as more than
	one (1) active user.

AUTHOR
	Steve Zucker
