Micromouse Sensors

Ok, its been a while since I did much more than think about my micromouse, but over the last week or so I actually did some ‘work’ on the sensor design…

First off this is all theoretical, I need some bits an pieces before I can test this outside of simulation. Hopefully in the next week or so I will order the bits I need.

The problem: Knowing where you are in relation to the walls of a micromouse maze.

The solution: Sensors.

Commonly optical sensors are used which act upon the basic premise that the diameter of a cone of light will get bigger as it travels, hence the intensity of light over a specific sensing area will vary with the distance the light has traveled. There are also other factors such as scattering and the reflectivity of the surface etc. etc. but there is a correlation, that’s the main point.

I am concerned with detecting the intensity of the light reflected, and removing any noise. My current design assumes that I have a source transmitting IR light at 10KHz and a receiver which converts received light to a current (such as a phototransistor). First I convert this current to a usable voltage, then filter it to remove the noise and then I use a peak detect and hold circuit to get the sensor reading.

You can download the current circuit diagram here: Sensor Test Board - Design 1 (Remember - untested!)

Current to Voltage

Current to Voltage

This stage is quite simple, it takes the current and produces a voltage following the rule Vout = -Iin * R. The value of the resistor should be selected based on the current expected. I chose 66K as I am considering having some digital potentiometers in there, and that’s there value. Notice that the positive terminal of the opamp is connected to Vcc, this creates a virtual ground at Vcc allowing it to go from 5V down the 0V. Because of this the voltage is now ‘upside down’ so the next bit of the circuit fixes this.

Difference Amplifier

Difference Amplifier

This is a difference amplifier which takes Vcc and subtracts out voltage from it, meaning the signal goes from 0V to 5V. Although not shown here you could also add in a gain here if required. The formula is Vout = (V2 - V1) * (Rb / Ra) where Ra = R2 = R4, Rb = R3 = R5 and V1 is our voltage and V2 is shown here as Vcc.

Second Order High Pass Filter

Second Order Filter

This is a standard second order high pass filter set to 530Hz cut-off. Considering I am aiming for 10kHz modulation this is quite low, but its due to the fact that I started with 1kHz modulation. Changing the resistor values to 1K will change the cut-off to 1.6kHz which is probably a bit safer. The main noise I wanted to remove was DC and mains (50Hz), so the current values will suffice for now.

Peak Detection and Hold - With Reset

Peak Detection and Hold - With Reset

This is the one part of the circuit which is not required, but does help and remove any precise timing issues with converting the final voltage to a digital number. The two opamps create a peak detect and hold circuit. The voltage is ’stored’ in C3, the voltage here is compared with the current input on the left opamp, if it is higher the opamp acts as a voltage follower and increased the output. The opamp on the left is a buffer, I think R8 provides some current to keep C3 from discharging, its the only part of the circuit I don’t full understand yet. I added a mosfet to enable the capacitor to be discharged after the A/D has completed.

Simulation

Graph 1 Using LTSpice I simulated this circuit with 40uA and 50uA inputs, with a 5uA @ 50Hz ‘noise’ sign wave. Left is a small segment of the result. The dark blue signal is the output after the Difference Amplifier, the green signal is after the second order high pass filter, the red is the final output from the peak detect and hold, the light blue is the peak detectors reset signal and the pink is the 50Hz noise (scale in A and on other axis).

You can see the noise affecting the dark blue signal, and being removed at the peak of the green signal, and the result being held at this peak as required.

The complete simulation output can be found here by clicking on the following link:

Simulation Results

You can see the different current input being applied for the last two pulses.

Well, I hope this was all accurate, but if there are any issues please do email me! Hopefully I will be able to build the circuit soon and test it for real.

Posted in: Micromouse, Robots April 2008 Martyn


6 Responses to “Micromouse Sensors”

Siddharth Chinoy Says:

Hey, in your simulation, the output of the phototransistor signal after processing, peaks every 5ms. doesn’t that correspond to a modulation frequency of 200Hz? and you intend to modulate your IRED at 10khz, don’t you? Am I missing something?

The design looks good. Im in the process of testing a similiar circuit for my mouse as well. The ’sample and hold’ is a good idea. Im going to copy it :).

May 5th, 2008 at 1:23 pm

Martyn Says:

The IR LED is on for 0.1ms every cycle, so its a 10khz signal 200 times a second. Means that multiple sensors can be used without overlapping readings.

May 6th, 2008 at 1:51 pm

I dont think thats how it works. The waveform that you send to the 2nd order filter is a pwm signal with a *duty cycle* of 0.1/5=2% . The harmonic content of this waveform consists of frequencies which are integral multiples of 200Hz (which can be seen from its fourier transform). There is no 10khz in here anywhere. the pwm frequency determines your modulation frequency and the pwm duty cycle determines the burst current you can send through the IRED and hence the range.

Since the filter in your simulation attenuates frequencies only below 540Hz, not much of your original wave is lost (only the 200Hz and the 400Hz part was attenuated). but the moment you raise the cutoff frequency to 10khz or soemthing, a large part of your wave will be filtered out, which is not desirable.

Correct me if im wrong.

May 9th, 2008 at 10:08 am

Martyn Says:

Yes, you are correct, its been a while since I looked properly at filter design and the word fourier just sent shivers down my spine. Will dig out the right book and read up on it before I go further into development.

I been plowing through state space, optimal control theory and robot ethics notes for the past month or so and did not really research the ’system’ before writing the entry. I’ve developed this from work I did about a year ago and implemented on my first working mouse, so knew the ranges of values and what to expect when I put everything in the correct order.

Do you have any ideas on getting rid of the difference amplifier so the system sits around a single opamp chip?

May 9th, 2008 at 1:08 pm

What Im doing is instead of setting the virtual ground at V, I’m using V/2. So my output voltage will be (V/2)+(I*R). I ll choose an R so that my output doesnt saturate. Then the high pass filter will remove the V/2 and any other DC components present and amplify the signal so that peak value is just enough to lie in the linear region of the opamp(filter has some gain, which is yet to be decided). So in this way, I eliminate using the difference amplifier.

There is one problem. The reverse bias voltage across the photodiode is only V/2. so it *might* low pass the signal more than desired,in theory. To what extent, I have yet to find out.

[I think there might be a problem in your current to voltage converter. your output is V+IR. so your opamp will saturate unless your power supply is greater than V. Im assuming that the Iin in your diagram is a photodiode connected to ground in reverse bias.]

May 10th, 2008 at 10:54 pm

Martyn Says:

I am using a phototransistor so am dealing with currents rather than having to put a reverse bias voltage across a photodiode. (The datasheet stated response times are in the low uS for on and off and the cut of frequency is around a hundred kHz.)

While I was looking into transimpedance amplifiers I came across a Maxim-IC datasheet stating that with the reference on the non-inverting input the equation was Vout = Vref - IR, hence why the signal is inverted.

Is anoying having 5 op-amps per sensor, over 8 sensors that 40 op-amps, 10 ic’s take up a lot of space.

I might look into getting a multiplexer so I can reuse some of the opamps with other sensors, but that would probably have a large impact on time for each reading, add possible instabilities and make it more complicated all round.

Once exams are over I will build a prototype circuit, if it works out ok I will see how small a footprint I can squeze the circuit into.

May 12th, 2008 at 1:42 pm
Post A Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>