• Main Page
  • Classes
  • Files
  • File List
  • File Members

qemotoruser.h

Go to the documentation of this file.
00001 //
00002 // begin license header
00003 //  
00004 // This file is part of Terk and TerkOS.
00005 //
00006 // All Terk and TerkOS source code is provided under the terms of the 
00007 // GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html).  
00008 // Those wishing to use Terk and TerkOS source code, software and/or
00009 // technologies under different licensing terms should contact us at 
00010 // [email protected]. Such licensing terms are available for
00011 // all portions of the Terk and TerkOS codebase presented here.
00012 //
00013 // end license header
00014 //
00015 
00016 #ifndef _QEMOTORUSER_H
00017 #define _QEMOTORUSER_H
00018 
00019 #include "qemotor.h"
00020 #include "singleton.h"
00021 
00022 #define QEM_DEVICE                      "/dev/qemot"
00023 #define QEM_OFFSET_UPPER_THRESHOLD      150*16 // 16 is the number of bemf measurements
00024 #define QEM_OFFSET_WINDOW_SCALE         9
00025 #define QEM_OFFSET_WINDOW               (1<<QEM_OFFSET_WINDOW_SCALE)
00026 #define QEM_INIT_TIMEOUT                (1<<(QEM_OFFSET_WINDOW_SCALE+2))
00027 #define QEM_DELAY                       9
00028 #define QEM_PERIOD                      110
00029 #define QEM_WRITE_QUEUE_SIZE            5*sizeof(long)
00030 
00031 class CQwerkHardware;
00032 
00052 class CQEMotorUser  
00053 {
00054 public:
00058   SINGLETON(CQEMotorUser);
00059 
00064   unsigned int GetFrequency();
00065 
00073   int          SetFrequency(unsigned int freq);
00074 
00082   virtual Axis_position GetPosition(unsigned int axis);             
00083 
00088   virtual void GetPositionVector(Axis_position position[]);  
00089 
00100   void         SetPWM(unsigned int axis, int pwm);
00101 
00108   int          GetPWM(unsigned int axis);
00109 
00121   void         SetPIDVGains(unsigned int axis, unsigned int pGain, 
00122                            unsigned int iGain, unsigned int dGain,
00123                            unsigned int vGain);
00124 
00134   void         Hold(unsigned int axis, bool val);
00135 
00141   void         Stop(unsigned int axis);
00142 
00143   // other functions...
00150   void         SetPosition(unsigned int axis, Axis_position pos);
00151 
00152   long         GetVelocity(unsigned int axis); 
00153   void         GetVelocityVector(long velocity[]);
00154   void         SetCalibrate(unsigned int axis, unsigned int cal);
00155   void         SetTiming(unsigned int axis, unsigned int waitInterval);
00156   bool         GetDone(unsigned int axis);
00157   void         HandleOffset();
00158   void         FlushWriteQueue(unsigned int axis);
00159   void         SetWriteQueueSize(unsigned int size);
00160 
00161 protected:
00162   CQEMotorUser();
00163   virtual ~CQEMotorUser();
00164 
00165   int ConstructCall(int axis, int findex, ...);
00166 
00167   unsigned int m_servoAxes;
00168   int m_handle[QEMOT_NUM_MOTORS];
00169 };
00170 
00171 #endif

Generated on Mon Oct 3 2011 15:36:31 for libqwerk by  doxygen 1.7.1