IAN LANG ELECTRONICS

A Braitenberg Vehicle, for those who don't know, is a concept developed from a thought experiment proposed by Valentino Braitenberg in which a simple vehicle consisting of a light sensor and a couple of transistors (and of course a pair of motors) can be made to react to its environment in a very simple way - but in doing so it displays a basic form of artificial intelligence. The main thing is that you can't have any internal memory or processing going on; the behaviour of the vehicle is dependent on the light hitting the sensors. There's more than one kind of vehicle and here's the idea in a drawing. I've no idea where this drawing comes from other than it's probably German in origin, so if it's yours sorry for nicking it so brazenly.

 

Robots-The Braitenberg Vehicle

Go Back

In there you can see the two basic vehicles (there's a plethora of variations on the theme).

 

Providing you have two light sensors the same, and you have a means of controlling the current through the light sensors, the behaviour of the vehicle will alter according to how much light is present at the sensor. If you make one motor spin faster than the other,  the vehicle will turn the opposite way to the side with the fastest spinning motor.

 

In the drawing on the left, more light will hit the right sensor and thus motor B will spin more quickly.

brait

A      B                                                A      B

In consequence the vehicle will turn away from the light source. On the right, the opposite happens because the connections are crossed. In both cases if both sensors get the same light then the vehicle moves forward and if the light increases the vehicle speeds up; less light and the vehicle slows down and eventually stops. You can see the drawback- there's no reverse and so often the vehicles get stuck in a corner.

 

Braitenberg vehicles have no practical use per se but they are an interesting foray into the shallow end of AI and that's good enough reason to make one. So let's do the first of the examples up there. Braitenberg called it "der Feigling" which translates as "the coward" but that's a bit harsh on the poor thing and a better term is the "evader".  The challenge here is to use as few bits as possible in the electronic circuitry and so it doesn't get any fewer than the following schematic:

braitdrive

What we have up there is two LDRs (light dependent resistors) and two transistors, BJT, of NPN type.

Here at Lang Towers we are well aware that some readers might not have the grounding in electronic theory that others might and yep, you've guessed it, this is the point where I bang on at length about transistors and LDRs. Here comes a cup of tea and some ciggies, dig in:

breaktime

Let's get on to the subject of transistors first. What we have above is the original BJT type, BJT standing for bipolar junction transistor. They come in two kinds, NPN and PNP, and the difference will become clear in a minute. The term transistor is a shortening of the phrase TRANSfer resISTOR and that's exactly what it is, a device that alters it's resistance at the output according to the current it gets at the input.

 

For an NPN, the more current it gets at the input, the harder it conducts until it reaches its maximum and for a PNP the obverse is true.

transynmbol

On the left there you see the symbols for a BJT. On top are the European symbols, lower down the American and now increasingly international ones since the Chinese started using them. They are the same thing and it doesn't really matter which you use since everybody recognises them both. What does matter is that you get the type right - don't confuse NPN and PNP or whatever you're making will not work and may have unintended weapons potential if you get it really wrong. (BOOOM!)

 

A quick peep at the symbols left shows the schematic above uses an

NPN type,  because the arrow is Not Pointing iN  and were it a PNP type the arrow would Point iN Proudly.

That's a mnemonic worth knowing. And mnemonic is a word worth knowing if you are at school as if you throw it at the English teacher in an essay you'll get a bucketful of brownie points. It's pronounced ni mon ick and means a device to aid the memory. It's the same as the colours of the rainbow ROY  G  BIV  

Yep, we'll get you through your GCSE studies. Even in the bits we're not supposed to.

 

I digress. an NPN is more widely used in electronics simply because it's easier to work. Consequently manufacturers make more NPNs than PNPs and they are easier to get hold of in a hurry. Sometimes you haven't got a choice but if you have an NPN is usually the better option; it's certainly more efficient in keeping the batteries going in this game.

braitdrive

A normal BJT has three pin-outs (some, used in TTL logic circuits, have four) and they are collector, base, and emitter. The more current you put in to the base, the more current flows between collector and emitter. BUT - there's an amplification factor. In small transistors like the 2N3904 I used to make the prototype board for this, it's about 100. This amplification factor is known as hFE or sometimes Beta. The practical upshot is that if I feed the base 0.001 A  the current between collector and emitter will be 100 times that which is 0.1 A

 

222A

On the schematic above you can see the emitter, collector and base and it's the same on any schematic so if you learn the following you'll be able to read any transistor circuit. The base is always the one in the middle, pointing straight out of the circle and at a right angle to the big thick line inside. The emitter is always the one with the arrow regardless of which way the arrow is pointing. That's two, and so by a process of elimination the last one must be the collector. Sure enough, there it is at the top, the one sticking out at angle with no arrow on it. On a physical transistor such as a 2222 or a 2N3904 the pins are arranged as according to the diagram on the left which is pretty much the standard for a TO 92 packaging  in which most small transistors come.  Other packagings have other arrangements and so check a datasheet first even if you think you are sure you know what's what because it may well not be; and that sentence could have been better gramatically but you know what I mean I'm sure.

 

 

 

This schematic is SIMPLIFIED

Don't use it like this. The actual

circuit is at the bottom of the page, the last one.

braitdrive

The simplified diagram on the left shows the motor attached to the collector of the transistor and when you do this it's known as a collector load. That's the normal way to use a transistor but there are others. I said this diagram is simplified and there are two points in here that need to be shown up about why you should not use the circuit like this. Point one is that passing the 6V supply through the motor to the LDR shows the path but in real life will not work. Point two is that those motors need a snubber diode

otherwise the back EMF will blow up the transistor. Here comes the real motor circuit:

braitproper

So this circuit is very efficient in component count but it is not a commercially viable one because you will get a disparity in the transistors and the LDRs. You need two motors that are the same too.

 

The diode on the motors is a flyback (aka snubber,catcher,stopper,snuffer etc) and it's there to cart away back emf from the motors so that it doesn't destroy the transistors. Those transistors are BJT type, because what we want to do here is control the speed of the motor and to do that we vary the current. The more light that drops on an LDR the less resistance it puts up, and the less resistance the more current reaches the base. The more current, the harder it conducts, the harder it conducts the better the ground path for the motors. The better the ground path, the more current the motors get and the faster they spin. That's the theory anyway.

 

So let's set to and make a luxovore, which is a ridiculous word I've just made up to mean a light following robot. As the first experimental platform I'm going to use my Rover 5, who is called Goliath because he looks vaguely like one of those scary mobile bombs the Germans used to use during the Second World War. Here's a pic:

DSC_0016

Dangling out of Goliath in an untidy fashion there is the circuit built on a bit of tripad board. You can clearly see the transistors at the top and the LDRs at the bottom.

The trouble with Goliath is that he is not friendly towards batteries. In fact he demands that electrons be severely inconvenienced to satisfy his appetite. This is not good because when current goes high voltage goes low and so the total power is a bit low for him at startup. Although he does work on six volts, it's not very satisfactory and on nine it's hopeless. Better find another platform then.

 

Enter, stage right, BOB.  

More>