Mouse Technology

I was invited by LungHwa University of Science and Technology, Taiwan to conduct a one-day workshop in micromouse in April 2009. Here's the notes I used for the workshop. It's in English with some Chinese words for the Taiwaneses.

In most competition, the most crucial factor that determines a mouse performance is its turning speed. The other important factors are the straight speed, acceleration and deceleration. Of course the mouse must be able to run reliably. Maze solving algorithm is almost standard and does not affect the outcome as much. In most competition I had seen, the top mice took the same path and so the mouse speed is the deciding factor.

Body design

I get most of my ideas for my design from racing car design and the article "Building MITEE Mouse III", by David Otten.

For a mouse to be fast, powerful drive motors are required. The wheel must also be able to provide the traction required for the mouse to accelerate, decelerate and curve turn. This means that the tire must provide good grip. Material like ping pong bat rubber is a good candidate.

For fast acceleration, with a given motor, the mouse has to be as light as possible. For fast curve turn, the moment of inertia has to be low, which means packing all the heavy parts as close to the turning centre as possible. During turning, there isweight transfer to the outer wheels and the inner wheels lose grip. In order to reduce weight transfer, the mouse centre of gravity (cg) has to be low and the inner to outer wheel distance has to be wide. Of course, if the mouse is too wide, then it is more likely to knock against the maze walls, so there has to be a compromise. In general, having a mouse that is unnecessarily slim is bad for the curve turns.

Sensor designSide sensor is always preferred to top sensor as top sensor increases the mouse moment of inertia. All my mice use 3 pairs of side sensors.

The front sensors are used for reading of front wall information and collision detection. In general, the left and right sensors are compared and if one is much larger than the other, than a collision is likely. The front sensors are heavily relied upon during diagonal run.

The side sensors are used for reading of side wall information only.

The diagonal sensors are used for alignment, mainly during the non-diagonal run. Before running the mouse, the alignment sensors are calibrated so that the centre position sensors' readings are known. The amount of alignment is proportional to the amount of deviation from the centre value.

Sensor circuitry

SENSOR CIRCUITRY DIAGRAM NOT READY

Motion control

The mouse motion can be broken down into two basic parts. Straight run and curve turn. The motion controls for diagonal and non-diagonal straight run are the same except for the alignment. As for the various curve turns, the turn profiles are also the same except for the difference in turn speed, turn radius and turn distance.

Curve turn Speed Profile

The curve turns are all 'blind'. This means that no sensors are used to feedback info like how much the mouse had turned while doing curve turn. It also means that the various turns have to be tediously tuned to the best performance.

DIAGRAM SHOWING CurveTurnSpeedProfile

(For Min3G, a gyro is used to measure how much the mouse has turned, and this has enabled the mouse to turn more accurately. It is less affected by the varying tire grip condition. The gyro drift makes it difficult to sense angle accurately over a long period of time. But for a short fast turn, the drift is minimal, and the turn is fairly accurate.)

Straight Run Speed Profile

The straight run speed profile is as shown below.

I use the above speed profile as it is very simple to implement. The problem with such a profile is that the DC motor torque decreases with increasing speed, and hence the motor might not be able to deliver the required torque at the high speed end of the profile.

For every straight run, there is a desired top speed, ending speed, acceleration and deceleration. The profiler will try to generate a speed profile that ensure the mouse runs at the highest speed possible.

At the beginning of profile, the mouse is accelerating until the top speed is reached. At the same time, the profiler will check whether it is time to accelerate based on the following formula.

Where a = deceleration required

S1 = current speed

S2 = ending speed

D1 = distance left to travel

When the distance left to travel is the distance required to decelerate to the desired ending speed, the profiler will start to decelerate.

What's the values of acceleration and deceleration? Assuming that the drive motors are able to deliver the required torque, the values are determined by the tires' traction capability. For a very clean floor and tire condition, my mouse tires has a coefficient of friction of about 0.6. Under normal operating condition, it drops to about 0.4. So I chose a safe value of about 0.35, which gives me approximately 3.5m/s/s.

Alignment

Alignment is required to keep the mouse in the centre of the path, heading towards the right direction. Without alignment, the mouse will crash into the walls.

There are three types of alignment errors: heading error or angular offset error and lateral and longitudinal positional offset errors. Note that with the sensor configuration described above, the mouse cannot tell the difference between angular and lateral positional offset.

On normal straight run, the 45deg sensors and front sensors are used for angular and lateral position alignment. For the 45 deg sensors, the mouse needs to know the average sensors' values when it is in centre position, without any angular offset. Any sensors' value that deviate from the centre values indicates that there is an offset error. The error could be due to either heading or lateral position offset. Luckily, the correction needed for either offset is the same.

DIAGRAM SHOWING ALIGNMENT

A simple method of correction is to add an error correction that is a fixed percentage of the current mouse speed to both left and right wheels. A more refined method will be to add an error correction that is also proportional to the size of the sensor value deviation.

For diagonal straight run, the front sensors alone are sufficient for alignment. Again, take note of the values of sensors when there are no obstacle. Any reading above that indicates an obstacle.

There is another type of alignment error, the longitudinal positional offset error. This occurs typically due to wheel slippages. When the mouse is commanded to travel one square distance, it does not travel exactly one square. This problem is more serious for long straight run as the error accumulates. The solution is to use the side sensors to detect for wall-to-no-wall and no-wall-to-wall transitions. These transitions can be used to realign the mouse position.

DC motor control

The control block diagram is as shown below:

BLOCK DIAGRAM UNDER CONSTRUCTION

The speed profiler generates the speeds for the left and right wheels. Depending on whether the mouse is doing a straight run, curve turn or pivot turn, a different speed profile is generated. For example, for a straight run, the straight-run-profile described above will be generated. The output of the speed profiler is fed to the DC motor control loop.

As we are interested in the position of the mouse, position control is used. A simple proportional-derivated (PD) control is sufficient. In a simple implementation, there are two control loops, one for each of the two drive motors.

Buzzer

My mouse has a 4 characters display, a buzzer and a push button. They are use to effect a simple user interface for the mouse. The buzzer is also used to provide audio debugging signal. For example, when a wall to no wall transition is detected by the IR sensors, a constant frequency beep is make. The buzzer can be used to produce a bird-like chirping sound, which makes the mouse more interesting. Since I received many inquiries on how the sound is produced, I shall described it here.

I got the idea from a Korean micromouser, whom I met in Japan in 1997. Communication with the Korean wasn't exactly easy, but I think I managed to understand him.

Hardware description:

A buzzer driven by a microcontroller timer output pin through a 2003 darlington driver. Different buzzer has different frequency response, so some will sound better than others. The buzzer is first and foremost a debugging device. It's not a fancy stuff for entertainment. My mouse chirps only when it's not moving, as the chirping is rather CPU intensive.

Basically, the buzzer is driven by a square wave with either a rising or falling frequency profile. The profile shape, whether it is straight, exponential or other shape determine the kind of sound you can get. By having more complicated frequency profile (pause and combination of profile), you can get amazing kind of sound.

Here's the code for my mouse chirp:

//////////////////////////////////////////////

int base = 400;

void Bird() {

int n, i, p;

beepCnt = -1;

BEEP_START_STOP=1; //start timer

BEEP_CYCLE_FLAG=0; // clear flag

for (n=256; n>24; n--) {

BEEP_PERIOD=(-n+base); // equation for generating

sound profile

p = n/32+1; // determine number of

pulses

for (i=0; i<p; i++)

{

while(!BEEP_CYCLE_FLAG); //BEEP_CYCLE_FLAG set

when timer pulse

BEEP_CYCLE_FLAG=0;

}

}

BEEP_START_STOP=0; //stop TCNT

ITU.TOLR.BIT.TOA0=0; //o/p cleared

}

// Experiment with your own equation.

/////////////////////////////////////////

How do I use the buzzer? While, the mouse is running, I'll use the timer to generate a fixed frequency beep as and when I need to know certain info. For example, during a diagonal run, the mouse will generate a beep for every poles it detect. Frequencies is different for left and right poles. When the mouse align itself with the front wall with it's front sensor, it lets off another different frequency beep. I found such debugging to be much more convenient than led display. It has the side benefit of making the mouse more entertaining.

When the mouse found the center of maze, it chirps (everything is OK). When it could not find a path to home or destination due to a wrong maze update, it chirps for a longer period (error). I also have a simple user interface menu on my mouse and the buzzer is used to feedback the user selection.