Line Follower Robot Racing Build Program Race! The COLMAC Line Follower Robot has been developed as a low cost introductory model for students and educators interested in Robotics. Line follower robots are used extensively in industry in areas where parts or materials need to be constantly delivered from one location to another. Generally known as AGVs (Automated Guided Vehicles) they are found mainly in the car manufacturing industry and anywhere that employs large warehousing where the robot follows tracks to and from the shelves they stock and retrieve from. The COLMAC line follower robot kit has the following features: Simple chassis made from acrylic sheet. Two wheeled easily controlled differential drive and steering. Significant distance between line sensors and wheels allowing the robot time to react and reduce the instances of over-shooting. Line illumination LED. The following should be noted when using this robot: All the settings for the LDR sensors indicated in the notes are examples only. Each robot will require its own settings for the sensors to be found through calibration. They will depend on the surface it is operating on, the colour of the line being followed, the charge in the batteries etc. and indeed similar LDRs will differ slightly from each other. This robot is also suitable for entering the annual Robotics Ireland ©Robot Games Ireland Tournament in the Line Follower Racing category. See www.colmac.ie for further details. www.colmac.ie 1 Table of Contents 1. Assembling the Line Follower Robot Kit……………………………………………………….................. 3 2.Downloading/Installing GENIE Programming Editor Software ....................................... 21 3. GENIE Programming Editor Interface ........................................................................... 22 4. Connecting the E18 Motor Control Board to your computer ......................................... 23 5. Testing the E18 Motor Control Board ........................................................................... 24 6. Driving the robot forward/reverse............................................................................... 29 7. Turning the robot ........................................................................................................ 32 8. Using the LDRs to detect a line .................................................................................... 35 9. Using the LDRs to follow a line .................................................................................... 43 10. Using a defined loop during a program ...................................................................... 45 11. GENIE Programming Editor Help ................................................................................ 48 12. Troubleshooting Tips ................................................................................................. 49 13. Improving your Line Follower racing……………………………………………………………………………53 www.colmac.ie 2 1. Assembling the Line Follower Robot Kit The following tools which are not supplied are the minimum necessary in order to build the robot: Minimum 25Watt soldering iron and stand – solder is supplied in the kit. SAFETY NOTICE Never touch tip of soldering iron – it will burn you! Always return iron to its stand when not in use. Wear eye protection – solder can ‘spit’ Avoid inhaling fumes – work in a ventilated area Ensure all parts of the equipment are damage free See www.colmac.ie for soldering technique video and other related videos e.g. cable stripping etc. Small long nosed pliers suitable for electronics. These can be used for manipulating small components and stripping cable insulation. They can also be used for trimming the legs of components once they have been soldered into the printed circuit board (PCB). Some method of holding the GENIE E18 printed circuit board (PCB) while components are being soldered is very useful. Some examples are shown below: Assembly aids and small vices are ideal but any method that holds the PCB while the component is being soldered is ideal – pieces of Blu-Tack can even be used! www.colmac.ie 3 The first step is to populate and solder all the components on to the GENIE E18 Motor Control Board. When completed, this board is a PIC micro controller. Peripheral Interface Controllers (PIC) are small computers that can be programmed and reprogrammed using the GENIE Programming Editor programming language to turn on/off various outputs depending on the state of various inputs. The outputs being controlled in this case are: 2 x DC motors used to drive and steer the robot 1 x LED used to illuminate the line being followed The inputs used to control these outputs are: 2 x LDR (Light Dependent Resistors) that act as line following sensors The processing of all the information from the inputs and the control of the outputs is done by: 1 x GENIE E18 PIC Microcontroller Chip (18 pin shown in red above) The motors are driven forward/reverse or clockwise/anti using a motor driver chip: 1 x L293D Motor Driver Chip (16 pin shown in yellow above) www.colmac.ie 4 Step 1: Solder in the fixed resistors. Resistors reduce the flow of electric current and also change the voltage level at different parts of the circuit. Their size is measured in Ohms (Ω) and usually in thousands of Ohms or Kilo Ohms – this is usually just written as K e.g. 22K = 22 Kilo Ohms Fixed resistor size is shown using colour code: http://en.wikipedia.org/wiki/Electronic_color_code The colour coding of all resistors used in the E18 board is shown below. Fixed resistors have no polarity i.e. no positive or negative (+ or –) and so can be inserted either way around. Insert the resistors in their correct places either way around as they don’t have a positive or negative (+ or -). The size of each resistor is marked on the board and their colour coding is as follows: 0 Ohm – Black – Marked ‘LK’ on PCB 330 Ohm – Orange, Orange, Brown, Gold 4.7K – Yellow, Violet, Red, Gold 10K – Brown, Black, Orange, Gold 22K – Red, Red, Orange, Gold 100K – Brown, Black, Yellow, Gold NOTE: Many instructional videos including how to solder the printed circuit board (PCB) and the associated components properly can be found at www.colmac.ie www.colmac.ie 5 Step 2: Solder in the capacitors Capacitors are devices that store electricity. Their size is measured in Farads, usually a small fraction of a Farad such as a micro Farad (µF) or nano Farad (nF). Solder the ceramic capacitors in their correct places either way around as they don’t have a + or -. These capacitors are used primarily to reduce electrical noise generated by the motors when they are running. This electrical noise can interfere with the operation of the E18 microcontroller. As such, C3 and C4 are connected directly across the motor output connections Q6/7 and Q4/5. Note that C5 shown in red is not required for this project. Solder the electrolytic capacitor in its correct place. It has polarity i.e. a positive and negative. The negative (-) leg is beside the grey stripe (marked with a minus sign) as shown below. www.colmac.ie 6 Step 3: Solder in the diode Diodes allow electricity to travel in one direction only. Solder the diode in its correct place - it has polarity i.e. a positive and negative. The negative (-) leg is beside the grey band as shown below. Grey band on negative side Step 4: Solder the transistor, the reset switch and the USB jack The transistor operates as an automatic switch. The USB jack allows the microcontroller to connect to your computer. The reset switch restarts the program from the beginning. Flat side USB www.colmac.ie 7 Step 5: Solder the status LED and chip sockets Insert the green status LED as shown below – flat side is negative. The chip sockets to hold the GENIE E18 microcontroller and L293D motor driver microchips should be inserted as shown. The L293D chip allows the motor turn both clockwise and anti-clockwise which gives forward/reverse and turning motion in the line follower robot. Flat side - Notch Step 6: Solder the cable terminal blocks. Insert the terminal blocks as shown – arrows indicate where flying lead cables will be inserted. www.colmac.ie 8 NOTE: Soldering should be neat and uniform. Connections should not touch each other unless they are supposed to as circled below. Step 7: Insert E18 and L293D microchips Try to handle the chip legs as little as possible but ensure that all legs are properly inserted into their socket. L293D E18 www.colmac.ie 9 Step 8: Make flying lead connectors for LED, LDRs and motors Use the coloured cable to make flying lead connectors as shown in the following pictures. For the LED, cut approx. 170mm of each cable, braid together as shown and remove approx. 5mm 5mm of insulation from the ends. Shorten the legs of the LED as shown using snips/pliers etc. in order to minimise the chance of them touching each other and creating a short circuit. Braid the individual strands of the exposed cable in order to minimise stray cable strands touching each other and solder the LED as shown. Take note of which cable is connected to the flat side of the LED. Black connected to flat side of LED Twist/braid strands together www.colmac.ie 10 For the LDRs, cut approx. 250mm of each cable, braid together as shown and remove approx. 5mm of insulation from the ends as before. As before, shorten the legs of both LDRs as shown to approx. 10mm using snips/pliers etc. in order to minimise the chance of them touching each other and creating a short circuit. Braid the individual strands of the exposed cable in order to minimise stray cable strands touching each other and solder the LED as shown. Take note of which cable is connected to the flat side of the LED. www.colmac.ie 11 For the motors, cut approx. 150mm of each cable, braid together as shown and remove approx. 5mm of insulation from the ends. Solder the flying leads to the motors as shown. Be careful with the motor connections as they are quite delicate. If possible use similar colour cables in the positions as shown in order to program in accordance with the notes later. www.colmac.ie 12 Step 9: Attach motors to chassis using sticky pads The motors should be attached to the plastic chassis using two sticky pads on each as shown below. The motor cables are then fed through the holes as shown. The edge of the motors should be positioned on the chassis as seen here. Line up the edge of the motor with the edge of the chassis marked in red. www.colmac.ie 13 Step 10: Attach battery pack/switch to chassis. Attach 2 sticky pads to the battery pack on the switch side as shown. Stick down the battery pack as seen below – try to centre on the chassis in order to keep it balanced. Battery pack cable Feed the red (+V) and black (0V) cables through the holes as shown. www.colmac.ie 14 Step 11: Connect motor flying leads to the E18 PCB Firstly attach two sticky pads to the bottom of the PCB in each of the approximate positions shown. 2 x sticky pads are used in each case in order to accommodate the raised soldered joints and ensure secure fit to the chassis. Then insert the cable from each motor into the M3 and M4 connectors preferably in the same manner as shown below in order to correspond with the programming later on. Do not worry however if they are inserted differently as changes can easily be made to the programming. Q4=Black Q5=Yellow Q6=Black Q7=Yellow www.colmac.ie 15 Step 12: Insert LED in chassis and connect to E18 PCB Insert the line illumination LED into the front of the chassis as shown and feed the flying lead through the centre cable hole. Flat side = Negative (-) Route the LED flying lead through the hole beside the PCB as shown. Connect negative (-) cable (black in this case) to the right side connection of output Q3 and the other cable + __ to the left side positive (+) connection. NOTE: If the LED is connected the wrong way around it will not be damaged but will simply not work. www.colmac.ie 16 Step 13: Connect battery power leads to the E18 PCB Connect the red (+V) and black (0V) cables to the relevant connectors as shown below. If the cables are connected the wrong way around the E18 chip will heat up and may be damaged. 0V +V Step 14: Insert LDRs in chassis and connect to E18 PCB Insert the two LDRs into the front of the chassis as shown and feed the flying lead through the A0 A2 cable holes. NOTE: Ensure that the LDR legs do not touch each other or the legs of the LED which would result in a short circuit. www.colmac.ie 17 Route the cables through the remaining holes as shown and connect into the input terminals A0 and A2 as shown on page 8. NOTE: Light Dependent Resistors (LDRs) do not have polarity (positive/negative) which means that it does not matter how the cables are connected into the terminal blocks. Finally, using the sticky pads, attach the E18 to the chassis in the position shown. A0 A2 www.colmac.ie 18 Step 15: Attach the rubber bands to the wheels and the wheels to the motors. The rubber bands are used to increase the grip of the wheels. When attached the wheels should push fit on to the motor drive shaft. Step 16: Assemble the rear spoiler and attach to chassis The 5mm end of the support fits into the spoiler. Spoiler The 3mm end of the support fits into the chassis. 5mm Support 3mm www.colmac.ie 19 Congratulations, you have built the COLMAC Line Follower Racing Robot! www.colmac.ie 20 2. Downloading/Installing GENIE Programming Editor Software GENIE Programming Editor software is required to program the robot and can be downloaded free of charge from its developers at their website http://www.genieonline.com/ Complete the required details in the online form accessed through the Downloads tab and a link will be emailed to you – click on the link to download and install the software. If you encounter any difficulties click on the Support tab and you will be directed to the GENIE Troubleshooting Guide and the Troubleshooting Tool. www.colmac.ie 21 3. GENIE Programming Editor To open GENIE Programming Editor click the GENIE Programming Editor icon on the desktop or use the start menu to locate the program. Menu Bar Tool Bar Programming Commands Microcontroller button Programming Area www.colmac.ie 22 4. Connecting the E18 Motor Control Board to your computer NOTE: It is necessary to use the GENIE USB Plug & Play cable in order to connect your computer to the GENIE microcontroller. The cable can be used with all GENIE microcontrollers and can be purchased from http://colmac.ie/product/download-cable/ Connect the GENIE USB Plug & Play cable and the following window should appear: Select OK If the confirmation window does not appear then click on the Help button and consult the Troubleshooting Guide. www.colmac.ie 23 5. Testing the E18 Motor Control Board Firstly you must tell the software what GENIE chip you are using. Select Microcontroller from the tool bar followed by Program Settings. Select the GENIE E18 chip. NOTE: This must be done each time a new program is written unless E18 is set as default. The Program Settings window provides information about the inputs and outputs available on the selected E18 chip: www.colmac.ie 24 The E18 chip has the following features: 8 digital outputs labelled Q0 to Q7 We are only using Q3 to Q7 incl. for this line follower robot These outputs are ‘digital’ in that they are either on (1) or off (0) 3 possible analogue inputs e.g. LDR, Thermistor etc. labelled A0, A1 and A2 5 possible digital inputs e.g. switches labelled D0, D1, D2, D6 and D7 As shown on the chip configuration: o Input A0 and D0 share Pin 17 – connected to A/D0 on PCB o Input A1 and D1 share Pin 18 – connected to A/D1 on PCB o Input A2 and D2 share Pin 1 – connected to A/D2 on PCB We are only using A/D0 and A/D2 for this line follower robot Power to the chip can be tested across Pin 5 (0v) and Pin 14 ( should be at least 3.5 to 9v) NOTE: We are only using LDR inputs in this robot but it is possible to use many other analogue inputs such as a thermistor, variable resistors etc. with the GENIE E18. Similarly it is possible to incorporate digital inputs such as micro switches with the robot for obstacle avoidance. etc. but they are not covered in this www.colmac.ie 25 Connect the GENIE USB Plug & Play cable to the line follower robot and turn on power to the robot using the on/off switch included in the battery pack. The green status LED should flash and the software should indicate that the microcontroller is now connected as shown. We can now test that both motors and the line illumination LED are working. We will use the Control Device command to test these outputs. This command can be activated from the menu shown above or by clicking the Microcontroller button on the tool bar as shown below. www.colmac.ie 26 Activating the Control Device command opens the following window in the Program menu. This indicates that the software recognises that the 2 LDR sensors are connected to A/D0 and A/D2 inputs. NOTE: If they do not show up immediately, cover the sensors with your finger or lift the nose of the robot off the ground. This indicates that all outputs are currently off (0) By clicking on output Q3 and changing it from off (0) to on (1) we should be able to activate the line illumination LED at the front of the line follower robot as shown. If the LED does not illuminate, check the following: Is the LED cable connected into the PCB with correct polarity as shown below? Is the LED cable connected to the LED with correct polarity i.e. leg on flat side of LED connected into negative black? www.colmac.ie 27 Now, by turning on (1) and off (0) outputs Q7, Q6, Q5 and Q4 in turn, we should observe the clockwise and anticlockwise rotation of each motor M4 and M3. If the motors do not operate then check the following: Are the 2 cables from M4 connected into Q6 and Q7 on the PCB? Are the 2 cables from M3 connected into Q4 and Q5 on the PCB? NOTE: Consult Section 12 Troubleshooting Tips if you still have problems connecting to the board and using Control Device. In the next section we will now look at how to write a simple program to operate both motors in order to create forward and reverse motion. www.colmac.ie 28 6. Driving the robot forward/reverse We are now ready to write our first program to move the motor forward and reverse. Construct the following flowchart by left clicking and dragging the programming commands from the Gallery. Commands will automatically link together when you drop them in place. The Motor command is located under the Input and Output section of the flowchart symbols. The Wait and Stop commands are located under the Program Control section of the flowchart symbols. Commands will automatically link together when you drop them in place. Each command must now be edited in order to complete the program. NOTE: The following conventions are used when editing outputs and inputs: 0 Make output low (off) 1 Make output high (on) T Toggle this output (where high is set to low and low is set to high) X Leave output alone www.colmac.ie 29 Double click on each of the commands except the Stop and edit as shown below. Remember to set the type of motor being used to DC: It is good practice to give every program a name to appear in the Start symbol. Push up the M3 and M4 sliders in order to set both to forward motion. NOTE: Depending how you have connected each motor polarity you may find that you need to set the sliders in the down position or one slider up and the other down in order to achieve forward motion when you download and Run Live. Set the Wait time to 3 seconds. This instructs the program to continue running the last command for 3 seconds. Click on the M3 and M4 buttons to turn both motors off as shown. NOTE: The Stop command stops running the flowchart program – it will not turn off the motor if it is already running! www.colmac.ie 30 In order to download the program to the robot, click on the Microcontroller button and select Run Live. The Program window will indicate that it is Accessing the PIC chip and then that it is Running Live. The program will start immediately once it is downloaded. The USB cable can then be removed and the program rerun by pressing the small reset switch on the PCB. The following commands and screen will be seen when using Run Live. As mentioned previously, when you run this program live you may now discover one of the following scenarios depending on how you have connected the motor polarity either at the motors or on the PCB: a) The motor is actually going in reverse. In this case you simply set both M3 and M4 sliders to the down position instead of the up in order to get forward motion. b) One motor is going forward and the other going in reverse. In this case you will have to move M3 slider up and M4 down or vice versa. EXERCISE 1 Edit the program so that your robot moves forward for 4 seconds AND then reverse for 4 seconds. Use Run Live to download and run the program. www.colmac.ie 31 7. Turning the robot The procedure for turning the robot while it is moving is based simply on turning off one motor and leaving the other running. Construct and edit the following flowchart as shown. Settings for motor control are shown. You will see these output settings appear in the Multiple Panel View when we simulate this program. www.colmac.ie 32 Select the Run command on the tool bar. You will see each flowchart command highlight as the program simulates. The Speed Dial can be rotated to adjust the speed at which the simulation runs. Now click on the View several monitor panels at once command in order to open Multiple Panel View. This allows us see what each flowchart command is doing as shown below. To turn left motor M4 is turned off by turning off both outputs Q6 and Q7 and motor M3 is left running (output Q4) in forward direction. We created this setting earlier while editing this command using Motor Properties www.colmac.ie 33 Click on the Microcontroller button and select Run Live in order to download the program to the robot. The Program window will indicate that it is Accessing the PIC chip and then that it is Running Live. The program will start immediately once it is downloaded. The USB cable can then be removed and the program re-run by pressing the small reset switch on the PCB. EXERCISE 2 Like all learner drivers you need to learn how to complete a 3 point turn. Edit the previous Turning Ex program to have your robot execute a 3 point turn. If you’re not sure what a 3-point turn is ask your teacher to explain. Points to consider: It is not possible to control the number of revolutions of a DC motor as it is with a servo or stepper motor. Controlling the amount your robot turns using the Wait command is accomplished by trial and error. It is possible to set the Wait Properties to fractions of seconds by typing the value in rather than selecting the set values from the drop down menu as shown below. The turning circle of a robot such as this depends on the diameter of the wheel and the distance between the wheel centres. This could be the basis for an Applied Math question. Having completed this exercise why not try to program your robot to drive in a square, drive in a figure 8 or even set up a parking bay that it must park in using parallel parking! www.colmac.ie 34 8. Using the LDRs to detect a line Before we can successfully use the LDR sensors to detect a line we must learn how to understand the digital reading that the LDR creates in the GENIE software. The resistance of the LDR supplied goes from approx. 1KΩ in normal light to approx. 15KΩ in normal darkness i.e. the resistance of an LDR increases as it gets darker. Theoretically it goes from 0KΩ in total brightness to 1MΩ in total darkness. The GENIE software takes whatever analogue resistance value the LDR has at any given moment and converts it into a digital reading of between 0 and 255. A digital value of 0 corresponds to an LDR resistance of 1MΩ i.e. total darkness. Similarly, a digital reading of 255 corresponds to an LDR resistance of 0KΩ i.e. total brightness. Turn on your robot, connect it to the USB and select Calibrate Sensor from the Microcontroller menu on the tool bar. You should see the screen shown below. Shows the LDRs connected to A0 and A2 and their current reading. Move the robot around and observe the reading change as LDRs pass over bright and dark surfaces. www.colmac.ie 35 The area underneath the LDRs on the robot will, by virtue of its design, be quite dark. This could create difficulties when trying to detect a white line on a dark surface. In order to solve this problem a LED has been installed between them to illuminate the line and surface. In order to calibrate the LDRs while this LED is on we will use the Debug Live command. Construct and edit the following ‘Calibrate LDR’ flowchart. The Outputs command is The Outputs used to command turn on theisLED used connected to turn on the LED Q3. to output connected to output Q3. The back loop back toStart the Start The loop to the keepskeeps the LED the tuned LED tuned on. on. To create the loop, firstly left click and hold the mouse over the right connection point on the Outputs symbol. Drag the connecting line to the right and then upwards to create the first 90˚bend. To create the second 90˚bend, release the left mouse button and then click again at a point approximately in line with the Start command. Continue dragging the line to complete loop. Release and click again here www.colmac.ie 36 Place your robot on the Calibration Sheet shown on the next page (remove/print/copy if necessary), turn on and select Debug Live from the Microcontroller menu. You will see the screen shown below. Click Start to begin Debug Live. This facility allows you watch your program animate as it runs live on the microcontroller. By clicking on View several monitor panels at once as shown below we can now observe what the LDRs are reading along with what inputs/outputs etc. are activated. You could choose to view the inputs/outputs or the analogue sensor readings etc. on their own but the View several monitor panels at once option shows nearly everything and is demonstrated on page 39. www.colmac.ie 37 www.colmac.ie 38 You should now see the screen as shown. Indicates that inputs A0 and A2 are connected. Indicates that the LED connected to output Q3 is on. Readings from LDRs connected to A0 and A1. LDRs on the white area. NOTE: Your readings may be different Move the front of the robot on to the thick black line order that the LDRs detect the new reading associated with the black line. Now, take note of both readings as shown below. Readings on white area: A0 = 224 A2 = 231 NOTE: Depending on number of batteries used and ambient lighting conditions etc. your readings may be significantly different. www.colmac.ie 39 Readings on black line: A0 = 180 A2 = 184 NOTE: Depending on number of batteries used and ambient lighting conditions your readings may be significantly different. The data gathered in this example shows: LDRs read a max of approx. 231 on the white surface LDRs read a max of approx. 184 on the black line For the purposes of this line follower we can summarise by saying that once the LDR readings go above 190 then they have definitely moved away from the black line and into the white area. This allows a little tolerance for ambient lighting, battery power etc. We can now use this information to create a simple program to stop the robot from driving over the black line. www.colmac.ie 40 Construct the following program shown below. The Compare command is found in the Flow Control section of the flowchart symbols. It is used to compare the LDR readings and decide whether to follow the Yes (Y) or No (N) route in the program. The first line connected to the Compare command will indicate the Yes (Y) route to follow and the second line connected will indicate the No (N) route to follow. These can be swapped by right clicking the Compare command and selecting Swap Yes and No if necessary. We will now edit this flowchart so that it carries out the following program: 1. Turn on the line illumination LED connected to Q3. 2. Check if the LDR readings are more than 190 (>190). 3. If so then drive the robot forward as it is still on the white surface. 4. If not, i.e. less than 190 then stop the robot as it has detected the black line. 5. The loop will ensure that the program continually checks the readings. NOTE: The settings used i.e. more than 190 may need to be adjusted to suit the surface and lighting that your own robot is operating in. Use your own reading found while calibrating using Debug Live earlier. The edited flowchart symbols are shown on the next page. www.colmac.ie 41 Tick the ‘and’ box to open the second expression. This instructs the program to compare both readings from A0 and A1 to see if they are more than 190. If they are, then the robot is still on the white surface and continues forward. If they are less than 190 the robot has encountered the black line and stops. See www.colmac.ie for a video of the program in operation. NOTE: The speed of rotation of the motor can be slowed by not pushing up the slider control fully up or down. Beware of having motors rotate at different speeds as this will cause the robot to veer off line. www.colmac.ie 42 9. Using the LDRs to follow a line Before beginning work on programming the line follower to follow a line you should firstly set up a line course/track for it to follow. The program that follows is based on the COLMAC GP course as used in competition. The GP course consists of a black line track on a white background as shown below. This track is available to purchase from www.colmac.ie and measures approx. 2400mm x 1200mm. You can create your own track with a roll of standard 20mm wide black insulating tape and using it to create a track on a lighter coloured floor. Don’t make the track too difficult initially – keep corner radius large. In Section 10 we will look at how to deal with difficult tracks. NOTE: The following program is designed to instruct the line follower follow the black line and correct itself when it moves on to the white area. It is also possible to program it to stay in the white each side of the black line and correct itself if it moves on to the black line. www.colmac.ie 43 NOTE: Remember to use your own LDR readings in the Compare commands. Visit www.colmac.ie for videos showing the program being tested using Debug Live and the robot following the GP track. In the first Compare command the LDRs are set so that if they both read less than 190 i.e. they are both detecting the black line, then both motors are on moving the robot forward. In the second Compare command if A0 reads more than 190 then the robot has moved off the line to the right and motor M3 is turned off in order to turn the robot left and back to the line. In the third Compare command if A2 reads more than 190 then the robot has moved off the line to the left and motor M4 is turned off in order to turn the robot right and back to the line. www.colmac.ie 44 10. Using a defined loop during a program In order to deal with difficult 90˚ bends similar to those highlighted on the COLMAC F1 track shown below where the robot can lose sight of the line, we need to program it to stop and look for the line if it loses it completely. This can be accomplished by instructing the robot to firstly stop, then look left and if it does not find the line there to then look right until it does. We could program this in a number of ways but we have chosen to use the defined loop commands as shown in the program on the following page. Edit the previous program to create the flowchart shown. www.colmac.ie 45 Initially we need to insert another Compare command that will check if both LDRs A0 and A2 have lost sight of the black line i.e. if the LDR reading has gone above 190. We will now look in closer detail at the commands that follow this new Compare command in order to see how the robot can look for a missing line. www.colmac.ie 46 Once the program detects that the sensors A1 and A0 are both off the line the motor stops briefly for half a second. This minimises the amount of over-shoot of the line. The For command is found in the Flow Control section of the flowchart symbols. It runs the series of commands between it and the End Loop command either a set number of times or for a given number of seconds – in this case, for 5 seconds. The Motor command that follows causes the robot to perform a two wheeled left turn in order to look for the line. Note that the sliders are set slightly less than max in order to slow the rotation speed. The Compare command checks to see if A2 is on the line during the left turn. If it is then the program follows the Y route back to the main section of the program. If not, after the 5 second loop ends, the motor performs a two wheeled right turn continuously until a further Compare command detects the line in the other direction. When it does the program follows the Y route back to the main section of the program. Again that the sliders are set slightly less than max in order to slow the rotation speed. www.colmac.ie 47 11. GENIE Programming Editor Help These notes are only an introduction to GENIE Programming Editor. It contains many more commands that have not been mentioned at all. Explanations of these other commands can be found in the Help section of the software by clicking on GENIE Programming Editor Help as shown below: Then select Flowchart commands as shown: This will open a window displaying all current GENIE commands. By clicking on any command the user will be given a simple explanation of what the command does along with a sample flowchart showing how the command may be used. www.colmac.ie 48 12. Troubleshooting Tips The most common problem involves getting the ‘No Device Found’ error when trying to connect to the GENIE E18 microcontroller using the USB cable. Follow the steps below when trying to resolve this issue: Check the USB cable is connected properly using the Troubleshoot GENIE tool in the Help section. Follow the steps in the window that opens. Pin 14 (+V) Test the supply voltage across pins 5 and 14 of the E18 microchip. These are the +/- power connections. There should be at least 3.5V in order for the chip to work properly and connect to your computer. Pin 5 (-V) NOTE: If the supply voltage is already low (</= 3.5V) it will drop further when the motors are turned on and this can also cause the chip to turn off and cease controlling/connecting etc. www.colmac.ie 49 If the USB cable is OK and the voltage at the chip is sufficient then the next most common problem is poor soldered connections. Please consult www.colmac.ie for soldering technique video. Check your soldering by examining the connections under a magnifying glass. You should see the following: The connection should be solid if you try to wiggle it with some tweezers or pliers. The pad should be covered completely but not overflowing. The solder should be shiny. The following are indicators of a poorly soldered joint: The pad and lead aren't completely covered with solder, enabling you to see through one side of the hole through which the lead passes. o You didn't apply enough solder, or the pad wasn't hot enough to accept the solder. The lead is loose in the hole or the solder isn't firmly attached to the pad. o You possibly moved the lead before the solder had completely cooled. The solder isn't shiny. o If the solder gets just barely hot enough to melt, then flows over a wire or pad that isn’t heated sufficiently, it will be dull when it cools. o Unfortunately, the new lead-free solder almost always cools dull, so it looks like a bad solder joint even when the joint is good! Solder overflows the pad and touches an adjacent pad. o This can happen if you apply too much solder. It can also happen if the pad didn't get hot enough to accept the solder, which can cause the solder to flow off the pad and onto an adjacent pad. If solder spills over from one pad to an adjacent pad, your circuit may not work right. www.colmac.ie 50 Solder not firmly attached to component leg can be caused by leg moving before solder had cooled fully. This is a difficult fault to find and is best located using a magnifying glass. Sometimes a pad can break off either during initial soldering or later de-soldering. Missing pad If this happens, scrape off the green protective coating and reconnect the broken track using Component leg cable links soldered to the component leg as shown. The photo below shows 6 examples of poorly soldered connections and 2 examples of properly soldered connections. Properly soldered connections www.colmac.ie 51 Finally, you may sometimes encounter strange things happening in your programs during either Debug Live or Run Live such as outputs turning on/off for no apparent reason. This can be caused by electrical interference generated by the motors during operation. This is a common problem when motors are being controlled by microcontrollers and is minimised by attaching a capacitor across the motor connection terminals. This is already done on the PCB with 2 x 100nF ceramic capacitors attached across terminals Q4/Q5 and Q6/Q7 as shown below. In the event that you still experience these types of issues you can solder a further 100nF capacitor directly across the terminals of the motor, at the actual motor – they have no polarity so it does not matter which way around they are connected – an example on a different motor is shown below. Notice that the cables are also glued to the body of the motor – this is good practice in order to minimise the chance of the motor cable connection being damaged through excessive movement of the cables. Consult www.colmac.ie for further help with troubleshooting www.colmac.ie 52 Circuit and PCB diagrams courtesy of www.genieonline.com www.colmac.ie 53 14. Improving you Line Follower racing There are numerous ways of improving the speed of your line follower with a view to entering competitions such as the annual Robotics Ireland tournament that features both line follower and mini sumo competitions. Here are some examples: 1. Increase the diameter of the wheels. This will necessitate recalibration of the LDR sensors. 2. Increase the voltage supply to the board. The manufacturers indicate that up to a 12V battery supply may be used but recommend not to use a 9V PP3 battery. Again, this will necessitate recalibration and editing of wait times etc. 3. Improve your programming skills and try out other commands such as Analogue, Sub etc. 4. Shield the LDR sensors from external light sources using a shield of your own design. This will improve the performance of the sensors. 5. Make your line follower as light as possible by removing unnecessary parts. Further Information www.colmac.ie [email protected] www.roboticsireland.com www.genieonline.com www.colmac.ie 54
© Copyright 2024