Tag Archives: TSL262

Feeling our way with sensors

The sensors are a critical part of a micromouse. Primus uses six infra-red reflective sensors. Here is code to test that they are working.Now that we have a nice display to show what the sensor reading are, we can get that module tested. Since the hardware is very simple, there is not a lot to go wrong. Yet somehow I had a dead sensor when I first tested the Primus prototype. It was a simple dry joint that would have been detected by more careful inspection of the board.This program just sets up the sensor hardware and activates each channel in turn. All six channels are then displayed on the screen as raw ADC values. there is no real need to scale these numbers. If it is working correctly, each channel should show values between nearly zero and about 700 or so.For best performance the sensors will need careful alignment. For now, just check that they are working. They should easily detect the presence of a wall at distances of 150mm and should not saturate until the wall is only about 35-40mm away.The reason the maximum value is only about 700 is that the TSL262 can only reach a maximum output value of around 3.5V. You should find that the sensors are relatively immune to ambient light levels although they will become less sensitive under very bright conditions. A black paper or card shield is needed over the TSL262s to reduce the effect of ambient light.The sensor module is also responsible for measuring battery voltage via a potential divider on the battery input. While not essential for use with NiMh or NiCd cells, it is particularly important that LiPo cells do not become discharged to too low a level. You program can monitor the battery voltage and sound an alarm or shut the mouse down if the battery voltage gets too low. The processor will carry on as long as the voltage into the regulator does not drop below about 7V so you should have plenty of time to avoid trouble.The project files can be downloaded here:primus4.zip Continue reading

Posted in Primus | Tagged , , | Leave a comment

Sensor test

The simple sensor circuit described by Ng Beng Kiat seems to give the best results.On his web site (http://www.np.edu.sg/alpha/nbk/) Beng Kiat describes Min4, one of his recent mice. In there is a PDF with schematics for the mouse. The sensor circuit for Primus is essentially the same except for a couple of component value changes. The emitters are run in series pairs from the 5V supply. Not shown here, a ULN2003 darlington driver does the switching.

Emitter circuit

The TSL262 is used as a detector. Although Beng Kiat’s circuit shows a Shottky diode, it is omitted from this version as tests indicate they serve no apparent purpose in this design. Another change is to the values of the AC coupling components. This has little discernable effect on the circuit operation but 33nf ceramic capacitors in a suitable size are relatively hard to come by whereas 100nF items are cheap and plentiful as they are used universally for power supply decoupling.

detector circuit

A simple test rig for this circuit allowed me to generate a graph of analogue reading against distance. The ADC is operating in 10 bit mode so full scale is 1023. Note that the TSL262 cannot bring its output above about 3.75V. although the data sheet indicates that this can be extended with a resistor from the output to Vdd, it seems to have little effect in this circuit.

Typical sensor response

While very non-linear, beyond abut 30mm, the results are completely monotonic. That is, as distance increases, reading always decreases. Closer than 30mm, the physical arrangement of the sensor assembly prevents the sensor from seeing the spot of light. It is not a good idea to compensate too much for this as we can arrange that the sensors are only used at distances greater than 40mm from a wall. Notice that it is quite easy to detet the presence of a wall at distances of at least 120mm. there is not, however, enough of a response to be sure of seeing a wall in an adjacent cell. Continue reading

Posted in Primus | Tagged , , , | Leave a comment