Let's Make Robots!

How to keep pixace controlled robot from getting stuck?


I have built my first robot after advice of  LMR start here. So my robot is navigating with help of IR sensor and has those standard geared motors.

 I'm wondering if picaxe can read information from motors if the robot gets stuck. I guess motor makes some noise in such a situation?Can pushing against some obstacle with rubberwheels on harm picaxe?

I would be grateful for any piece of advice!


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Are we trying to PREVENT getting stuck and thus, are looking for answers about distance sensors and the like? --or-- Are we wondering what to do after the obstcal avoidance didn't work and we are CURRENTLY stuck against a wall, etc?


This sounds more like philosofical question for me :) If you could be sure that distance sensors never fail, that would be enough to prevents stucking.You wouldn't never mind the situation where robot has a problem. For my robot it is quite optimistic to rely on one longrange sharp IR sensor, so i originally thought that the very reliable way to make my little innocent cleaning robot able to survive in this wicked world would be monitoring the motors. But now i think its simply to  do it with bumber switches.


For Frits comment. I thought of comparing distance values but its a little bit hard job as my robot is scanning frontal sector and thus distance changes  all the times anyway .

But thank you for comments

I'd just see if the suroundings changed when I was moving. You know; If wheels are moving, but sensor is not making difference accordingly, you are stuck :)

I thought I'd try using a optical mouse camera/LED/prism to see if the surface under the bot is moving or not. Just a theory, nothing I've put into practice yet, but an idea for ya to chew on.


The parts from the mouse they use are available as components so you can do away with all the extraneous mouse material. This method has a limited range (~1/4") and may be useless to you.

Thats cool idea too. I have to check out if somebody has a spare optical mouse somewhere. I'm not sure if this is beyond my skills, as im quite a newbie robotbuilder :)

Thank you for helping!

Although monitoring current seems to be good option in long run i'll try first combination of LDRs for close range warning system and some kind of encoder based on hall effect sensors.

I studied ways of calculating suitable resistor to divide voltage for analogue input. However I couldn't find answer for some questions.

1. Can i actually use any resistor? is this only question of setting sensible range for a typical situation of your LDR or is it possible that too little or too high resistance in total (LDR and resistor) can cause damage for picaxe?

2. Could it be possible to have several LDR connected in series and to have one Vout for them?

3. I was planning to have one LDR measuring overall light intensity and some in front to detect obsctacles. Would it work if i connected "overall" LDR to ground and another to Vin? would this balace the changes in overall light intensity so that dangerlevel wouldn't be achieved too easily when having dim overall light?

Your questions:

1) Can i actually use any resistor? (and can it damage picaxe?)

Any resistor will work, but you need to remember that the picaxe inputs and outputs should never go above 20 milliamps continuous current, and all inputs and outputs together should not go above 90 milliamps.  For this reason it is a good idea to put a resistor in the lead connecting to picaxe. Usually this can be in the range of 220 to 330 ohms.

2)  possible to have several LDR connected in series?

Yes, it is, but probably will not help.  The LDR is a variable resistor which varies according to the light hitting it.  Several in series then is just like putting several resistors in series.  The total ohms is the total of the individual ones added together.

3) one LDR measuring overall light intensity and some in front to detect obsctacles?

Yes, as long as you do it the way you said and have one aimed so it picks up only background light (no focusing lens and perhaps even with a ground glass or smoky plastic that disperses the light).  As per the the discussion with IgnobleGnome, be sure you put a series resistor towards the picaxe. In most cases, it should be at least 220 ohms. (10K is not necessary.)

Another method I have used is to check the light from the ldr and then turn on "headlights" which are ultra-bright leds pointing straight ahead and if the resistance of the ldr goes down, then there is an obstacle.  This is not necessary though. Your method will also work.


I think the configuration below would work for a single LDR. Setting the resistor value close to the LDR's value when in dim light should help it work OK in most lighting conditions. Be sure the resistor value isn't too low, so that there is protection from 5V power to ground when the LDR value is close to zero in bright light.

I = V / R

So 1k ohm gives you 5mA at 5V, which should be safe. Use at least 1k for the resistor; 10k is even better. If your 5V supply is not clean/regulated, you might include a 1k ohm in series with the LDR as well.


I like the concept you introduce in question #3, where you balance the detection LDR with another LDR to sense the ambient lighting conditions. However, let's take a closer look:

Here you are creating a dangerous condition, where you can short your power to ground. No good!

However, your basic concept if valid. See below.

I have never tried this, but I think it will be safe and should work. Depending on your LDRs, you may have to play with the resistor values a bit. The bottom LDR would be pointed straight up to sense ambient light. The object detecting LDR will be placed in front of the robot, and will detect dark when it is blocked.


Another way to sense ambient light with the first setup is to take a quick analog reading when your robot starts up. As long as the LDR is not blocked during start up, you will now have an ambient light reading to compare against.

Yet one more idea is to install an LED mounted next to the detection LDR. Insert the LDR in a piece of shrink wrap, so it can only see light from directly ahead. Now your LDR will detect the reflected light from the LED when it is close to an object.

Good luck. I hope I have given you some food for thought.

Thank you very much indeed for clear answer.

I had last night (must always wait children and wife are sleeping) some experiments with LDRs on my breadboard. This setting of two LDRs worked fine, actually i think it worked best with a bit smaller resistors than 10k. Originally i had idea that if i put another LDR into a tube, the resistance wouldn't ever go near 0 but your setting is smarter.

Having "two LDRs voltagedividesytem" gives me another idea: this way you can compare values of two LDRs with a single analogue input. when for example right LDR connected to V gets more light than LDR connected to ground it gives different voltage to input compared to reverse lighting situation. I hope you understand what i mean. I think having both dimmed gives also difference in voltage because if both LDRs resistance vary together, another (connected to ground i suppose) affects more. I have to try this  out next.

on monitoring current, you should check http://letsmakerobots.com/node/18517 .