Robotics Circuit DiagramsSensors - Tranducers Circuits

An Obstacle Detecting Robot Schematic Circuit Diagram

When first trying our hand at robotics, we’re generally in a hurry to build a mobile robot that has a degree of autonomy. It’s with this aim in mind that we’ve produced this article, to enable you, in record time, to build a mobile robot capable of detecting and avoiding obstacles. Of course, given the relative simplicity of the solutions employed, it will be fairly easy to catch it out, but as long as you take a little care over the obstacles it might encounter, it’ll still create quite an impression. And you’ll be able to use this starting point as a springboard for your own development. To deal with the mechanical issues that often pose problems for many amateur robot-builders, we’re making use of a ‘Rogue Blue’ base (www.roguerobotics. com), sold as a kit and very easy to assemble without special tools. What’s more, this kit is distributed in France by Lextronic (, who can dispatch to any of the neighboring countries.

An Obstacle Detecting Robot Schematic Circuit Diagram 1

An Obstacle Detecting Robot Schematic Circuit Diagram 2

As you can see from the photo, it consists of two pre-cut circular plates able to accommodate two radio-control servos, used as traction motors. Supplied with the base, these come already modified (as explained elsewhere in this issue) to enable them to turn continuously. Two wheels with large-diameter tires are also provided, fixing directly onto the servo shafts, while the front and rear of the robot’s lower plate have PTFE ‘skids’ taking the place of a jockey wheel. Some self-adhesive Velcro lets us secure a battery holder for primary cells or rechargeables between the two circular plates, leaving the whole of the top plate free for the electronics. Given the supply voltage for the servos and the electronics, we have wed a 4-cell battery holder that tales four 1.5 V AA (R6) cells, and will also take rechargeable NiMH batteries of the same size, in the event of intensive use. So as to get our robot up and running quickly, we’ve used a ‘whisker’-type obstacle detector. To achieve this, we use two long-lever microswitches — or two ordi-nary lever-operated microswitches with a few centimeters of piano wire soldered to them – mounted on the top plate. They are positioned at an angle of around 45-60° to each other, with their centrelines intersecting on the robot’s front/back centreline. This gives us one obstacle detector on the front right, and another on the front left. The robot’s brain is entrusted to a Cubloc CB 220 module from Comfile Technology, allowing us to both write a very simple program and build an equally simple electronic circuit, as you can see from the diagram. Ports PO and P1 of the Cubloc are programmed as inputs and receive the information coming from the obstacle detectors.

Normally low, they go high when one or other of the whiskers is activated, i.e., in the presence of an obstacle. Ports P5 and P6 are programmed as outputs and drive the propulsion servos. The choice of these ports is vital, as the Cubloc’s PWM signal-generating instruction we are going to be using only works with these. The servos are powered directly from the pack of four 1.5 V cells, while we use the Cubloc’s VIN input so as to take advantage of its built-in 5 V regulator. However, if you are going to use NiMH rechargeables instead of primary cells, you’ll have to use the VDD input to power the Cubloc, as in this case the voltage available is only 4.8 V. Connector DB9 is designed for connecting the Cubloc to a PC, to program it with the software we’ll be suggesting in a moment. Given the simplicity of the circuit, it can be built on perforated prototyping board or on a CB220-Proto test board, which comes with this connector already pre-wired. The software needed to control the whole thing is very simple, even for someone with only faint notions about programming. The Cubloc’s Basic language is both simple and very powerful.

The source listing is available on the Elektor website, as well as the author’s own site (, but it’s so short, you can also just type it yourself directly into the Cubloc Studio editor, which is the Cubloc’s (free) development tool, and can be downloaded from The listing is very easy to analyze. After defining the type of Cubloc in use and the operating sense of the ports PO, P1, P5, and P6, we also define a variable ‘obstacle’. The main program can then commence, in the form of a continuous Do Loop. We start by testing for one or other of ports PO or P1 going high, and if this is the case, the robot is stopped by means of the two PWM instructions that follow. Given that we are using modified radio-control servos, remember they are stopped when they receive pulses of 1.5 ms; they rotate at full speed in one direction fo rms pulses, and at full speed in the other direction for 1 ms pulses. ote too that, as the servos are mounted in reverse orientations in the ogue Blue base, they need to rotate in opposite directions to make the robot go forwards or backward. Because of the mechanical and electrical tolerances, 1.5 ms pulses don’t always give exactly stop. So you may need to go back and tweak the first parameter of the PWM instructions (3410 in this example). Once the robot has stopped, we test to see if the left or right whisker has been activated, and set the variable ‘obstacle’ accordingly. One last test checks if both whiskers have been activated simultaneously, and if this is the case— meaning the robot has encountered an obstacle directly ahead — reverse drive is applied (2 ms pulses to one servo and 1 ms to the other). The variable ‘obstacle’ is then analyzed by means of a ‘select’ box that the Cubloc’s powerful Basic has borrowed from C. If the variable ‘obstacle’ has a value of 0, no obstacle has been encountered and our robot sets off forwards. If the variable ‘obstacle’ has a value of 1 or 2, an obstacle has been encountered to right or left, and so a quarter-turn is made in the opposite direction.

However, if the variable ‘obstacle’ has the value 3, an obstacle directly ahead has been encountered, and the robot does a complete U-turn. Watch out! Depending on what you call front/bade and left/right on your particular robot, you may need to swap around the successive PWM instructions in the listing we’ve just given, so that they do indeed produce the movements intended. You might also need to tweak the first parameter of the various PWM instructions. We explained the reason for this above for stop, but the same thing happens for rotation of the servos at full speed in one direction or the other. If your robot fails to travel in a straight line when running forwards or backward, it’s just because the servos are not turning at the same speed for pukes of the same width. In this case, all you have to do is make minor adjustments to the first parameter of one or the other of the PWM instructions in order to get correct results.

Don’t be afraid to, the Cubloc’s program memory is virtually infinitely reprogrammable (a minimum of 10,000 cycles guaranteed by the manufacturer of the microcontroller it’s fitted with!) After a certain period of use, you’ll doubtless realize the limitations of this robot.

Then it’s up to you to develop it, by adding, for example, obstacle detectors of the same type, but to the rear, an ultrasonic distant obstacle detector, a line-follower function, etc. This issue of Elektor already ought to give you some good ideas to get you started.


Related Articles

Leave a Reply

Your email address will not be published.

Back to top button