disputedip.com

Micromouse Sensors

by Martyn on Apr.07, 2008, under Micromouse, Robots


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.



18 Comments for this entry

  • Siddharth Chinoy

    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 :).

  • Martyn

    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.

  • Siddharth Chinoy

    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.

  • Martyn

    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?

  • Siddharth Chinoy

    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.]

  • Martyn

    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.

  • Pranjal

    Liked the final stage of your circuit!

    CP

  • Martyn

    Heh, As soon as I get some parts through the post for my ‘newest’ sensor design (digital filters) I will proto up this circuit just to see if it works.

    Digital is the way to go I think, being able to adjust the filters is a great ability thats difficult to realise accuratly with analog setups…

  • Pranjal

    I was also thinking on the same lines….actually implemented a few digital filters on dsPICs at the MASTERS. But a bit unsure as to how to perform that peak detection digitally….filter output in the dsPIC is a very clean sinewave(thats what we were filtering)….also not sure whether dsPIC will be able to take load of 6 sensors. One more processor on board will definitely increase the complexity though…..

  • Martyn

    Hehe, I have on dspic per 4 sensors, and 8 in total (overkill ;)). But both boards are identical and just plug into an spi bus so the main controller can talk to them.

  • Pranjal

    Great…..’Cube Core’ processing!
    Do post the pics of your PCBs….it would be interesting to see how you have kept things so small

  • Martyn

    hehe, not fabbed yet, pleanty of room tho, I have two lower pcbs with 4 sensors and 1 pic + programmer header on each. And a large top pcb with a dspic33 (dual quad decoders, pleanty of ram etc.). Also have vishay motor driver chip (they sooo small).

    Regulated power for the motors, and two other power rails for various components.

    Also a pic32 on the top hocked up to a 3axis accelerometer and a two axis gyro and another single axis gyro. they are going through 16-bit a/d’s on a spi bus (they all sample at exactly the same time). Might also get another, better accelerometer, but they cost $50 each, so might just leave the relevant footprints in place.

    I will be doing some videos over the weekend talking about it and putting them on youtube…

  • Pranjal

    Gosh….thats a Quad processing core your mouse has got… :-)
    Btw, Why are you using the additional 1 axis gyro? 2 axis is good enough i guess….

    Also, if you want to tell, which drivers you are using….i just might order a few for myself too…. :-)

  • Martyn

    the 2 axis gives me pitch and roll, i am really only interested in yaw (epic fail)

    Driver is the si9986 ;) I will be doing an article soon on using it (although focussed more at controlling motors).

  • Pranjal

    I am waiting for it…!

    Drivers are great….but they require additional MOSFET driver ICs….dont they?

  • Martyn

    No, they contain everything they need. Peak output of 1.5A, my motors peak current is 1.2A (I assume when you put both ends in a clamp, or try and move a skyscraper…)

  • Pranjal

    Gr8 then….I am ordering them from Farnell!
    Yes, that 1.2A current will be drawn when someone will try to ride the micromouse….lol!

  • Pranjal

    I tried your PD&H circuit….you really dont need that Reset FET, it works just fine without it….

Leave a Reply

CAPTCHA image

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...