|
StepperII
Dual Axis Stepper Controller
|
00001 00002 #pragma once 00003 #include "CBitio.h" 00004 #include "CEepromVar.h" 00005 00006 #include "CProfile.h" 00007 #include "CStepPeriod.h" 00008 #include "CMotor.h" 00009 #include "CStepTimer.h" 00010 00011 class CStepper 00012 { 00013 private: 00014 static const char DEGREES = 0; 00015 static const char STEPS = 1; 00016 public: 00017 CProfile profile; 00018 CRunProfile runProfile; 00019 CStepPeriod avrStep; 00020 CMotor *pMotor; 00021 CStepTimer *pStepTimer; 00022 private: 00023 CBit(F, 0, RO_AL) homeSwitch; 00024 00025 int homeSwitchPosition; 00026 protected: 00027 00028 public: 00030 void init(uint8_t *s, CMotor *pMotor, CStepTimer *pStepTimer, const char axis, char consoleStatus = 0); // Manual initialization 00031 00032 void setSprIndex(int x); 00033 void setDirection(char); 00034 void brakeOn(void); 00035 void brakeOff(void); 00036 inline int readPosition(void); 00037 void writePosition(int x); 00038 00039 void step(int x); 00040 void stepTo(int position); 00041 void doPulse(void); 00042 void stepMotor(void); 00043 void on(char direction); 00044 void autoHome(void); 00045 void setHomeOffset(int offset); 00046 void changeSpeed(void); 00047 00048 void timerCompareA(void); 00049 void timerOverflow(void); 00050 00051 int indexToSteps(char index); 00052 char stepsToIndex(int steps); 00053 int stepsToMove(int x); 00054 int toSteps(int x); 00055 int toUnits(int x); 00056 }; 00057 00058 //----------------------------------------------------------------------------- 00059 // Returns position 00060 //----------------------------------------------------------------------------- 00061 inline int CStepper::readPosition(void) 00062 { 00063 return toUnits(runProfile.position); //<! Return position 00064 } 00065
1.7.3