|
StepperII
Dual Axis Stepper Controller
|
00001 /*This file has been prepared for Doxygen automatic documentation generation.*/ 00019 #pragma once 00020 00021 #include "CProfile.h" 00022 00029 //const long timerFreq = F_CPU / 8; // 8 is timer prescaler 00030 //const int T1_FREQ_148 = timerFreq * 0.676 / 100; // divided by 100 and scaled by 0.676 00031 00032 struct coefficients 00033 { 00034 const long A_T_x100; 00035 const long A_SQ; 00036 const int A_x20000; 00037 }; 00038 00045 class CStepPeriod 00046 { 00047 public: 00048 static const long timerFreq = F_CPU / 8; // 8 is timer prescaler 00049 private: 00050 static const int T1_FREQ_148 = timerFreq * 0.676 / 100; // divided by 100 and scaled by 0.676 00051 00052 static struct coefficients c[]; 00053 unsigned int decelStart; // What step_pos to start decelaration 00054 int decelVal; // Sets deceleration rate. 00055 unsigned int minDelay; // Minimum time delay (max speed) 00056 int accelCount; // Counter used when accel/decel 00057 // to calculate step_delay. 00058 unsigned int stepCount; // Counting steps in accel/decel modes 00059 unsigned int maxSpeedLimit; // Number of steps before max speed. 00060 unsigned int remainder; // Remainder from nextPeriod() to incrase accurancy 00061 00062 CProfile *profile; // Reference to axis profile 00063 CRunProfile *pRunProfile; // Reference to axis run profile 00064 00065 void nextPeriod(void); // Calculates stepDelay for next step 00066 unsigned long squareRoot(unsigned long x); // Calculates long square root 00067 00068 public: 00069 void init(CProfile *, CRunProfile *); 00070 void move(int step); 00071 void doStep(void); 00072 void changeSpeed(void); 00073 void off(void); 00074 }; 00075
1.7.3