abdrive360 library v0.9.2 Differential servo drive library for the Parallax ActivityBot 360

- Main Page
- Files

- File List
- Globals

abdrive360.h
Go to the documentation of this file.
1
36 #ifndef ABDRIVE360_H
37 #define ABDRIVE360_H
38
39 #if defined(__cplusplus)
40 extern "C" {
41 #endif
42
43
44 #include "simpletools.h"
45 #include "servo360.h"
46
47
48 #ifndef DOXYGEN_SHOULD_SKIP_THIS
49
50 #ifndef ABD360_GOTO_BUSY
51 #define ABD360_GOTO_BUSY 1
52 #endif
53
54 #ifndef ABD360_GOTO_CLEAR
55 #define ABD360_GOTO_CLEAR 0
56 #endif
57
58 #ifndef ABD360_GOTO_BLOCK
59 #define ABD360_GOTO_BLOCK 0
60 #endif
61
62 #ifndef ABD360_GOTO_SET_FORGET
63 #define ABD360_GOTO_SET_FORGET 1
64 #endif
65
66 #ifndef AB360_NEITHER
67 #define AB360_NEITHER 0
68 #endif
69
70 #ifndef AB360_LEFT
71 #define AB360_LEFT 1
72 #endif
73
74 #ifndef AB360_RIGHT
75 #define AB360_RIGHT 2
76 #endif
77
78 #ifndef FOR_GOTO
79 #define FOR_GOTO 1
80 #endif
81
82 #ifndef FOR_SPEED
83 #define FOR_SPEED 0
84 #endif
85
86 #ifndef OFF
87 #define OFF 0
88 #endif
89
90 #ifndef ON
91 #define ON 1
92 #endif
93
94 #ifndef SIDE_LEFT
95 #define SIDE_LEFT 0
96 #endif
97
98 #ifndef SIDE_RIGHT
99 #define SIDE_RIGHT 1
100 #endif
101
102 #ifndef SIDE_BOTH
103 #define SIDE_BOTH 2
104 #endif
105
106 #ifndef ABD60_PIN_CTRL_L
107 #define ABD60_PIN_CTRL_L 12
108 #endif
109
110 #ifndef ABD60_PIN_FB_L
111 #define ABD60_PIN_FB_L 14
112 #endif
113
114 #ifndef ABD360_PIN_CTRL_R
115 #define ABD360_PIN_CTRL_R 13
116 #endif
117
118 #ifndef ABD360_PIN_FB_R
119 #define ABD360_PIN_FB_R 15
120 #endif
121
122 #ifndef ABD360_UNITS_REV
123 #define ABD360_UNITS_REV 64
124 #endif
125
126 #ifndef ABD_RAMP_STEP
127 #define ABD_RAMP_STEP 12
128 #endif
129
130 #ifndef ABD_SPEED_LIMIT
131 #define ABD_SPEED_LIMIT 128
132 #endif
133
134 #ifndef ABD_GOTO_SPEED_LIMIT
135 #define ABD_GOTO_SPEED_LIMIT 64
136 #endif
137
138 #ifndef ABD_GOTO_RAMP_STEP
139 #define ABD_GOTO_RAMP_STEP 8
140 #endif
141
142
143 //#define ABD_NUDGE_SPEED 4
144 //#define ABD_STOP_50ths 5
145
146 #ifndef _AB360_EE_Start_
147 #define _AB360_EE_Start_ 63418
148 #endif
149
150 #ifndef _AB360_EE_Pins_
151 #define _AB360_EE_Pins_ 12
152 #endif
153
154 // y = mx + b for transfer function separated into above (ccw) and below (cw)
155 // zero speed deadband pulse width. m sets slope, b sets transition pulse
156 // width from zero speed to motion. If not found in EEPROM, default values
157 // from servo360 library are used.
158
159 #ifndef _AB360_EE_mVccwL_
160 #define _AB360_EE_mVccwL_ 28
161 #endif
162
163 #ifndef _AB360_EE_bVccwL_
164 #define _AB360_EE_bVccwL_ 32
165 #endif
166
167 #ifndef _AB360_EE_mVcwL_
168 #define _AB360_EE_mVcwL_ 36
169 #endif
170
171 #ifndef _AB360_EE_bVcwL_
172 #define _AB360_EE_bVcwL_ 40
173 #endif
174
175 #ifndef _AB360_EE_mVccwR_
176 #define _AB360_EE_mVccwR_ 44
177 #endif
178
179 #ifndef _AB360_EE_bVccwR_
180 #define _AB360_EE_bVccwR_ 48
181 #endif
182
183 #ifndef _AB360_EE_mVcwR_
184 #define _AB360_EE_mVcwR_ 52
185 #endif
186
187 #ifndef _AB360_EE_bVcwR_
188 #define _AB360_EE_bVcwR_ 56
189 #endif
190
191 #ifndef _AB360_EE_End_
192 #define _AB360_EE_End_ _AB360_EE_Start_ + 60
193 #endif
194
195
196 extern volatile int abd360_initialized;
197
198 extern volatile int abd360_unitsPerRev;
199
200 extern volatile int abd360_pinCtrlLeft;
201 extern volatile int abd360_pinCtrlRight;
202 extern volatile int abd360_pinFbLeft;
203 extern volatile int abd360_pinFbRight;
204
205 extern volatile int abd360_speedLimit;
206 extern volatile int abd360_rampStep;
207 extern volatile int abd360_setRampStep;
208 extern volatile int abd360_speedLimitGoto;
209 extern volatile int abd360_rampStepGoto;
210
211 extern volatile int abd360_gotoMode;
212
213
214 void drive_init(void);
215 void drive360_ticksPerRev(int units);
216
217
218
219 #endif // DOXYGEN_SHOULD_SKIP_THIS
220
221
222
233 void drive_speed(int left, int right);
234
235
251 void drive_goto(int distLeft, int distRight);
252
253
263 void drive_getTicks(int *left, int *right);
264
265
274 void drive_getTicksCalc(int *left, int *right);
275
276
277
300 void drive_servoPins(int controlPinLeft, int controlPinRight);
301
302
316 void drive_encoderPins(int encPinLeft, int encPinRight);
317
318
332 void drive_setMaxVelocity(int forGotoOrSpeed, int ticksPerSec);
333
334
344 void drive_setAcceleration(int forGotoOrSpeed, int ticksPerSecSq);
345
346
358 void drive_gotoMode(int mode);
359
360
372 int drive_gotoStatus(int side);
373
374
375
381 void drive_feedback(int enabled);
382
383
384
392 //void drive_calibrationResults(void);
393 //void drive_setErrorLimit(int maxDistDiffTicks);
394
403 void drive_setMaxSpeed(int speed);
404
405
413 void drive_setRampStep(int stepsize);
414
415
429 void drive_rampStep(int left, int right);
430
431
442 void drive_ramp(int left, int right);
443
444
445
452 #if defined(__cplusplus)
453 }
454 #endif
455 /* __cplusplus */
456 #endif
457 /* ABDRIVE360_H */
458
459
482 //