Category Archives: sensor

Comparing the ADXRS610 and ADXRS642 gyros

Analog Devices recently release new vibration rejection gyros which seemed a perfect fit for use on a micromouse. Since I was using the ADXRS610 on Zeetah V, I temporarily mounted an ADXRS642 to ZV to compare the two.

Posted in Hardware, Micromouse, sensor | Tagged , , , | Leave a comment

Choosing an emitter for micromouse sensors

Most commonly, micromouse reflective sensors use Infra Red LEDs as the emitter component. That is all very well and suits many, or most, phototransistors. the thing is, you cannot easily see where they are pointing and what kind of illumination … Continue reading

Posted in Micromouse, sensor | Leave a comment

Sensor Alternatives to the TSL262

The TSL262 sensor has been popular with a number of micromouse builders. It is compact, easy to use and results in a low component count. A common alternative is the use of a simple phototransistor in an emitter foloower configuration. … Continue reading

Posted in Micromouse, sensor | 5 Comments

Measure angular error using front sensors

The front, or forward-facing, sensors on a micromouse have several uses. Apart from detecting the distance to walls ahead and obstacles on one side or another, properly setup forward sensors can be used to measure an angular error with respect … Continue reading

Posted in Micromouse, sensor | Leave a comment

Front Sensor Replacement

Reliable front wall sensors on a micromouse are essential. Those on Decimus 2A were anything but so they needed to be replaced. Continue reading

Posted in Micromouse, sensor | 1 Comment

Pointing the sensors

How do you decide where to point the sensors?

I haven’t seen too much discussion on where to point the sensors. The few images I’ve seen show the mouse laterally centered with the diagonal sensors pointed at the pegs for an orthogonal as well as diagonal cell. What is not clear is where the mouse should be longitudinally.
I think the longitudinal location should be a function of the turn radius (and vice versa). The further forward the sensors look, the sooner the mouse can detect the side openings. However, this also means that when it finishes a turn, it may be looking too far forward to do correction or see the pegs.
The other design choice is what should the sensor angle be?
For the sake of this discussion, imagine that a sensor pointed forward (along the longitudinal axis) has an angle of 0 deg. and a sensor pointed directly towards the wall (along the lateral axis) has an angle of 90 deg.
As the sensor angle decreases, the emitter energy reflected by the wall decreases which means that the detector response goes does. Also, as the sensor angle decreases, a change in the mouse angle has a larger effect on the detector’s response.
So, my design target has been to put the mouse in the middle of a cell and then locate the sensors such that they can see the longitudinal peg and maximize the angle of the sensor. Since nothing is for free, as you maximize the angle of the sensor, you have to move it further away from the center of the mouse which means you are increasing the sensor’s rotational inertia contribution.
For the longest time, I wondered why people were crossing the diagonal sensors i.e. the sensor on the left side of the mouse looked at the right wall and vice versa? The answer turns out to be that they were trying to minimize the rotational inertia! Since light drops off at 1/distance^2 (Peter has some graphs in one of his blog posts), this means they were trading off sensor performance also.
As they say, mouse design is full of compromises.
You might want to move paper cut outs of the mouse along with pieces of paper showing the sensor location and angle through a maze to get an idea of different sensor angles. Alternatively, you might be able to do this with a CAD program – my CAD skills are too limited for me to have tried this.

Continue reading

Posted in sensor | Tagged , , | 1 Comment

Eliminating the wall sensors on Zeetah V

What are the wall sensor used for? Are they worth it?

After looking at the sensor configurations of the winning mice a year or so ago, we decided to follow their lead and implement something similar.

This means two front facing sensors that look directly in front of the mouse. Two diagonal facing sensors that look at the side walls at an angle. Two perpendicular wall facing sensors that look direclty at the side walls.

The thinking is that the front wall and diagonal sensor are used for navigation/correction and the wall sensors are used to determine the presence/absence of walls, and to look for edges for longitudinal correction.

Since then, mice have started eliminating the wall sensors. In fact, the code that Zeetah V (ZV) used at the Japanese contest this year, used only the front and diagonal sensors. Also, due to an accident, two traces for the right wall sensor were damaged.

So, the thought has been, why not eliminate the wall sensors? It turns out that for the ZV sensor configuration, during diagonals, the wall sensor would have been helpful but beyond that one case, there was no other benefit. In fact, using the wall sensor for wall state determination meant that ZV had to go further into the cell before it could make that decision than if we continued to use the diagonal sensor.

The wall sensors are also the furthest element from the center on ZV. So what, you ask? The sensor blocks weigh 1.75gms each (3.5gms total out of 100gms for the mouse) but they contribute 11% of the rotational inertia!

They are now history…

Continue reading

Posted in sensor | Tagged | Leave a comment

Simpler sensor emitters

Simpler is often a good thing. For the new mouse, I wanted to make the sensor arrangement as simple as possible. One way is to drive the emitters from the battery supply…

In the past, I have always driven the sensor emitters from a regulated voltage. The main reason is that the brightness of the emitters will not change as the battery voltage drops dirung a run. A down side is that you will be generating fairly large pulses on the regulated logic supply and this is a potential source of noise. Looking at pictures of mice, it was apparent that Kato’s Tetra and Bee have the sensor emitters connected directly to the battery supply. On the face of it, this is not a good idea since battery vopltage can vary quite a lot while the mouse is running around. Nonetheless, it seems to work well enough for him so how can that be?

A simple test rig has a sensor connected to an Arduino since these are wonderfully flexible and easy to use for this kind of experiment. The detector is connected in the usual way but the emitter has its anode connected to the bench supply. Now it is possible to set up a wall at a fixed distance and measure the output from the detector with various different supply voltages. What we hope for here is a linear relationship between the supply vltage and the sensor reading. If that is the case, simple scaling arithmetic will allow us to measure the supply voltage and calculate a correction for the sensor reading to make it independant of the supply. If the result is non-linear, then life gets more difficult and correcting for the supply voltage is tricky. Here are the results form a quick experiment:

The results are not perfect because the experiment was cobbled together on the desk with whatever came to hand and there was a fair bit of noise. But there is a clear linear relationship between supply voltage and sensor reading. This is just what I would hope for. For the new mouse, it mean I can completely eliminate a voltage regulator whose only job would have been to provide a stable supply for the emitters.


Continue reading

Posted in sensor | 7 Comments

Calibrating Reflective Sensors

By far the most commonly used micromouse sensors are simple reflective types that give an indication of distance by measuring how much light is reflected from the maze wall. While the response is repeatable and related to distance, it is quite difficult to get an accurate answer. This is how the sensor readings can be converted into an actual distance…
This type of sensor has many limitations. The reading depends upon the angle between the emitter and the wall, the reflectivity of the wall itself and the geometry of the emitter and detector. For more experiments about the effect of the angle, look at this earlier post.

Typically, a narrow-beam Infra Red LED shines a spot of light onto the maze wall and a photodiode or phototransistor measures the light level. Two readings can be taken. The first is done with the emitter of and the second with the emitter on. The difference between the two readings should be due almost entirely to the effect of the emitter so that you can cancel out the effect of the ambient light. It is worth pointing out two problems with this technique, not related to the walls. First, the sensitivity of the detector will be affected by the ambient light level so you cannot entirely eliminate this. Second, the detector may be close to saturation with the emitter off as a result of high ambient light levels so that turning on the emitter does not produce a reading as high as it would be in the absence of ambient illumination.

My mouse has six sensor assemblies. Two face almost sideways, two face diagonally at around 45 degrees to the direction of travel and two more face nearly forwards, in front of the mouse. To measure the response of these sensors, the mouse was place on a moving platform (the cross-slide of my lathe) and a wall arranged appropriately to the mouse axis in orientation seen by a correctly positioned mouse. Thus, for the forward sensor readings, the mouse faced the wall directly with the wall perpendicular to the long axis of the mouse. For the side and diagonal sensor tests, the wall was place parallel to the long axis of the mouse. Now the distance between the edge of the mouse and the wall can be changed accurately in fixed steps and readings taken from the sensors. I chose steps of 6mm to keep the volume of manually collected data manageable. The edge of the mouse is used for distance measurements rather than the centre of the mouse because this feels more practical. When the distance gets to zero, the mouse is in contact with the wall. the results for all six sensors can be seen in this chart:

Here the raw ADC value is plotted against distance. You can see immediately that the reading is not linearly related to the distance although it is monotonic beyond about 15mm. That is, increasing the distance always makes the reading decrease. at distances of less than 15mm, the shape of the graph changes. Mostly, this is because the physical arrangement of the emitter-detector pair on my mouse means that the spot of light is not visible by the detector when the wall is very close. this is a design flaw that could be largely corrected. It does not generally cause any trouble because, by the time you are within 15mm of a wall, you are already in trouble and the exact distance is not terribly relevant. You should also notice that the forward sensors are less affected close to the wall. This is by design to make it more reliable when gauging distance to the wall ahead for aligning the mouse

The various sensors have different sized responses even though they were all very carefully aligned to specific geometries when the mouse was assembled. Manufacturing tolerances mean that, for the same current, each emitter will be a slightly different brightness and, for a given level of illumination, each detector will give a different response. While it would be possible to buy in large numbers of emitters and detectors and select matching pairs, that is not a practical, or economic solution.

What is reasonably clear, however, is that the shape of the graph for each sensor is very similar even though they have different orientations to the wall. If we suppose that each curve is determined by the same equation but with different constants, it should be possible to determine the appropriate constants for each sensor and convert the reading into a reliable measure of distance.

The question is – what equation would generate the shape that we see.

Excel lets you fit a trend line to the data but none of the available options gave a convincing fit. To cut a long story short, eventually I found a function that gave a very good fit to the data:

Where y is the sensor reading, x is the distance to the wall, and a and b are constants which will be different for each sensor and the reflectivity of the walls.

Taking the left front sensor data as an example, we can calculate that the appropriate values for a and b in the test setup are 1182 and 176 respectively. Plotting both the fitted and the original data on the same axes give us this result:

This fits the data so well that the variation can only be seen at very short distances where we know that other effects change the response of the sensor.

Now that it is possible to determine a function that fits the results, it can be manipulated so that, for a given sensor reading, the distance can be determined. Rearranging the equation above gives us:

Again, y is the sensor reading and x is the distance. By now you will probably have thought of a couple of problems with this approach. First, how do you determine the constants a and b, and how much work will it be to calculate a natural logarithm and a divide for each sensor reading, bearing in mind that we want to do six of these every millisecond or so.

Taking the second problem first, I pre-calculated a table of natural logarithms for all values of 1 to 1023. Since I have a 10 bit ADC, this quickly allows me to look up the logarithm directly from the sensor reading. Inconveniently, logarithms are fractional values but that is easily fixed by pre-multiplying each by 65536 to give a 16.16 fixed point value in the table. If the constant a is also scaled by the same amount, the result of the division gives us an integer result. All we need worry about then is a 32 bit divide which is not overly burdensome on a fast processor like the dsPIC or STM32. If you have a slower processor, you will want to optimise that a bit more. For example, you could generate a 16 bit value with 12 bits for the fractional part and leave yourself with a 16 bit divide.

How well does it work? Well, here is a chart showing the calculated distance, in mm against the actual distances recorded from the raw data.

The correspondence between the two is remarkably good and well within the various errors that are unavoidable with this type of sensor.

So, how to calculate the constants? The equation above has two unknowns, an and b. All we require are two sensor readings at known distances from the walls and a bit of gentle algebra will allow us to work those out. One of the sets of readings can be taken with the mouse placed as close as possible to the centre of a maze cell. using this as one of your fixed points ensures that the fitted curve will be that little bit more accurate at that distance. The other point is most conveniently having the mouse hard up against the far wall for each sensor. This is a known distance which, by the magic of geometry is easy to determine from the dimensions of your mouse. I will leave the task of figuring out how to calculate a and b as an exercise for the reader so that you feel that you have actively participated.

It may occur to you that there is a potential problem with this technique as the distances get larger. Since typical sensor readings at a distance of 100mm or so are down to, perhaps 60 out of a range of 1023, the effect of small changes in sensor reading is proportionately much larger. The method will be very reliable over the range 20-100mm and progressively less reliable beyond that. However, I have found good results at distances up to 150mm where typical sensor readings are down to about 35. Even then, a difference in sensor reading of just one bit changes the calculated distance by about 3mm. At that range, it is not a serious issue.

There are only a couple of occasions where long range sensing is important unless you are trying to map walls in adjacent cells without visiting them. When exploring, it is important to be able to detect a wall ahead as soon as you can. When the front of the mouse enters a cell, the far wall will be about 170mm away. It is easy to tell that a wall is there and the error in its measured position will be relatively large but, at this stage relatively unimportant. As the mouse wheels cross the threshold, the far wall will be a about 130mm away – well within reliable enough measurement range. Bear in mind that wall reflectivity plays a crucial role in this business and the walls I have – all Korean – show variations as great as 10% in the extreme so really accurate measurements using just reflective light are a bit of a pipe-dream anyway.

Another time you see apparently distant walls is when passing a lone post. if your emitter beam-width is large compared to the size of a post, the amount of light reflected is less that it would be from a section of wall at the same distance. Consequently, the post will appear to be a section of wall way off in the distance. You need to look out for that and compensate accordingly. On Decimus2, the most advantageously positioned sensors – the side-looking pair – see a lone post at an apparent distance of about 75mm while a wall would appear to be about 42mm away.

Addendum:

The chart below shows actual results from the mouse in part of the maze:

Here the mouse starts off in the middle of a cell with walls on either side and then runs down a short section with only perpendicular walls on either side – a comb. The side sensor results, converted to distance are plotted with the right side represented as a negative number. It is fairly clear that the posts generate a smaller response and that the calibration generates good results out to beyond a perceived 150mm. As the distance gets larger, the effects of quantisation on small sensor readings are also apparent. If there had been a parallel wall at the far side of the adjacent cell, it would have been about 240mm away from the mouse. At that distance, the response is down into the noise region and the sensors, as configured, would not be able to detect it. I cannot recall whether there were walls present for this trial.

Continue reading

Posted in sensor | 5 Comments

Sensors and shiny maze walls.

Among the various thing you will hear said by contestants at a micromouse contest, the topic of walls will frequently come up. Generally in some disparaging way that indicates that the walls are in some sense to blame for their misfortune. I have certainly said so more than once but what effect do shiny walls have?

Today, I decided to do some experiments and find out. The idea was to test a couple of sensor types and different walls to see what the effect of angle alone had on the sensor response for each wall type. The results were a bit surprising.

The test setup is shown below:

Walls are placed on a rotary table so that the front surface was exactly over the center of rotation. They were kept aligned with the help of magnets on the surface of the table which also served to hold down a disk of black card to represent the maze floor. In this way, reflections from the floor should be reduced. The rotary table can be turned by repeatable amounts as small as 1/6 of a degree if necessary.

The emitter under test was placed on a solderless breadboard and connected up exactly as it might be in a micromouse. In this case, that meant it was connected in series with a 5.6Ohm resistor to the 5V supply and switched on an off through a ULN 2803 darlington.

The emitter pulses are generated by an arduino board. The timing is non-critical but consistent so that the results can all be compared. For each reading, the sensor was read 32 times and averaged before the reading was sent to the computer for entry into a spreadsheet and subsequent graphing. Sensor readings are the difference between the sensor value without the emitter and the value with the emitter to eliminate the effect of ambient light.

Once set up, readings are taken every 2.5 degrees and plotted on a graph over the range 60 to 120 degrees. That is, with the emitter +/- 30 degrees from perpendicular. Moderate care was taken to try and get the emitter reasonably perpendicular to the wall in all directions. This could (and should) have been done better. The emitter light pattern was arranged to be, as much as possible, centered over the center of rotation of the wall. With these precautions taken, the average distance from the emitter to the wall would remain constant at 60mm. the detector was placed to one side of the emitter. It would have been better if it had been directly above or below.

The test wall set included

  • a wall with the face covered by a piece of white laser printer paper to provide a flat, non-specular reflection that should be very uniform cross its surface.
  • A standard Korean plastic wall as used in many mazes. this was arranged so tha the emitter illuminated the wall half way between the dips in the surface caused by shrinkage over the internal webs.
  • A new Taiwanese plastic wall since these are visibly very shiny.
  • An old, melamine-covered wall with a smooth surface which does not appear very shiny.

 

So, what did the results look like:

First we have a SFH409 IR LED. It has a peak emission at 950nm and is well matched to the TSL252 used as a detector. Beamwidth according to the data sheet is +/- 20 degrees – very wide. Here are the response curves:

As expected, the paper surface gives the smoothest response. it is clear that the emitter was not well positioned with respect to the 90 degree angle but it was left untouched so all the curves were directly comparable. The Korean walls were the least reflective. Melamine gave a good response which varied smoothly with angle. Both the Taiwanese and the Korean walls gave an uneven response. this is no simple artifact and was repeatable. The polar emission graph of the SFH409 gives a clue:

Here you can see that the emitted light is not even and the slope of the polar chart drops off at about +/- 10 degrees. This corresponds roughly to the pattern seen in the response curves. The shinier Taiwanese walls enhance this effect.

Next, I tried a SFH4503. These are a powerful emitter that I use in my current mice. They have a much narrower beam angle. According to the data sheet, this is +/- 4 degrees. Here are the results:

This time I had the emitter pointing slightly off axis in the other direction. No matter. The vertical scale shows just how much more light is being put out by these emitters compared to the SFH409. More light means better signal-to-noise so that is good. Again, the paper surface has the smoothest response. However, see now the effect of shininess. First, there is a very marked peak in the response on shiny walls with the Taiwanese being most affected. A change in the angle of incidence by only 5 degrees could cause a change in response of 25%. No wonder I sometimes struggle with my forward sensors. These are pointed right at the wall and it would not take much of an angular error to make their readings nonsense. You will also see that the shape of the response is not good with two distinct peaks appearing at about 10 degrees off axis with the Taiwan walls. So, even if I had the sensors angled, I would still suffer from apparent distance changes cause by small angular changes. The polar diagram for the SHF4503 looks like this:

You can clearly see the additional lobes in the response at 10 degrees. When viewed with an IR camera this shows as an annular ring of light around the central spot.

OK – so what about a laser. These have a clearly defined spot of light and we can easily see it so what could be bad? The laser in this test was a random 5mW module found on eBay. It it driven using the exact same circuit as the LEDs. Here is its response:

For this test an TSL252 was used as the detector since the TSL262 has a daylight filter to exclude visible light. Apart from that, I believe they are identical devices. Although visibly bright, rather smaller readings come back using the laser. Here you can see that the small spot of the laser seems to accentuate the specular effect of shiny surfaces. That is, the amount of light reflected close to perpendicular is much greater than when off-axis. Now my first thought was that this is just due to the shininess of the surface but it is apparent that the effect is much less with a shiny Taiwanese wall than it is with a relatively dull melamine wall.

 

Some time ago, I was reading about laser target designators. That text spoke of guided munitions having to be within the ‘cone’ of laser light reflected from the target before they could successfully home in on the target. So, consider a surface that is all specular – light a mirror. The reflected light from that is all specular and consists of the original beam leaving at the angle of incidence. You would have to be directly in line with that to see it at all but then it would be very bright. A less shiny surface will have most of the light behave like the mirror but a small amount will be reflected in a diffuse manner. However, being shiny the cone of diffuse reflection will be very narrow and mostly along the axis of the reflected beam. So, when the beam is reflected back close to the detector, there will be the spike we see from the Taiwanese walls but, because the surface is more shiny, the spike will be small and narrow because we are not very close to the axis of the reflected bean and not much energy goes into the cone. Paradoxically then, surfaces that are still shiny but which have a greater diffuse component have a wider cone of diffusely reflected light making it more likely that the detector sees it. Thus we see a wider and larger response. Paper, having essentially no specular component to its reflection gives a suitably smooth, even response.

What can we conclude?

Well, it would be nice if contest maze walls were all faced with printer paper but I don’t suppose that will happen.

First, lasers are attractive but I think great care needs to be taken to ensure they are not used anywhere near perpendicular to a wall surface. This might be tricky to arrange but an angle of, say, 30 degrees should be fairly safe in keeping the beam at least 15 degrees off perpendicular for all surfaces. Forward facing sensors are tricky though and might need considerably more cunning to keep them reliable.

IR emitters (or visible light for that matter) need more care than I had suspected. Having chosen the SFH4503 for its narrow beam and high output, I had not considered the effect of the secondary lobes with shiny walls. Although I was aware there could be an issue with specular reflection, I had not thought it might be so large. Looking at the results for the SFH409, it might be better to choose an emitter with a wider beam rather than a narrower one. Perhaps +/- 10 degrees and no (or minimal) sidelobes.

A quick look at the OPE5594A favoured by Ng Beng Kiat shows it to have exactly those characteristics. So, let’s give that a go:

Pretty good. In fact these are about what I would have hoped for in the first place. Perhaps it is not such a bad thing that the SFH4503 is no longer available. Time to hit the datasheets to see what else might be suitable.

 

Continue reading

Posted in sensor | 6 Comments