Steering a Beobot?

I have used a 3d printer to make a steering mechanism for a refabricated beobot to be controlled by an ir remote. The steering uses a standard servo.

Is it possible to write a program that will allow me to send steering instructions (e.g. turn left gradually) to the Beobot while it moves forward or backwards? I’ve tried using loops of various kinds but the results aren’t pretty - the drive motors judder when the steering is activated and and I cant figure out how to make the steering smooth and variable.
Essentially I cant see how to make one servo do something while another servo is doing something else and have both of them respond to Ir commands!

Any help would be appreciated.

Hi,

As a general idea, whenever you need to do multiple things at the same time and that they involve different timings (ex: moving forward at a certain while turning gradually), you would want to rely on timers and interrupts.

If you only need to make a small test/prototype, you could do this in one main loop with counters. Here is a rough example:

while(true)
{
// Get IR commands
result = Check_IR_commands();

// Decide on action based on last command
switch(result)
{
  CASE 1:
code ... 
break;
  case 2:
code ... 
break;
 ...
  default:
break;
}

// Increment counters
counterForward += 1;
counterTurning += 5;

// Check forward action
if(counterForward >= ???)
{
  code to change state of forward action (based on current state + last IR command) ...
  counterForward = 0;
}

if(counterTurning >= ???)
{
  code to change state of turning action (based on current state + last IR command) ...
  counterTurning = 0;
}

// Change output to motors
code to update forward ...
code to update turning ...
};

Of course, this is a rough skeleton and you will need some thinking into how you want the turning to work. The values ??? and the ones incrementing the counters (after +=) will depend on your CPU clock and the rate at which you want those actions to take place.

In general, most of these projects can be divided into simple finite state machines and can be built by following the principle a simple method such as:

]read inputs/:m]
]change states/:m]
]create/update outputs/:m]This type of structure allows for easy debugging when issues with the logic arise (they always do :slight_smile: ).

Good luck with your project!

Sincerely,

Many thanks. I’ll give this a try