This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Defines | |
#define | __attribute__(x) |
Functions | |
char | __attribute__ ((unused)) encoder_h[]="$Id |
int | encoderInit (ENCODER_STRUCT *enc) |
int | encoderSetCountsPerRev (ENCODER_STRUCT *enc, int countsPerRev) |
int | encoderGetCountsPerRev (ENCODER_STRUCT *enc) |
int | encoderGetCounts (ENCODER_STRUCT *enc, double position) |
int | encoderCalibrate (ENCODER_STRUCT *enc) |
int | encoderNoCalibrate (ENCODER_STRUCT *enc) |
int | encoderIsCalibrating (ENCODER_STRUCT *enc) |
int | encoderIniLoad (ENCODER_STRUCT *enc, const char *filename, const char *section) |
Variables | |
ENCODER_STRUCT |
|
|
|
Definition at line 33 of file encoder.h. 00033 : encoder.h,v 1.2 2000/10/27 20:34:42 terrylr Exp $"; 00034 00035 typedef struct 00036 { 00037 /* parameters */ 00038 int countsPerRev; /* counts per motor shaft revolution */ 00039 00040 /* internal vars */ 00041 int configured; 00042 int counts; 00043 int calibrating; 00044 double offset; 00045 double lastPosition; 00046 int index; /* count where index pulse was */ 00047 00048 } ENCODER_STRUCT; |
|
Definition at line 138 of file encoder.c. 00139 { 00140 if (0 == enc || 00141 enc->configured != ALL_SET) 00142 { 00143 return -1; 00144 } 00145 00146 enc->calibrating = 1; 00147 00148 return 0; 00149 } |
|
Definition at line 112 of file encoder.c. Referenced by simEncoderRead().
00113 { 00114 if (0 == enc || 00115 enc->configured != ALL_SET) 00116 { 00117 return 0; 00118 } 00119 00120 if (enc->calibrating) 00121 { 00122 /* see if range [lastPosition, position] includes a multiple of 00123 TWO_PI. If so, we saw an index pulse */ 00124 if (sawIndex(position, enc->lastPosition)) 00125 { 00126 enc->offset = position - fmod(position, TWO_PI); 00127 enc->calibrating = 0; 00128 } 00129 } 00130 00131 enc->counts = (int) (((double) enc->countsPerRev) * 00132 ((position - enc->offset) / TWO_PI)); 00133 enc->lastPosition = position; 00134 00135 return enc->counts; 00136 } |
|
Definition at line 101 of file encoder.c. 00102 { 00103 if (0 == enc || 00104 ! (enc->configured & COUNTS_PER_REV_SET)) 00105 { 00106 return 0; 00107 } 00108 00109 return enc->countsPerRev; 00110 } |
|
Definition at line 173 of file encoder.c. Referenced by __attribute__(), and main().
00174 { 00175 #ifndef NO_STDIO_SUPPORT 00176 00177 int countsPerRev; 00178 int retval = 0; 00179 const char *inistring; 00180 #ifndef UNDER_CE 00181 FILE *fp; 00182 00183 if (NULL == (fp = fopen(filename, "r"))) 00184 { 00185 rcs_print_error( "can't open ini file %s\n", filename); 00186 return -1; 00187 } 00188 #else 00189 INET_FILE *fp; 00190 00191 if (NULL == (fp = inet_file_open(filename, "r"))) 00192 { 00193 rcs_print_error( "can't open ini file %s\n", filename); 00194 return -1; 00195 } 00196 #endif 00197 00198 if (NULL != (inistring = iniFind(fp, "COUNTS_PER_REV", section))) 00199 { 00200 #ifndef UNDER_CE 00201 if (1 != sscanf((char *) inistring, "%d", &countsPerRev)) 00202 { 00203 /* found, but invalid */ 00204 rcs_print_error( "invalid COUNTS_PER_REV: %s\n", inistring); 00205 retval = -1; 00206 } 00207 else 00208 { 00209 encoderSetCountsPerRev(enc, countsPerRev); 00210 } 00211 #else 00212 countsPerRev = atol(inistring); 00213 encoderSetCountsPerRev(enc, countsPerRev); 00214 #endif 00215 00216 } 00217 00218 /* close inifile */ 00219 #ifndef UNDER_CE 00220 fclose(fp); 00221 #else 00222 inet_file_close(fp); 00223 #endif 00224 00225 return retval; 00226 00227 #else 00228 00229 return -1; 00230 00231 #endif 00232 } |
|
Definition at line 66 of file encoder.c. 00067 { 00068 if (0 == enc) 00069 { 00070 return -1; 00071 } 00072 00073 /* parameters */ 00074 enc->countsPerRev = 0; 00075 00076 /* internal vars */ 00077 enc->configured = 0; 00078 enc->counts = 0; 00079 enc->calibrating = 0; 00080 enc->offset = 0.0; 00081 enc->lastPosition = 0.0; 00082 enc->index = 0; 00083 00084 return 0; 00085 } |
|
Definition at line 163 of file encoder.c. 00164 { 00165 if (0 == enc) 00166 { 00167 return -1; 00168 } 00169 00170 return enc->calibrating; 00171 } |
|
Definition at line 151 of file encoder.c. 00152 { 00153 if (0 == enc) 00154 { 00155 return -1; 00156 } 00157 00158 enc->calibrating = 0; 00159 00160 return 0; 00161 } |
|
Definition at line 87 of file encoder.c. Referenced by encoderIniLoad().
00088 { 00089 if (0 == enc || 00090 countsPerRev <= 0) 00091 { 00092 return -1; 00093 } 00094 00095 enc->countsPerRev = countsPerRev; 00096 enc->configured |= COUNTS_PER_REV_SET; 00097 00098 return 0; 00099 } |
|
|