That’s a nice way to start, but you have to code out your autonomous routine, and that can make it harder to tweak.
The method I use is arrays. Yes, fun old arrays.
For Example:
const int Func[13][3] = {
{84, 170, 40},
{170,170,60},
{84,170,20},
{170,170,30},
{84,170,20},
{170,170,30},
{84,170,20},
{170,170,60},
{84,170,40},
{170,170,30},
{84,170,20},
{170,170,30},
{84,170,40}
};
Then you only need a simple strand of general cod in your Process_Master_uP routine:
if (F_Count < MAX_FUNC)
{
counter ++;
if (counter > Func01[F_Count][2])
{
counter =0;
F_Count ++;
}
if (F_Count == MAX_FUNC) //Comment out this if for no loop.
{
F_Count = 0;
counter = 0;
}
pwm02 = Func01[F_Count][0];
pwm01 = Func01[F_Count][1];
}
Now, you could shorten this down to a 2D array, since all the variable in Column 2 are the same. I left it open because I change that array around alot. You could increase the dimensions so several different auto modes could be within one array, and the switch could be applied to one array element.
(BTW, for those of you out there who would like to tinker a bit, what does the array listed above do? HINT: It writes something. PWM01 is the left drive(facing reverse) and PWM02 is the right)
Now, someone may come along and tell you that it’s a rough process mapping out all your array values and hard coding them in, but I solve this with my own program, that I’m working on called eduCAD. The program gets a spec sheet on your edubot, generates some basic variables for use and calculation etc. Then you draw out the path of motion for the bot. It then calculates all the data to form a final array which is dumped to a custom include file that contains different auto arrays.
I plan on posting eduCAD on CD once it’s more complete. I just planned on making it more usable with the full robot as well, however, and I’m working on making it a win32 prog(rather than DOS
)
Anyway, if you have any specific questions, just PM me, I’m more than willing to help with any programming issues anyone’s having.