Skip to content. | Skip to navigation

Personal tools

dmc.h

dmc.h

dmc.h

/////////////////////////////////////////////////////////////////////////////
// DMC.H
//
//  Last updated: 5/21/1998
//
//  Part of the source code for the Vane End Actuator Control System
//
//  This file contains all constants/variables/routines that are dedicated to
//  motor control and communication with the Galil DMC cards.
/////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
// DMC Constants and Parameters

// Ratio of encoder microns to Motor Steps
	// Axial  ratio = 0.55 microns at encoder/step
float AxialEncoderMicsPerStep = 0.55;
	// Radial ratio = 0.15 microns at encoder/step
float RadialEncoderMicsPerStep = 0.15;

// Ratio of vane end motion in microns to Motor Steps
	// Axial  ratio = 0.26 microns at vane end/step
float AxialVaneEndMicsPerStep  = 0.26;
	// Radial ratio = 0.08 microns at vane end/step
float RadialVaneEndMicsPerStep = 0.08;

// The two variables RadialSign and AxialSign must be verified!
//
// If RadialSign = 1, the program assumes that a positive move command
// to a radial motor (example, PR 100) results in a POSITIVE change in the
// radial encoder reading.
//
// If RadialSign = -1, the program assumes that a positive move command
// to a radial motor (example, PR 100) results in a NEGATIVE change in the
// radial encoder reading.
//
// If AxialSign = 1, the program assumes that a positive move command
// to an axial motor (example, PR 100) results in a POSITIVE change in the
// axial encoder reading.
//
// If AxialSign = -1, the program assumes that a positive move command
// to an axial motor (example, PR 100) results in a NEGATIVE change in the
// axial encoder reading.
//
// Check this by giving an IR 1 100 (move individual radial motor #1 100 microns)
// command in keyboard command mode.  Make sure that the onscreen reading
// for radial encoder #1 (S2 #1) is the one that changes.
//
// If it increases,set RadialSign to 1.
// If it decreases,set RadialSign to -1.
//
// Repeat this procedure for the axial motors, giving an IA 1 100 command.
// Make sure that the onscreen reading for axial encoder #1
// is the one that changes.
//
// If it increases,set AxialSign to 1.
// If it decreases,set AxialSign to -1.

int RadialSign = -1; // These two were correct as of 12/1/96
int AxialSign = -1;

// DMC constants/variables
int Radial = 0x300; // Base I/O Address of Radial DMC
int Axial = 0x304;  // Base I/O Address of Axial DMC
int AxialErrorCount = 0; // Number of consecutive Axial errors
int RadialErrorCount = 0; // Number of consecutive Radial errors
#define MaxDMCErrors 4 	// Maximum number of consecutive DMC errors before
												// suspending DMC error messages

// The following two constants are used to determine when a move is complete.
// Their values are the maximum amount in microns at the encoders that
// the commanded position is allowed to be off by from the actual position
int AxialError;
int RadialError;

// Command timeouts for DMCs in milliseconds
int DMCSlowCommand = 200;  // SlowCommand = initialization commands, like RS
int DMCFastCommand = 100;   // FastCommand = fast commands, like TP
int DMCMoveCommand = 2000; // MoveCommand = very slow movement commands

// Global DMC temporary variable
int DMCTemp;

/////////////////////////////////////////////////////////////////////////////
// DMCCharReady - Check for waiting DMC character
int DMCCharReady(int Port);
// Returns a 1 if the DMC on port Port has a character ready,
// otherwise it returns a zero

/////////////////////////////////////////////////////////////////////////////
// DMCSend - Send a string to a DMC
void DMCSend(int Port, char *Data);
// Output a string (Data) to DMC on port Port.
// See the DMC manual for more info on communication with the DMC cards.

/////////////////////////////////////////////////////////////////////////////
// DMCReceive - Wait for a response from a DMC
int DMCReceive(int Port,char *Response,int Timeout);
// Put the DMC's (on port Port) response in Response, and wait for Timeout
// milliseconds before giving up.
// Returns a 0 on success, 1 on a failure, -1 on not done yet
// See the DMC manual for more info on communication with the DMC cards.

// Blocking version of DMCReceive
int BDMCReceive(int Port,char *Response,int Timeout)
{
	int temp;

	do
		temp = DMCReceive(Port,Response,Timeout);
	while (temp == -1);
	return(temp);
}

/////////////////////////////////////////////////////////////////////////////
// DMCCommand - Send a DMC a command and wait for a response
int DMCCommand(int Port, char *Data,char *Response,int Timeout);
// Returns a 0 on success, 1 on a failure, -1 on not done yet

// Blocking version of DMCCommand
int BDMCCommand(int Port, char *Data,char *Response,int Timeout)
{
	int temp;

	do
		temp = DMCCommand(Port,Data,Response,Timeout);
	while (temp == -1);
	return(temp);
}

/////////////////////////////////////////////////////////////////////////////
// CheckDMCs - Verifies initial power-up state of DMCs
int CheckDMCs();
// CheckDMCs exists just to make sure that on boot-up, the outputs
// of the Radial controller are low (0), which disables the emergency stop
// card, and that the Axial controller outputs are high (1), turning OFF
// pressure and vacuum.  These outputs are stored using the burn command (BN),
// but this procedure checks them just in case, and re-burns them if necessary.

/////////////////////////////////////////////////////////////////////////////
// GetEncoders - Returns current axial and radial encoder values
int GetEncoders(int AE[4],int RE[4]);
// Reads all 8 encoder positions into AE (Axial encoders)
// and RE (Radial encoders).
// Returns a 0 on success, 1 on a failure.
//
// AE[0] = NW Axial,AE[1] = SW Axial,AE[2] = SE Axial,AE[3] = NE Axial
// RE[0] = NW Radial,RE[1] = SW Radial,RE[2] = SE Radial,RE[3] = NE Radial

/////////////////////////////////////////////////////////////////////////////
// GetSwitches - Returns current axial and radial switch values
int GetSwitches(int AS[4],int RS[4]);
// Reads all 8 switch values into AS (Axial switches)
// and RS (Radial switches).
// Returns a 0 on success, 1 on a failure.
//
// AS[0] = NW Axial,AS[1] = SW Axial,AS[2] = SE Axial,AS[3] = NE Axial
// RS[0] = NW Radial,RS[1] = SW Radial,RS[2] = SE Radial,RS[3] = NE Radial

/////////////////////////////////////////////////////////////////////////////
// ConfigDMCs - Sets up the DMCs
int ConfigDMCs();
// Configures the two DMC cards
// Returns a 0 on success, 1 on failure.

/////////////////////////////////////////////////////////////////////////////
// ResetEmergency - Reset the emergency stop card
int ResetEmergency();

/////////////////////////////////////////////////////////////////////////////
// MoveAllMotors - Moves all motors the specified number of steps
int MoveAllMotors(int TA[4],int TR[4],int MoveTime,int Timeout,int MoveDelay);
// This routine sends commands to the DMCs to accomplish a move
// of TA[] (target axial) or TR[] (target radial) steps in
// MoveTime milliseconds, allowing a timeout of
// Timeout milliseconds before failure.
// TA[0] = NW Axial,TA[1] = SW Axial,TA[2] = SE Axial,TA[3] = NE Axial
// TR[0] = NW Radial,TR[1] = SW Radial,TR[2] = SE Radial,TR[3] = NE Radial

/////////////////////////////////////////////////////////////////////////////
// DMCTerminal - Starts a simple terminal session with a DMC
void DMCTerminal(int Port);
// This routine provides a small terminal emulation
// for direct communication with the DMC cards.
// The DMC to be communicated with is passed in Port.
// Hitting ESC closes the terminal.

/////////////////////////////////////////////////////////////////////////////
// MoveIndividualMotor - Moves a single motor a given number of microns
int MoveIndividualMotor(int Port,int MotorNum,int Dist);
// This routine moves a single motor Dist microns at the encoder.
// Pass either Axial or Radial as the Port value, and an integer
// from 1 to 4 for MotorNum.
// Returns a 0 on success, 1 on failure

/////////////////////////////////////////////////////////////////////////////
// AdjustTension - Moves all radial motors to adjust the tensions
int AdjustTension(int Dist);
// This routine moves all radial motors to Dist microns in from their zeroed
// location, tensioning the vanes.  The new TensionAmount is written to
// VANE.INI.
//
// Returns a 0 on success, 1 on abort


Generated by GNU Enscript 1.6.5.2.
Document Actions