abdrive360 library  v0.9.3
Differential servo drive library for the Parallax ActivityBot 360
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 
391 void drive_suppress_eeprom(int state);
392 
400 //void drive_calibrationResults(void);
401 //void drive_setErrorLimit(int maxDistDiffTicks);
402 
411 void drive_setMaxSpeed(int speed);
412 
413 
421 void drive_setRampStep(int stepsize);
422 
423 
437 void drive_rampStep(int left, int right);
438 
439 
450 void drive_ramp(int left, int right);
451 
452 
453 
460 #if defined(__cplusplus)
461 }
462 #endif
463 /* __cplusplus */
464 #endif
465 /* ABDRIVE360_H */
466 
467 
490  //
void drive_encoderPins(int encPinLeft, int encPinRight)
Sets feedback pins to values other than the default P14 for left and P15 for right. Stores values in EEPROM, so you only need to call this function at the start of one program. Programs that are run after that will get the modified port numbers from EEPROM.
Definition: drive_encoderPins.c:28
void drive_getTicks(int *left, int *right)
Get the measured number of ticks each servo has traveled since the program started running...
Definition: drive_getTicks.c:17
void drive_rampStep(int left, int right)
This function allows your code to ask for a speed repeatedly in a loop, but each time your code asks ...
Definition: drive_rampStep.c:17
void drive_ramp(int left, int right)
This function ramps up to a given speed and blocks execution until the speed is reached. In practice, a call to drive_speed followed by a pause to reach the desired speed will have the same effect but does not have practical applications.
Definition: drive_ramp.c:17
void drive_setAcceleration(int forGotoOrSpeed, int ticksPerSecSq)
Set the acceleration used by either drive_goto or drive_speed.
Definition: drive_setAcceleration.c:17
void drive_goto(int distLeft, int distRight)
Make the wheels travel a certain distance, measured in ticks. Each "tick" is a 64th of a wheel turn...
Definition: drive_goto.c:17
int drive_gotoStatus(int side)
After using drive_gotoMode(0) to cause the drive_goto function to not wait until the maneuver is done...
Definition: drive_gotoStatus.c:18
void drive_setMaxVelocity(int forGotoOrSpeed, int ticksPerSec)
Set the maximum velocity used by either drive_goto or drive_speed. The defaults are 128 ticks per se...
Definition: drive_setMaxVelocity.c:17
void drive_getTicksCalc(int *left, int *right)
Get the calculated number of 1/64th wheel revolution ticks the abdrive360 control system thinks each ...
Definition: drive_getTicksCalc.c:17
void drive_gotoMode(int mode)
Set the mode of the drive_goto call to blocking (default) or interruptible. For calls in interruptibl...
Definition: drive_gotoMode.c:19
void drive_suppress_eeprom(int state)
Enables or disables ignore calibration settings stored in EEPROM. This feature allows an ActivityBot...
Definition: abdrive360.c:40
void drive_speed(int left, int right)
Set wheel speeds in "ticks" per second. A tick is 1/64th of a revolution, and makes an ActivityBot 36...
Definition: drive_speed.c:17
void drive_setMaxSpeed(int speed)
Modifies the default maximum top speed for Feedback 360 high speed servos. For calls to drive_speed...
Definition: drive_setMaxSpeed.c:17
void drive_setRampStep(int stepsize)
Overrides the default 12 ticks/second per 50th of a second for ramping. Note: drive_setAcceleration i...
Definition: drive_setRampStep.c:17
void drive_servoPins(int controlPinLeft, int controlPinRight)
Sets servo pins to values other than the default P12 for the left servo and P13 for right servo...
Definition: drive_servoPins.c:31
void drive_feedback(int enabled)
Enables or disables encoder feedback for speed control.
Definition: drive_feedback.c:17