Skip to content. | Skip to navigation

Personal tools

remote/tilt.h

remote/tilt.h

remote/tilt.h

/////////////////////////////////////////////////////////////////////////////
// TILT.H
//
//  Last updated: 31/1/2005
//
//  Part of the source code for the remote M3 Program
//
//  Contains routines for motion and status of M3 Mirror Tilt motors and LVDTs
/////////////////////////////////////////////////////////////////////////////

// Tilt Stepper Motions
#define TMStop 		0
#define TMOut		 	1		// "Out" = pushing the mirror away from the frame
#define TMIn			2		// "In"  = pulling the mirror back to the frame

// Tilt Move Results
#define TRSuccess			0
#define TRUserAbort  	1

// Largest number of tilt steps allowed per move
#define TiltMax			100

///////////////////
// Servo Constants
//
// Maximum position error: once the position servo does better than
// this error (in V), the servo turns off.
#define TiltServoError		0.1
// Steps to go for an error of 1.0 V  ... this should be lower than reality
// to insure the servo converges
#define TiltServoRatio		20
// Servo should try for this long (in seconds) and then give up
#define TiltServoTimeout  60

// Tilt Stepper Bits (For A,B,C)
int TBitMon[3] = {22,19,16};
int TBitDir[3] = {23,20,17};
int TBitStep[3] = {24,21,18};

/////////////////////////////////////////////////////////////////////////////
// CTilt - An object that represents the three Tilt motors
class CTilt {
	public:
	volatile int Motion[3],OldMotion[3];
	// Current and previous motion status (see TM bits)
  int Moving[3];
  // Flag, 1 if there's any motion at all
  int MoveStep[3];
  // Current step in move process
	int Dir[3],Stp[3],Mon[3],Pwr[3],Cur[3],Brk[3];
	// Stepper status bits
	volatile int MonStep[3];
	// Motor phases
	int InitialPulse;
	// Initial pulse in ms for the motion profile
  // Defined in M3.INI file
	float Acceleration;
	// Acceleration/Deceleration in steps/sec/sec
  // Defined in M3.INI file
	float MaxVelocity;
	// Maximum velocity in steps/sec
  // Defined in M3.INI file
	float FastestStep;
	// The shortest pulse in ms the computer can generate (found by a timed test move)
	float Kstepmm;
	// Steps per millimeter ratio for each stepper motor (steps/mm)
	// (all 3 considered the same)
	float KKA,KKB,KKC;
	// Constants given by the geometry of the M3 cell in millimeters
	int *Profile;
	// Array describing the acceleration profile, with each array element
	// being a number of FastestSteps.
	int MaxProfile;
	// Index of highest (last) profile in the Profile array
  int BrakeTimer[3];		// Time brake release
  int StepperTimer[3];	// Time stepper power up
  // Servo variables
  int ServoTimer;				// Time the servo to a commanded position
  int ServoFlag;				// Flags if the tilt servo is active
  float ServoTarget[3];	// Target servo positions

  //////////////////
  // Variables for communication with the interrupt routine
  int direction[3];							// Direction of motion
  volatile int movesteps[3];		// Steps left to move
  volatile int tempsteps[3];		// Used to store step count until stepper power is ready
  volatile int pulsecount[3];		// Counts clock ticks, to set output bit appropriately
	volatile int profileindex[3];	// Position in motion profile
  volatile int tempresult[3];		// Temporary storage for return code
  volatile int moveresult[3];		// Result of motion
  volatile int abortmove[3];		// Flag to abort motion (due to user interrupt or limit)

  //////////////////
  // Methods
	void Init();
	// Initialize all variables, perform timed motion test
	void Update();
	// Update all motion, positions, status, etc.
	void DisplayAll();
	// Display all variable information on-screen
	void DisplayBrake();
	// Display brake status on-screen
	void DisplayAnalogData();
	// Display analog tilt data on-screen
	void DisplayMotion(int tilt);
	// Display motion status on-screen
	void DisplayStepper(int tilt);
	// Display stepper status bits on-screen
	private:
	int analogcount;  				// Current analog channel (LVDT) being displayed
	double OldAnalogData[4];	// Previous analog LVDT data displayed
  int BrakeFlag;						// Counts how many tilts are keeping brakes off
  /*
	int OldBrake;             // Previous brake status
  */
} Tilt;

Generated by GNU Enscript 1.6.5.2.
Document Actions