The document summarizes the key components and functioning of the Mr. General robot kit. It discusses the infrared sensors that take two readings, one with the IR LEDs on and another with them off, to determine the reflected IR from objects. It describes how the servos work using control pulses to position the output shaft. The different types of servos are explained, along with how to connect them. It provides an overview of how the code functions by updating sensors and servos in the main loop to enable object tracking.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
146 views8 pages
Understanding MR General
The document summarizes the key components and functioning of the Mr. General robot kit. It discusses the infrared sensors that take two readings, one with the IR LEDs on and another with them off, to determine the reflected IR from objects. It describes how the servos work using control pulses to position the output shaft. The different types of servos are explained, along with how to connect them. It provides an overview of how the code functions by updating sensors and servos in the main loop to enable object tracking.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8
Understanding the Mr.
General robot kit
The sensors: The sensors are all IR (infrared) sensors. IR sensors can receive interference from sunlight and indoor lighting. The Mr. General robot overcomes this problem by taking two readings !ne with the IR "#$s on and another with the IR "#$s off. The difference is measured to determine IR reflected by an ob%ect. This will be e&plored later when we look at the code. 'hen you look at the corner sensors on Mr. General they are %ust a simple voltage divider. The principle is that the phototransistor works much like a "$R (light dependand resistor). (s more light shines on the transistor it allows more current to flow. The voltage across the fi&ed resistor changes with the current flowing. 'hen the sensor is connected to a digital input then it will read as a ) when the voltage goes above *+, of the -./ voltage and will read as a + when it falls below 0+,. The actual voltage levels may vary slightly depending on the processor used. 'hen connected to an analog input then the voltage will get higher as the ob%ect gets closer. The advantage of using the sensor on an analog input is that your code can then have more than one level. 1ou might have2 + 3 4++ nothing there 4+) 3 5++ something there but no chance of collision. -urious6 have a look. 5+) 3 7++ try to avoid this 7+) 3 )+48 better back up or something 9uick: The Eye: consist of 0 sensors almost the same as those on the corners of the main .-;. The main difference being that there are two phototransistors in parallel. This doubles the sensitivity. Increasing the brightness of the IR "#$ could also increase the sensitivity but uses more power and flattens the batteries 9uicker. Servos - how they work: Mr. General uses two standard micro servos for the pan<tilt assembly that makes his head<neck. This pan<tilt kit was designed on "MR (letsmakerobots.com) These servos consist of a small motor a gearbo& and a variable resistor connected to the output shaft. ( small built in control circuit uses the variable resistor to determine what position the output shaft is in. ( control pulse tells the circuit where the shaft should be. The control circuit uses this information to ad%ust the speed and direction of the servo motor until the position of the output shaft matches the position given by the control pulse. This pulse is between )m= and 4m= in width with ).5m= being the center position of the servo. The pulse repeats every 4+m=. $ifferent servo manufacturers have slightly different standards and as such some servos will work with pulse widths outside of the )34m= range. .ulses that e&ceed these limits may force your servo to try and move beyond it>s range of travel and possibly damage the servo. Continuous rotation servos: Mr. General uses two continuous rotation servos for movement. ( continuous rotation servo is similar to a standard servo e&cept that the output shaft can rotate continuously. ?or this reason there is no variable resistor that monitors the position of the output shaft like there is in a standard servo. The variable resistor is replaced with two fi&ed resistors that simulate the variable resistor set to the center position. @ow a pulse of ).5m= will make the motor stop. ( pulse greater than ).5m= will make the output shaft turn clockwise and a pulse less than ).5m= will rotate the shaft counter clockwise. The closer the pulse width is to ).5m= the slower the motor will turn. In reality no two servos are the same and as such ).5m= is only the theoretical center position. Temperature can also affect this center position causing the motors to drift slightly in one direction on a cold morning and the other direction on a hot day. To connect either type of servo to Mr. General simply plug it into the 8 pin male headers provided with the ground wire (usually black or brown) to the outer edge of the .-;. The 8 pin male headers already have power supplied (0.7A) so only a single wire is needed to connect the signal wire to the processor. (ll 8 pin male headers have a 8 pin female header connected in parallel so that a %umper wire can be used to connect the servo to the breadboard. Processor: The Mr. General robot was designed to work with any processor that can plug into itBs breadboard. ?or this document we will look at the (tmega7( using the (rduino bootloader and I$# as well as the .ica&e 47C). Making a programming cable for the ATmegaA: To program the (Tmega7( while it is in the breadboard will re9uire a homemade programming cable. There are many /=; to serial interfaces available. The photo below shows a typical e&le of what you might find in an office supply store. (lternatively you could buy a /=;<serial breakout board such as the ?T$I basic from =parkfun. @o matter which interface you use your cable will need 0 wires. Gnd TC RC and $TR or RT=. @ormally I use $TR but if that doesn>t work then try RT=. ( full list of pinouts for the $D serial socket can be found here2 http2<<en.wikipedia.org<wiki<=erialEport In order for the (rduino I$# to reset the (Tmega7( prior to programming a )++n? capacitor needs to be in series with the $TR and reset pins. This capacitor allows the $TR pin to briefly trigger a reset allowing the bootloader to accept a new program. I have shown )F4 resistors in series with TC and RC. This is a simple precaution as $+ and $) can be input or output depending on your program. $+ should be disconnected from the eye and $) disconnected from the servo prior to program upload to ensure a reliable data transfer. .ica&e offer ready made programming cables that terminate in a 8.5mm stereo plug. ( 8.5mm stereo socket can easily be adapted to interface with a breadboard. !esonators an" Crystals: !riginally Mr. General (both .ica&e and (rduino) used a 8 pin )*MGH ceramic resonator. This is the cheapest and easiest to use. There are 4 ways this can be installed on the breadboard. The first way is to plug it in near the chip and use 8 %umper wires to connect it to the processor. This usually works ok as long as the %umper wires are not too long.The tracks of the breadboard and the wires act like small capacitors and inductors. These can affect the fre9uency of the clock or prevent it functioning all together if there is too much. I prefer to bend the legs of the resonator so that it connects directly to the pins of the processor. This is more reliable. (s the resonator pins are a bit short it is even better if you solder some e&tensions onto the pins. .ica&e 47C) (Tmega7 (Tmega)*7 and (Tmega847 all have the G@$ pin (7) and CT(" pins (D )+) in the same configuration making this easy. If you are using (rduino then a )*MGH crystal and two )7p? or 44p? capacitors can be used for better timing accuracy. This might work with pica&e although I have never tried it. The Co"e: The original IMr. GeneralI kit was designed around the .ica&e 47C) although many different processors can be used. The program has since been re3written for (rduino and the kit is now normally supplied with the (Tmega7( which is e9uivalent to the old (rduino @G with (Tmega7. If you have an (rduino @ano then this will also plug directly into the breadboard. The (rduino @ano has two e&tra analog input. This allows the 0 corner sensors to be used as analog sensors. I have included sample code for (Tmega7( (rduino @ano and .ica&e47C). If you are using a .ica&e 47C4 or 0+C4 then you might be able to use the C4 conversion wiHHard to convert the program. (rduino users should note that there is a seperate tab called II!Epins.hI where all the I! pins are defined. This tab is effectively your wiring diagram as it tells you which pin of the processor connects to what piece of hardware on the .-;. Regardless of which processor you use the structure of the sample code is very simple. The Main loop "oes these things: ). /pdates the "#$ pattern apro&imately 5 times a second. This causes the corner "#$s to chase around the .-;. 4. /pdates the position of the neck servos and the speed < direction of the continuous rotation servos. 8. Reads the compound eye. 0. -alculate new pan < tilt servo positions and continuous rotation servo speeds to maintain ob%ect tracking. 5. Read the corner sensors and ad%ust continuous rotation servo speeds to prevent a collision. *. !ptional behaviour routines such as boredom counters can be added here. !ea"ing the #! sensors: =imple IR sensors such as those used on Mr. General cannot measure distance accurately and can be tricked by ob%ects of different colours. ?or e&le a small bright white ob%ect in the distance and a large dark ob%ect nearby can give the same readings depending on how well they reflect IR. =unlight has a lot of infrared light an can easily trick or blind these sensors. ;ackground light such as this is called ambient light. To help overcome some of these limitations we use the method proposed by ?rits of reading the sensors twice. The first time we read the sensor with the IR "#$s on. This gives us a reading that is e9ual to the ambient light plus IR "#$ light that has reflected from a nearby ob%ect. The second reading is with the "#$s off so that we read only the ambient light. 'hen we subtract the second reading (ambient IR) from the first (ambient IR J reflected IR) we are left with a value that represents only the IR light that was reflected from a nearby ob%ect. This techni9ue allows the robot to track your hand movements while ignoring the IR light coming in from a nearby window. Tracking Motion2 /sing the pan servo as an e&le the robot must first read the left and right compound eye sensors and subtract the ambient light as previously mentioned. The distance<reflectivity of the ob%ect must be taken into account to prevent servo overcorrection. This is done by using a variable called panscale wich is the average of the left and right readings divided by "Rscalefactor which is ad%usted to allow for servo speed and tracking sensitivity. Too sensitive and the servos will overshoot causing them to %itter. ( value called IleftrightI is the absolute difference between the left sensor and the right sensor divided by the panscale to allow for distance and servo speed. This value is then added or subtracted from the old servo position to provide a new servo position. Tilting of the head works the same way as the panning of the neck. (rduino users must forgive the clumbsy code as it has been translated from .ica&e basic which has limited math functions and no negative numbers. $ollowing an ob%ect: In order to track an ob%ect properly the robot needs to do more than turn it>s head. It must follow with the body. If the neck pans too far left or right then the wheels are driven causing the robot to turn towards the ob%ect. $istance is calculated by averaging the readings of all 0 sensors (up down left and right). This is not an accurate measurement of distance but is good enough for the robot to %udge things such as which direction is blocked and which direction has room to move. The robot tries to maintain a set distance from the ob%ect it>s tracking so as not to loose it>s lock on the ob%ect while avoiding a collision. The wheels are driven forward or backward as re9uired. Collision avoi"ance: ?inally the .-; corner sensors are read in the same fasion as the eye sensors. !ne reading with the "#$s on and one with the "#$s off. This causes all the corner "#$s to pulse briefly. ;ecause of the speed this is happening at the green corner "#$s appear to be dimmly lit. (fter the readings have been taken any ob%ects detected are compared with the direction of the motors. If necessary a motor will be stopped to avoid a collision. &ight pattern an" sensor in"ication: If a corner sensor detects an ob%ect or the light pattern determines that that corner "#$ should be on then that "#$ will be re3lit causing that corner "#$ to appear bright rather than dim. A""itional behaviour: In the original pica&e code I also e&perimented with a boredom counter which monitored how much time had passed without tracking a moving ob%ect. If too much time passed then the robot would wander off in a random direction until it found a new ob%ect. If that ob%ect failed to move in a given time the robot would wander off again. (dd other counters to monitor things such as frustration if the robot gets stuck in a corner. #&citement if the the robot finds a fast moving ob%ect or multiple moving ob%ects. ;y adding several counters and behaviour routines your robot can appear 9uite life like. #! Communications: If a suitable communications protocol was written then it should be possible for more than one robot to communicate with each other using the IR sensors as IR transcievers. A""itional har"ware: The main .-; of Mr. General has all the spare space converted to prototype board. This area is ideal for adding additional circuitry such as line following sensors speak%et chipset amplifiers etc. There are 4 great IGow to>sI for the speak%et here2 http2<<letsmakerobots.com<node<08+5 this is (nt>s post using the pica&e. http2<<letsmakerobots.com<node<)84)+ this is $roidbuilder post using the (rduino and TT=45* companion processor. (n ideal amplifier is the T$(4744M. This is a small 7 pin stereo power amplifier that will work with supply voltages from ).7A to )5A. The two amplifiers in the chip can be connected in Ibridge modeI to make a single amplifier with a greater power output. (s the continuous rotation servos stop position is sensitive to temperature a temperature sensor such as an "M85 could be added between the servos. 1our processor could use this to ad%ust the stop position of the servos. A""itional voltages: 1ou may choose to use 8.8A devices. The area under the breadboard is an ideal location for a 8.8A regulator. (s the power rail on each side of the robot can be isolated and changed you could connect the rail on one side of the robot to 8.8A and switch all the servos to the other rail which might remain connected to battery JA. I hope this guide will help owners of the IMr. GeneralI robot kit to get more en%oyment from it through a better understanding of it>s functions.