Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

speed_cntr.h

Go to the documentation of this file.
00001 /*This file has been prepared for Doxygen automatic documentation generation.*/ 00021 #ifndef SPEED_CNTR_H 00022 #define SPEED_CNTR_H 00023 00030 typedef struct { 00032 unsigned char run_state : 3; 00034 unsigned char dir : 1; 00036 unsigned int step_delay; 00038 unsigned int decel_start; 00040 signed int decel_val; 00042 signed int min_delay; 00044 signed int accel_count; 00045 } speedRampData; 00046 00052 // Timer/Counter 1 running on 3,686MHz / 8 = 460,75kHz (2,17uS). (T1-FREQ 460750) 00053 #define T1_FREQ 460750 00054 00056 #define FSPR 200 00057 00058 #ifdef HALFSTEPS 00059 #define SPR (FSPR*2) 00060 #pragma message("[speed_cntr.c] *** Using Halfsteps ***") 00061 #endif 00062 #ifdef FULLSTEPS 00063 #define SPR FSPR 00064 #pragma message("[speed_cntr.c] *** Using Fullsteps ***") 00065 #endif 00066 #ifndef HALFSTEPS 00067 #ifndef FULLSTEPS 00068 #error FULLSTEPS/HALFSTEPS not defined! 00069 #endif 00070 #endif 00071 00072 // Maths constants. To simplify maths when calculating in speed_cntr_Move(). 00073 #define ALPHA (2*3.14159/SPR) // 2*pi/spr 00074 #define A_T_x100 ((long)(ALPHA*T1_FREQ*100)) // (ALPHA / T1_FREQ)*100 00075 #define T1_FREQ_148 ((int)((T1_FREQ*0.676)/100)) // divided by 100 and scaled by 0.676 00076 #define A_SQ (long)(ALPHA*2*10000000000) // ALPHA*2*10000000000 00077 #define A_x20000 (int)(ALPHA*20000) // ALPHA*20000 00078 00079 // Speed ramp states 00080 #define STOP 0 00081 #define ACCEL 1 00082 #define DECEL 2 00083 #define RUN 3 00084 00085 void speed_cntr_Move(signed int step, unsigned int accel, unsigned int decel, unsigned int speed); 00086 void speed_cntr_Init_Timer1(void); 00087 static unsigned long sqrt(unsigned long v); 00088 unsigned int min(unsigned int x, unsigned int y); 00089 00091 extern struct GLOBAL_FLAGS status; 00092 00093 #endif

Generated on Mon May 8 15:05:03 2006 for AVR446 - Linear speed control of stepper motor by doxygen 1.3.7