You can make a robot using only one motor driver chip and a couple of photocells. Depending on the method of connecting motors, microcircuit, and photocells, the robot will move into the light or, conversely, hide in the dark, run forward in search of light or back off like a mole. If you add a couple of bright LEDs to the robot circuit, you can make it run by hand and even follow a dark or light line.
The principle of the robot’s behavior is based on “photoreception” and is typical of a whole class BEAM robots. In wildlife, which our robot will emulate, photoreception is one of the main photobiological phenomena in which light acts as a source of information.
As a first experience, let's turn to the device BEAM-robotmoving forward when a ray of light falls on it, and stopping when light ceases to illuminate it. The behavior of such a robot is called photokinesis - an undirected increase or decrease in mobility in response to changes in the level of illumination.
In the robot device, in addition to the L293D motor driver chip, only one photocell and one electric motor will be used. As a photocell, you can use not only a phototransistor, but also a photodiode or photoresistor.
In the design of the robot, we use an n-p-n phototransistor structure as a photosensor. Phototransistors today are perhaps one of the most common types of optoelectronic devices and are distinguished by good sensitivity and quite reasonable price.
The figure shows the mounting and circuit diagrams of the robot, and if you are still not very familiar with the symbols, then, based on the two schemes, it is easy to understand the principle of designation and connection of elements. The wire connecting the various parts of the circuit to the ground (the negative pole of the power supply) is usually not fully depicted, but a small dash is drawn on the circuit to indicate that this place is connected to the ground. Sometimes three letters “GND” are written next to such a dash, which means “ground”. Vcc refers to the connection to the positive pole of the power supply. Instead of letters, Vcc is often written + 5V, thereby showing the voltage of the power source.
The principle of operation of the robot circuit is very simple. When a ray of light hits the phototransistor PTR1, a positive signal will appear at the input INPUT1 of the motor driver chip and motor M1 will begin to rotate. When the phototransistor stops lighting, the signal at input INPUT1 disappears, the motor stops rotating and the robot stops. You can read more about working with the engine driver in the previous article, “L293D Engine Driver”.
In order to compensate for the current passing through the phototransistor, a resistor R1 is introduced into the circuit, the nominal value of which can be selected about 200 Ohms. Not only the normal operation of the phototransistor, but also the sensitivity of the robot will depend on the value of the resistor R1. If the resistance of the resistor is large, then the robot will only respond to very bright light, if it is small, then the sensitivity will be higher. In any case, you should not use a resistor with a resistance of less than 100 ohms to protect the phototransistor from overheating and failure.
Make a robotrealizing the phototaxis reaction (directional movement towards or away from light), it is possible using two photosensors.
When light enters one of the photosensors of such a robot, the electric motor corresponding to the sensor is turned on and the robot turns in the direction of light until the light illuminates both photosensors and the second motor turns on. When both sensors are lit, the robot moves toward the light source. If one of the sensors ceases to be illuminated, the robot again turns toward the light source and, having reached the position at which light falls on both sensors, continues its movement into the light. If the light stops falling on the photosensors, the robot stops.
The robot circuit is symmetrical and consists of two parts, each of which controls the corresponding electric motor. In fact, it is, as it were, a doubled circuit of the previous robot. Photosensors should be placed criss-cross with respect to electric motors as shown in the figure of the robot above. You can also arrange the motors crosswise relative to the photosensors as shown in the wiring diagram below.
If we arrange the sensors according to the left figure, the robot will avoid light sources and its reactions will be similar to the behavior of a mole hiding from the light.
Make robot behavior it can be more lively by applying a positive signal to the INPUT2 and INPUT3 inputs (connecting them to the plus of the power supply): the robot will move in the absence of light incident on the photosensors, and "see" the light, it will turn towards its source. When light falls on both sensors, the robot will stop.
Dear Bobot, is it possible to use a simple robot in a reducible circuit? any other chips, for example L293DNE?
Of course you can, but you see what’s the matter, buddy Babbot. This L293D is only available in the ST Microelectronics group of companies. All other similar microcircuits are only substitutes or analogues of L293D. Such analogs include L293DNE of the American company Texas Instruments, SCP-3337 from Sensitron Semiconductor. Naturally, like many analogs, these microcircuits have their own differences, which you will need to consider when you will be making your robot.
Could you tell us about the differences that I will need to consider when using L293DNE.
With pleasure, old Babot. All chips of the L293D line have inputs compatible with TTL levels *, but some of them are not limited to level compatibility only. So, L293DNE has not only compatibility with TTL in terms of voltage levels, but also has inputs with classical TT-logic. That is, on an unconnected input there is a logical "1".
Sorry, Bobot, but I don’t quite understand: how can I take this into account?
If the L293DNE has a high level on an unconnected input (logical "1"), then we will have a high level signal on the corresponding output. If we now apply a high-level signal to the input in question, to put it another way - logical “1” (we connect with the “plus” of the power supply), then nothing will change at the corresponding output, since we had “1” at the input before that. If we apply a low level signal to our input (we connect it with a “minus” power supply), then the output state will change and there will be a low level voltage on it.
That is, it turns out the opposite: we controlled L293D using positive signals, and L293DNE must be controlled using negative signals.
L293D and L293DNE can be controlled both within the framework of negative logic and within the framework of positive *. In order to control the inputs of the L293DNE using positive signals, we will need to pull these inputs to the ground with pull-up resistors.
Then, in the absence of a positive signal, a logical “0” will be provided at the input, provided by a pull-up resistor. Cunning Yankees call such pull-down resistors, and when pulling a high level - pull-up.
As I understand it, all we need to add to the simple robot circuit, - so these are pull-up resistors to the inputs of the motor driver microcircuit.
You understood correctly, dear Babot. The value of these resistors can be selected about 4.7 kOhm. Then the circuit of the simplest robot will look as follows.
Moreover, the sensitivity of our robot will depend on the value of the resistor R1. The lower the resistance R1, the lower the sensitivity of the robot, and the higher it is, the higher the sensitivity.
And since in this case we do not need to control the motor in two directions, we can connect the second motor output directly to the ground. Which even simplifies the scheme a little.
And the last question. And in those robot circuitsthat you cited as part of our conversation, can the classic L293D chip be used?
Of course it can. And I would even add that using pull-down resistors for the L293D would be justified.
To make a robot, "running" at hand, we need two bright LEDs (on the diagram LED1 and LED2). We connect them through resistors R1 and R4 in order to compensate for the current flowing through them and protect them from failure. We place the LEDs next to the photosensors, directing their light in the same direction the photosensors are oriented, and remove the signal from the inputs INPUT2 and INPUT3.
The task of the resulting robot is to respond to the reflected light emitted by the LEDs. Turn on the robot and put your palm in front of one of the photosensors. The robot will turn towards the palm. Let's move the palm a little to the side so that it disappears from the field of view of one of the photosensors, in response the robot obediently turns around behind the palm like a dog.
LEDs should be selected bright enough so that reflected light is steadily captured by phototransistors. Good results can be achieved by using red or orange LEDs with a brightness of more than 1000 mcd.
If the robot responds to your hand only when it almost touches the photosensor, then you can try experimenting with a piece of white paper: the reflective abilities of a white sheet are much higher than that of a human hand, and the reaction of the robot to a white sheet will be much better and more stable.
White color has the highest reflective properties, black - the smallest. Based on this, you can make a robot following the line. Sensors should be positioned so that they are pointing down. The distance between the sensors should be slightly larger than the line width.
The scheme of the robot following the black line is identical to the previous one. To prevent the robot from losing the black line drawn on the white field, its width should be about 30 mm or wider. The robot behavior algorithm is quite simple. When both photosensors pick up light reflected from a white field, the robot moves forward. When one of the senosors enters the black line, the corresponding electric motor stops and the robot begins to turn, aligning its position. After both sensors are again above the white field, the robot continues its forward movement.
In all figures of robots, the L293D motor driver chip is shown conditionally (only control inputs and outputs).
Is it possible to assemble a robot yourself?
Now it’s hard to surprise someone with a robot toy. The modern technology and computer industry has stepped far forward. But still, you may be surprised at the information on how to make a simple robot at home.
Undoubtedly, it is difficult to understand the principle of operation of various microcircuits, electronics, programs and designs. In this case, it is difficult to do without basic knowledge in the fields of physics, programming, and electronics. Even so, each person can build a robot on his own.
A robot is an automated machine that can perform various actions. In the case of a home-made robot, it is enough that the car just moves.
The means at hand will help facilitate assembly: a telephone handset, a plastic bottle or plate, a toothbrush, an old camera, or a computer mouse.
How to make a little robot? At home, you can make the simplest version of a vibrating bug. The following materials must be stocked:
- a motor from an old children's car,
- CR-2032 series lithium battery, similar to a tablet,
- holder for this very tablet,
- paper clips
- electrical tape
- with a soldering iron
First you need to wrap the LED tape with electrical tape, while leaving free ends. Using a soldering iron, solder one LED end with the back of the battery holder. The remaining tip is soldered with the motor contact from the machine. The clips will serve as paws for the vibrating bug. The wiring from the battery holder is connected to the wires of the motor. The bug will vibrate and move after the holder contacts the battery itself.
What we need
To begin with, our robot will be able to simply go around obstacles, that is, repeat the normal behavior of most animals in nature. All that we need to build such a robot can be found in radio stores. Decide how our robot will move. I consider the most successful caterpillars used in tanks to be the most convenient solution, because the caterpillars have greater cross-country ability than the wheels of the car and it is more convenient to control them (for turning it is enough to rotate the caterpillars in different directions). Therefore, you will need any toy tank in which the tracks rotate independently of each other, this can be bought at any toy store at a reasonable price. From this tank you only need a platform with tracks and motors with gears, the rest you can safely unscrew and throw. We also need a microcontroller, my choice fell on the ATmega16 - it has enough ports for connecting sensors and peripherals, and in general it is quite convenient. You also need to purchase some radio components, a soldering iron, a multimeter.
Brushbot - fun for children
So, how to make a mini-robot at home? A funny car can be assembled from improvised materials such as a toothbrush (head), double-sided tape and a vibration motor from an old mobile phone. It is enough to glue the motor to the brush head, and that's it - the robot is ready.
Power will come from a flat battery. For remote control, you have to come up with something.
We make a fee with MK
In our case, the microcontroller will perform the functions of the brain, but we will start not with it, but with the power of the robot’s brain. Proper nutrition is the key to health, so we will start with how to properly feed our robot, because novice robot builders usually make mistakes on this. And in order for our robot to work properly, you need to use a voltage stabilizer. I prefer the L7805 chip - it is designed to give a stable voltage of 5V at the output, which our microcontroller needs. But due to the fact that the voltage drop on this chip is about 2.5 V, a minimum of 7.5 V needs to be supplied to it. Along with this stabilizer, electrolytic capacitors are used to smooth out voltage ripples and the diode must be included in the circuit to protect against reverse polarity.
Now we can take care of our microcontroller. The case of MK - DIP (it is more convenient to solder) and has forty conclusions. On board there is an ADC, PWM, USART and much more, which we will not use yet. Consider several important nodes. The RESET pin (9th foot of the MK) is pulled up by the resistor R1 to the "plus" of the power supply - this must be done! Otherwise, your MK may be unintentionally reset or, more simply, glitch. It is also a desirable measure, but not required, to connect a RESET through a ceramic capacitor C1 to ground. In the diagram, you can also see an electrolyte at 1000 microfarads, it saves from voltage dips during the operation of the motors, which will also favorably affect the operation of the microcontroller. The quartz crystal X1 and capacitors C2, C3 should be located as close as possible to the terminals XTAL1 and XTAL2.
I will not talk about how to flash MK, since this can be read on the Internet. We will write the program in C, as the programming environment I chose CodeVisionAVR. This is a fairly convenient environment and is useful for beginners, because it has a built-in wizard for creating code.
How to make a robot at home if a child requires it? You can come up with an interesting toy from simple cardboard.
- two cardboard boxes
- 20 caps from plastic bottles,
- with tape.
It happens that dad wants to make a sort of curiosity for the baby, but nothing sensible comes to mind. Therefore, you might think how to make a real robot at home.
First you need to use the box as a body for the robot and cut out the bottom of it. Then you need to make 5 holes: under the head, for arms and legs. In a box designed for the head, you need to make one hole that will help connect it to the body. A wire is used to fasten parts of the robot.
After attaching the head, you need to think about how to make a robot arm at home. To do this, a wire is inserted into the side holes, on which plastic covers are put on. We get moving hands. Do the same with the legs. You can make holes in the covers with an awl.
An equally important component in our robot is the engine driver, which makes it easier for us to manage it. Never and under no circumstances should motors be connected directly to the MK! In general, powerful loads cannot be controlled directly from the microcontroller, otherwise it will burn. Use key transistors. For our case, there is a special chip - L293D. In such simple projects, always try to use this particular chip with the “D” index, as it has built-in diodes to protect against overloads. Этой микросхемой очень легко управлять и её просто достать в радиотехнических магазинах. Она выпускается в двух корпусах DIP и SOIC. Мы будем использовать в корпусе DIP из-за удобства монтажа на плате. L293D имеет раздельное питание двигателей и логики. Поэтому саму микросхему мы будем питать от стабилизатора (вход VSS), а двигатели напрямую от аккумуляторов (вход VS).L293D can withstand a load of 600 mA per channel, and it has two of these channels, that is, two motors can be connected to the same chip. But in order to be safe, we will combine the channels, and then one micra for each engine will be required. It follows that the L293D can withstand 1.2 A. To achieve this, you need to combine the legs of the micra, as shown in the diagram. The microcircuit works as follows: when a logical “0” is supplied to IN1 and IN2, and a logical unit to IN3 and IN4, the motor rotates in one direction, and if the signals are inverted, a logical zero is applied, then the motor will begin to rotate in the other direction. Conclusions EN1 and EN2 are responsible for switching on each channel. We connect them and connect to the "plus" power from the stabilizer. Since the microcircuit heats up during operation, and the installation of radiators is problematic for this type of case, heat is provided by the GND legs - it is better to solder them over a wide contact area. That's all you need to know about engine drivers for the first time.
Cardboard Robot Assembly Recommendations
For the stability of the cardboard robot, you need to pay close attention to slices. They give the toy a good appearance. It is difficult to connect all parts with an incorrect cut line.
If you decide to glue the boxes together, then do not overdo the amount of glue. Better use sturdy cardboard or paper.
So that our robot can navigate and not crash into everything, we will install two infrared sensors on it. The simplest sensor consists of an IR diode, which emits in the infrared spectrum and a phototransistor, which will receive a signal from the IR diode. The principle is this: when there is no obstacle in front of the sensor, then the infrared rays do not fall on the phototransistor and it does not open. If there is an obstacle in front of the sensor, then the rays from it are reflected and fall on the transistor - it opens and current begins to flow. The disadvantage of such sensors is that they can respond differently to different surfaces and are not protected from interference - the sensor can accidentally work from extraneous signals from other devices. Modulation of the signal can protect against interference, but for now we will not bother with this. To start, and that's enough.
To revive the robot, you need to write firmware for it, that is, a program that would take readings from the sensors and control the engines. My program is the simplest, it does not contain complex structures and everyone will understand. The following two lines include header files for our microcontroller and commands for generating delays:
The following lines are conditional, because the PORTC values depend on how you connected the engine driver to your microcontroller:
If light from the IR diode gets on the phototransistor, then a log is set on the foot of the microcontroller. "0" and the robot begins to move backward to move away from the obstacle, then turns around so that it does not collide with the obstacle again and then goes forward again. Since we have two sensors, we check for the presence of an obstacle twice - on the right and on the left, and therefore we can find out which side the obstacle is from. The delay_ms (1000) command indicates that one second will elapse before the next command starts to execute.
I looked at most aspects that will help you assemble your first robot. But this is not the end of robotics. If you collect this robot, then you will have a lot of opportunities for its expansion. You can improve the robot algorithm, such as what to do if the obstacle is not from some side, but right in front of the robot. It also does not hurt to install the encoder - a simple device that will help you accurately position and know the location of your robot in space. For clarity, you can install a color or monochrome display, which can show useful information - battery level, distance to obstacles, various debugging information. Improvement of sensors is not a hindrance - the installation of TSOP (these are IR receivers that receive a signal of only a certain frequency) instead of conventional phototransistors. In addition to infrared sensors, there are ultrasonic ones, they are more expensive, and they are also not without drawbacks, but recently they are gaining popularity among robot engineers. In order for the robot to respond to sound, it would be nice to install microphones with an amplifier. But really interesting, I think, is installing a camera and programming based on it machine vision. There is a set of special OpenCV libraries with which you can program face recognition, movement along colored beacons and a lot of interesting things. It all depends on your imagination and skills.
ATmega16 in DIP-40 package>
L7805 in TO-220
L293D in DIP-16 х2 pcs.
0.25 W resistors with ratings: 10 kΩ x1 pcs., 220 Ohm x4 pcs.
ceramic capacitors: 0.1 μF, 1 μF, 22 pF
electrolytic capacitors: 1000 microfarads x 16 V, 220 microfarads x 16V x2 pcs.
diode 1N4001 or 1N4004
16 MHz quartz crystal
IR diodes: any two are suitable.
phototransistors, also any, but reacting only to the wavelength of infrared rays
About my robot
At the moment, my robot is almost complete.
It has a wireless camera, a distance sensor (both the camera and this sensor are mounted on a turret), an obstacle sensor, an encoder, a remote control signal receiver and an RS-232 interface for connecting to a computer. It works in two modes: stand-alone and manual (receives control signals from the remote control), the camera can also be turned on / off remotely or by the robot itself to save battery power. I am writing firmware to protect the apartment (transferring an image to a computer, detecting movements, detouring a room).
How to make a light robot at home? It is difficult to create a full-fledged automated machine, but it is still possible to assemble a minimal design. Consider the simplest mechanism, which, for example, will be able to perform certain actions in one zone. The following materials will be required:
A pair of medium sized brushes for shoeshine.
Computer fans in the amount of two pieces.
9-volt battery connector and battery itself.
Clamp and screed with snap function.
We drill two holes with the same distance in the plate for brushes. We fasten them. Brushes should be located at the same distance from each other and the middle of the plate. With the help of nuts we attach the adjusting fastening to the brushes. In the middle location, we set the sliders from the mounts. For robot movements, computer fans must be used. They are connected to the battery and placed in parallel to ensure the rotation of the machine. It will be a kind of vibrating motor. Finally, you need to throw the terminals.
In this case, it does not require large financial costs or any technical or computer experience, because here it is described in detail how to make a robot at home. It is not difficult to get the necessary details. To improve the motor functions of the structure, microcontrollers or additional motors can be used.
The robot, as in advertising
Probably, the browser’s commercial in which the main character is a small robot spinning and drawing figures on paper with markers is a lot familiar. How to make a robot at home from this ad? Yes, very simple. To create such an automated cute toy you need to stock up:
- three markers
- thick cardboard or plastic,
- a motor
- round battery
- foil or electrical tape,
So, we create a mold for the robot from plastic or cardboard (more precisely, we cut it out). It is necessary to make a triangular shape with rounded corners. In each corner we make a small hole in which a felt-tip pen can climb. We make one hole near the center of the triangle for the motor. We get 4 holes around the perimeter of a triangular shape.
Then we insert in turn felt-tip pens into the holes made. A battery must be attached to the motor. This can be done with glue and foil or electrical tape. In order to keep the motor firmly on the robot, it is necessary to fix it with a small amount of glue.
The robot will only move after attaching a second wiring to a fixed battery.
"Lego" - a series of toys for children, which consists mainly of parts of the designer, connected in one element. Details can be combined, while creating more and more new items for games.
Almost all children from 3 to 10 years old love to collect such a designer. In particular, children's interest increases if a robot can be assembled from parts. So, to assemble a moving robot from Lego, you need to prepare the parts, as well as a miniature motor and control unit.
In addition, ready-made kits with parts are now sold, allowing you to assemble any robot yourself. The main thing is to master the attached instructions. For instance:
- we prepare the parts as indicated in the instructions,
- fasten the wheels, if any,
- we collect fastenings that will serve as support for the motor,
- insert a battery or even a few into a special unit,
- install the engine
- connect it to the motor,
- load a special program into the design memory that allows you to control the toy.
It would seem that it is rather difficult to assemble a robot, and a person without certain knowledge will not succeed at all. But this is not so. Of course, it is difficult to build a full-fledged automated machine, but everyone can do the simplest option. Just read our article on how to make a robot at home.