Template for LPC1768
Dependencies: Gimbal MLX90620 Socket lwip-eth lwip-sys lwip mbed-rtos mbed
Fork of EkkoEye by
Diff: CGimbal.h
- Revision:
- 53:72f350a6d09c
diff -r 53b1625b8035 -r 72f350a6d09c CGimbal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CGimbal.h Thu Apr 14 13:45:38 2016 +0100 @@ -0,0 +1,74 @@ +/* + * CGimbal.h + * + * Created on: 15 Feb 2016 + * Author: mike + */ +#ifndef CGIMBAL_H_ +#define CGIMBAL_H_ + +#include "mbed.h" + +#define FORWARD 0 // Used for the direction pin +#define REVERSE 1 // Used for the direction pin +#define CLOCKWISE 0 // Used for the direction pin +#define ANTICLOCKWISE 1 // Used for the direction pin +#define DFT_STEP_PULSE 0.00002 // 20us is recommended pulse width for most stepper drivers +#define X_AXIS 0 // Used for Tour array indexing +#define Y_AXIS 1 // Used for Tour array indexing +#define NUM_AXES 2 // Used for Tour array indexing +#define DEGREES_PER_STEP .1125 // 0.45 & 200 steps per revolution give 360/3200 degrees per step (1/16microsteps) +#define DFT_STEP_INTERVAL 250 // Normal time interval between pulses (5ms = 250 * 20us) +#define HOME_STEP_INTERVAL 500 // Moves more slowly when homing (10ms = 250 * 20us) +#define MAX_TOUR 10 // Maximum number of way-points that can be performed in a single tour + +class CGimbal +{ + public: + + DigitalOut * m_pXStepPin; // Pointer to the X axis step pin + DigitalOut * m_pXDirPin; // Pointer to the Y axis step pin + DigitalOut * m_pYStepPin; // Pointer to the X axis direction pin + DigitalOut * m_pYDirPin; // Pointer to the Y axis direction pin + + // Constructor + CGimbal(DigitalOut * pXStepPin, DigitalOut * pXDirPin, DigitalOut * pYStepPin, DigitalOut * pYDirPin); + + // Destructor + ~CGimbal(); + + void Zero(void); + void Home(void); // Move to the Home position + int MoveRel(); // Move (x, y) relative to current position + int MoveAbs(float x, float y); // Move to Absolute (x,y) position + int RotateAbs(float xAngle, float yAngle); // Rotate to Absolute (x,y) angle in degrees + int TourPoint(int n); // Execute a tour using n stored waypoints + void MeanderScan(void); // Perform a full sweep at increments of (60, 15) degrees + + int m_StepInterval; // The time in 10us increments between each Step pulse (ie 100 = 1ms) + int m_AbsoluteXPos; // The current motor x axis position in steps (800 per revolution) + int m_AbsoluteYPos; // The current motor y axis position in steps (800 per revolution) + + float m_AbsoluteXAngle; // The current motor x axis angle in degrees + float m_AbsoluteYAngle; // The current motor y axis angle in degrees + + int m_xSteps; // Tracks the number of required x steps (+/-) when moving relative or absolute + int m_ySteps; // Tracks the number of required y steps (+/-) when moving relative or absolute + int m_xPulses; // Tracks the number of required x pulses when moving (always a positive value) + int m_yPulses; // Tracks the number of required y pulses when moving (always a positive value) + int m_xDir; // X Direction: Used internally when moving, calculated from m_xSteps 1 to move ccw, 0 to move cw + int m_yDir; // Y Direction: Used internally when moving, calculated from m_xSteps 1 to move ccw, 0 to move cw + + int m_NumWaypoints; + float m_TourPoints [NUM_AXES] [MAX_TOUR]; // Used to store the x,y way-points received from the server + float m_PointTemperature [MAX_TOUR]; // Used to store the x,y way-points received from the server + + + int m_TickCount; // Used to track the number of 10us Ticks that have occurred to ensure consistent motor speed + +}; + + + + +#endif /* CGIMBAL_H_ */