Download Print this page

Advertisement

Quick Links

StenBOT Rover Kit
1
Stensat Group LLC,
Copyright 2013

Advertisement

loading
Need help?

Need help?

Do you have a question about the StenBOT Rover Kit and is the answer not in the manual?

Questions and answers

Summary of Contents for Stensat StenBOT Rover Kit

  • Page 1 StenBOT Rover Kit Stensat Group LLC, Copyright 2013...
  • Page 2 Legal Stuff Stensat Group LLC assumes no responsibility and/or liability for the use of ● the kit and documentation. There is a 90 day warranty for the Quad-Bot kit against component defects. ● Damage caused by the user or owner is not covered.
  • Page 3 Table of Contents Overview ● Robot Kit Assembly ● Arduino Programming and Interfacing ● Robot Motor Control ● Robot Sensing ● Robot Remote Control ●...
  • Page 4 Overview...
  • Page 5 Goals The goal of this kit is to have a quad-bot platform that can operate on ● uneven terrain and even in sand autonomously or by remote control. You will learn basic autonomous operations using the ultrasonic range ● sensor. For remote operations, you will learn how to configure and program the ●...
  • Page 6 Program Overview Assemble Kit ● Programming to move ● Learning how to calibrate the motion ● Running the Maze ● Using sensors for collision avoidance ● Running the Maze using collision avoidance ● Remote control ●...
  • Page 7 Robot Parts Electronics The robot is made ● up structural parts, Cross Bar and mechanical parts Linkages and electronics. Electronics Plate Base Plate Gear Motors Rocker Arm Wheels...
  • Page 8 Suspension System The rocker arm suspension system is made of a few main components ● shown below Rocker Arms Linkages Cross Bar...
  • Page 9 How the Suspension Works Two motors are attached to the ● ends of the rocker arms. The center of the rocker arm is attach to the base plate and pivots. This lets both wheels on the same side keep touching the ground if one drops in a dip or goes up on something.
  • Page 10 How the Suspension Works When the one rocker arm Cross Bar ● Pivot Point changes its angle, the cross bar is pushed up or down to push the other rocker arm in the opposite direction. This helps keep the wheels on the other rocker arm touching the Linkage ground.
  • Page 11 How the Electronics Works The robot electronics controls the ● operations. It consists of a battery for Radio Battery Battery Radio power, a processor board for the brains, a motor controller to operate the motors and an ultrasonic sensor for detecting obstacles. Processor Processor Board...
  • Page 12 Battery The power source for the robot is a battery. The battery is made up of four ● AA cells. Multiple types of AA cells can be used in the robot. The simplest is alkaline ● cells that cannot be recharged and must be discarded when they are used up.
  • Page 13 Processor Board The processor board is the brains of ● the robot. It controls everything and connects to all the sensors. This is the part that you program to control the actions of the robot. The processor board has multiple ●...
  • Page 14 Motor Controller The motor controller is the interface between ● the motors and the processor board. It has circuitry to allow control of the motors and can handle the high currents required to operate the motors. The processor board cannot directly power the motors.
  • Page 15 The Motors The motors are connected to gears that ● translate the high speed of the motors to a Gear box slower rotations speed. This also increases the power of the motor so the wheels can turn to move the robot. The motor is a small DC brush motor shown ●...
  • Page 16 Ultrasonic Range Sensor The ultrasonic range sensor is ● a device that sends a short burst of sound and listens for the echo. The processor board starts the ● measurement by generating a pulse on the Trig pin. It them measures the size of ●...
  • Page 17 Ultrasonic Range Sensor Operation The ultrasonic range sensor operates in a specific sequence. ● It waits for a trigger signal. The trigger is a 10us pulse. Once the trigger is ● detected, the sensor generates a short signal at 40 KHz. It then waits for an echo and measures the time from sending the short burst ●...
  • Page 18 Base Plate The base plate is a fiberglass board with holes arranged in a .5 inch grid ● pattern. There are also other holes to mount specific things such as the suspension systems and the electronics. There are markings on the board identifying specific functions for the holes.
  • Page 19 Electronics Plate This is another fiberglass board that is used to hold the processor board and ● solderless bread board. 19 19...
  • Page 20 Solderless Bread Board The solderless bread board allows you to wire up circuits. It will be used to ● connect the motor controller to the motors and the processor board. It is also used for connecting the sensors. 20 20...
  • Page 21 End of Section In this section, you learned the parts of the robot and how they all tie ● together. 21 21...
  • Page 22 Assembly 22 22...
  • Page 23 Robot Assembly The robot assembly starts with the wheels, motors and suspension system. ● Once the suspension system with the motors and wheels installed are ● attached to the base plate, the electronics plate is assembled and installed. 23 23...
  • Page 24 Parts List 6 – 3/8” 4-40 screws 4 – geared motors with wheels ● ● 5 – 1/4” 4-40 screws Dual H-Bridge driver module ● ● 8 – 1/2” 4-40 screws 1 – electronics plate ● ● 9 – 1” 4-40 screws 1 –...
  • Page 25 Tools Needed Philips screw driver ● 1/4 inch nut driver ● 11/32 inch nut driver ● Soldering iron ● Solder ● Wire strippers ● Wire cutters ● 25 25...
  • Page 26 Definition of Components Screw – A cylindrical device with a raised helical thread running around it ● used to join things together. Sizes ● 4-40 means it is a #4 size screw with threads that wrap around 40 times per –...
  • Page 27 Definition of Components Nut – A device that mates to a screw to secure things together. The sizing is ● specified the same way, ie 4-40 or 6-32. Kep nut is a nut with an integrated lock washer. ● A nylon lock nut is a nut with a piece of nylon material inserted to keep the ●...
  • Page 28 Definition of Components Right angle bracket – A device that allows two things to be attached at right ● angles to each other. Standoff – A device that allows things to be attached to each other at a ● distance. Allows stacking. One end can be threaded like a screw and the other hollowed and threaded to be like a nut.
  • Page 29 Wiring the Motors First step is to install wires on the motors. ● The picture to the write shows the motor ● with the white shaft on the opposite side. The motor will either be red or black. They ● both work the same.
  • Page 30 Wiring the Motors There are jumpers that are connected in pairs. These will be the wires used ● to connect to the motors. They come in different colors. ● The colors do not matter. ● 30 30...
  • Page 31 Wiring the Motors One end of the wires is to be cut. It ● is the end with the socket connectors, not the pins sticking out. Use a wire cutter to cut the ● connectors off. Cut at the end of the connector as shown.
  • Page 32 Wiring the Motors After cutting the connectors off, ● strip the insulation off of both wires. Strip off about ¼ inch. Use the 26 ● awg notch on the wire stripper. 32 32...
  • Page 33 Wiring the Motors Insert the wires as shown in the ● picture. They should be inserted so that the wires sit over the geared motor housing. Solder the wires in place. ● The result should be like below. ● 33 33...
  • Page 34 Wiring the Motors Next, get a small zip tie and secure ● the wire as shown. Make sure the square block part of ● the zip tie is on the side. Cut the excess zip tie extending ● out with a wire cutter. Repeat the wiring for the other ●...
  • Page 35 Start of the Assembly The assembly will start with the wheels and suspension system. ● Below is a picture of the components. One side is shown. The second ● side will be assembled as a mirror image. Lock Nut 8-32 Screw Right Angle Bracket 35 35 Rocker Arm...
  • Page 36 Rocker Arm Assembly The rocker arm will mount to the robot base plate ● using the right angle bracket. The 8-32 screw is inserted into the larger hole on ● the right angle bracket as shown in the top right. Insert the screw with the bracket through the hole in ●...
  • Page 37 Rocker Arm Assembly Assemble the second rocker arm the opposite ● of the first one. The two rocker arms should look like the ● picture to the right. 37 37...
  • Page 38 Motor Preparations The four motors are to be prepared the same. ● Take two 1 inch screws and insert them from ● the white shaft side of the motors. Kep-Nuts Install a kep-nut on each screw and tighten to ● be snug.
  • Page 39 Motor Installation The motors are to be installed on the rocker arms. ● The motors mount on the opposite side of the right angle bracket. ● Secure each motor with two nuts. ● The nuts can be made tight. ● Right Angle Bracket Opposite Side of Motors Nuts 39 39...
  • Page 40 Mounting Motors Install the motors on the second ● rocker arm. They should look like the mirror of ● each other. Make sure the bracket is on the ● opposite side of the rocker arm from the motors. Make sure the wires from the motors ●...
  • Page 41 Suspension Linkage Bracket Before installing the rocker arms, small ● right angle brackets for the suspension linkage need to be installed. Locate the two small right angle ● brackets, 4-40 lock nuts, and 3/8 inch 4- 40 screws. Insert the screws into the smaller hole of ●...
  • Page 42 Suspension Linkage Bracket Mount the brackets onto the back side of the rocker arms as shown. ● Install the 4-40 lock nut on to the screw from the motor side and tighten with ● a ¼ inch nut driver. Tighten until the nut does not turn any more. ●...
  • Page 43 Mounting the Rocker Arms Brackets This End The rocker arms are to be mounted ● to the base plate. The end of the rocker arm with the right angle brackets must be opposite the side marked Front on the base plate. Use the ¼...
  • Page 44 Suspension Linkage Now, assemble the cross bar. ● Get a 1 inch 4-40 screw and 4-40 lock nut. ● Insert the screw into the center hole of the cross bar. ● Insert the lock nut and tighten all the way. ●...
  • Page 45 Cross Bar Mount Install a ¾ inch standoff in the center back hole of the base plate. The hole is ● marked “Suspension.” Insert the threaded side of the standoff in the hole and secure with a 4-40 kep-nut from the underside of the base plate. Do not over tighten as you may break the standoff.
  • Page 46 Cross Bar Mounting Bracket Install a small right angle bracket on top of the standoff and secure with a ¼ ● inch 4-40 screw. Use the larger hole of the right angle bracket. Align the bracket as shown. ● Threaded hole facing the back Right Angle Bracket ¼...
  • Page 47 Installing Cross Bar Screw the cross bar into the right angle bracket secured on the standoff. ● Don't screw in all the way. Leave about ¼ inch of threads. 47 47...
  • Page 48 Installing the Linkages Install the two linkages on to the cross bar. Use the 3/8 inch long 4-40 ● screws and lock nuts. Tighten the lock nuts and then loosen by a ½ turn of the nut driver. ● 3/8 Inch Screw and Lock Nut 48 48...
  • Page 49 Linking the Linkages Use another 3/8 inch 4-40 screw and 4-40 lock nut and secure the bottom ● end of the linkages to the brackets on the rocket arm. Tighten the lock nuts and then loosen with a half turn. ●...
  • Page 50 Testing the Suspension Make sure all linkage ● connections are loose. This allows the rocker arms to move freely and keep the base plate stable. Lift one motor and ● make sure all the other three motors stay on the surface. Up two three inches of height should be possible.
  • Page 51 Preparing for Mounting Electronics Install the threaded side of the four 1.5 inch standoffs in the holes marked ● “MNT”. Secure the standoffs with the kep-nuts and hand tighten. Use a nut driver to ● tighten with no more than a quarter turn. Again, do not over tighten as the standoff can be broken.
  • Page 52 Install the Wheels Next, install the wheels on each motor. The motor shaft is keyed with two flat ● spots. The motors slide onto the shaft. 52 52...
  • Page 53 Electronics Base Plate Base plate is for mounting ● solderless bread board and processor board Solderless bread board is to be ● mounted in the marked rectangular area. It has a blue backing that covers the screw holes. Punch holes into the backing material.
  • Page 54 Mount the Solderless Breadboard The solderless breadboard is ● mounted as shown. ½ inch 4-40 Screws 54 54...
  • Page 55 Processor Board Mount The process board is mounted differently. ● Insert screws from the back side and install a kep-nut on each screw. The ● nuts will serve as standoffs for the processor board. Look at the picture what holes are used. ½...
  • Page 56 Electronics Base Plate Assembly Place the processor board ● on top of the screw/kep-nuts installed in the previous step. Insert another set of four ● nuts to secure the processor board. 56 56...
  • Page 57 End of Section At this point, the robot structure and wheels are assembled along with the ● suspension system. The electronics plate is assembled but not installed on the robot at this time. ● The next section will focus on learning how the electronics works and how to use it and add circuits.
  • Page 58 Processor Board Arduino Software 58 58...
  • Page 59 Overview In this section, you will be introduced to the processor board electronics and ● the arduino software. At the end of this section, you will be able to write software, control things ● and sense the environment. 59 59...
  • Page 60 Processor Specifications The processor is shown to the right. It is called ● an embedded computer because it is to be integrated or embedded in something, this case a robot. The processor board has connections that allow ● devices to be interfaced such as lights, motors and sensors.
  • Page 61 Digital Pins The digital pins are highlighted in ● green. Digital Pins There are six digital ports identified as ● D3, D5, D6, D9, D10, D11 ● The digital pins can be used to control ● things and detect things. When the digital pin is set low, the ●...
  • Page 62 Processor Board Pinout The digital pin configuration is shown to ● Digital Signal the right. 5 Volts The digital pin is the most inward pin. This Ground ● is the digital signal that can be set to high or low, logic level 1 or 0, 5 volts or 0 volts. The next pin is 5 volts.
  • Page 63 UART A UART is a device that allows the processor ● to communicate with other devices. It communicates using a serial protocol which means it sends one bit of data at a time. UART is short for Universal Asynchronous ● Receiver/Transmitter.
  • Page 64 What are Bits and Bytes Bits are a unit of information in the computer. It has two states ● State 0 is logic level 0 also known as low and represented in the processor as 0 ● volts. State 1 is a logic level 1 also known as high and represented in the processor a ●...
  • Page 65 What are Bits and Bytes Example ● 10111001 equals 2 = 185 ● 128 + 32 + 16 + 8 + 1 = 185 ● Try a couple binary numbers ● 01100000 ● 10010101 ● Byte 65 65...
  • Page 66 What are Bits and Bytes There are larger numbers the processor can support ● int is a 16-bit number. The most significant bit has a weight of 2 to the 15 ● power. long is a 32-bit number. The most significant bit has a weight of 2 to the 31 ●...
  • Page 67 UART There are standard transmission speeds for ● UARTS. This is the number of bits per second, also called baud rate. Standard baud rates are: ● ● ● 1200 ● 4800 ● 9600 ● 19200 ● 38400 ● 57600 ● 115200 ●...
  • Page 68 UART The lessons here use 9600 baud or 9600 bits ● per second. There is a format to the serial transmission and the format helps the receiver to know when a new byte is being received. There is a start bit and a stop bit. The start bit ●...
  • Page 69 Power Selection There is a three pin jumper that ● lets you select how the processor board is powered. A shorting jumper is required to ● make the selection. The picture below shows the ● shorting jumper connecting EXT which connects the battery to power.
  • Page 70 Other Features Micro USB Port The power switch allows the ● processor and anything connected to be turned on and off when the battery is disconnected. The power selection shorting ● jumper also has to be set to EXT. The micro USB port is used for ●...
  • Page 71 Software Now that the processor features have been covered, it is time to learn about ● programming it. The processor uses the arduino software. This software allows you to write ● programs, compile them and upload them to the processor. It also allows you to interact with the software running on the processor.
  • Page 72 Loading and Configuring Arduino Software Copy the arduino-1.6.5 folder from the provided CD to the computer. ● The software can also be downloaded from www.stensat.org/products ● Just find the robot product and the software will be there. ● It can be installed anywhere on the computer.
  • Page 73 Configuring Arduino Software Plug the processor board into the computer USB port ● Let the operating system find the drivers. (network connection required) ● The driver is also included with arduino software – In the arduino program select menu “Tools” ●...
  • Page 74 Using Arduino This is the arduino software. ● The software will let you ● enter programs and upload the code to the processor board. The large white area is Area for entering code ● where the code is entered. The black area below is ●...
  • Page 75 Using Arduino The buttons below the menu ● have different functions. The first called Verify Code Verify ● Save Code will compile the code and Open Program check for errors but not Upload Code upload the code. The next button will do the ●...
  • Page 76 Using Arduino Serial Monitor button opens ● a new window allowing you to interact with the processor. Serial The Serial Monitor window ● Monitor allows the processor to display information and you to send information. This will be used quite a bit ●...
  • Page 77 Power Selection for Programming Before continuing, the power ● selection shorting jumper needs to be moved to the USB side. Pull the shorting jumper from the ● two pins and insert where it is marked USB. 77 77...
  • Page 78 First Program to Test Enter the program in the editor on the ● void setup() right. Do not copy and paste from the pdf file. It doesn't work. The Serial.begin(9600); compiler is case sensitive so pay attention to capitalized letters. void loop() Plug the processor board into the USB ●...
  • Page 79 What are Functions void setup() A function is basically a set of ● Serial.begin(9600); instructions grouped together. A function is created to perform a specific task. void loop() The set of instructions for a function are ● Serial.print(“Hello World”); bounded by the curly brackets as seen to the right.
  • Page 80 Other Syntax Requirements void setup() You will notice that some lines end with ● Serial.begin(9600); a semi-colon. This is used to identify the end of an instruction. An instruction can void loop() be an equation or function call. Serial.print(“Hello World”); When you create a function such as ●...
  • Page 81 Arduino Programming Basics The program is made up of two ● functions. setup() function is run at reset, void setup() ● power up or after code upload Serial.begin(9600); only once. It is used to initialize all the ● void loop() needed interfaces and any parameters.
  • Page 82 What is in the Software In the setup() function, it executes ● void setup() the function Serial.begin(9600); Serial.begin(9600); This function initializes the UART ● which is connected to the USB port to allow for communications. void loop() In the loop() function, it executes the ●...
  • Page 83 What is in the Software In the Serial Monitor window, you may ● void setup() have noticed that the text displayed scrolls to the right. That is just how Serial.begin(9600); Serial.print() works. To have the text displayed on its own ●...
  • Page 84 Electronics At this point, you should be able to run the arduino software. ● You should know that the software consists of two functions ● setup() ● loop() ● You should know how to initialize the UART and write a program to display ●...
  • Page 85 Electrical Circuits In this section, you will learn how to connect electrical circuits. ● Electrical circuits is nothing more than connecting wires between devices to ● allow the flow of electrons. A lamp plugged into an outlet has two wires to make an electrical circuit.
  • Page 86 How the Solderless BreadBoard Works The solderless bread board allows circuits to be quickly connected. ● Each row of holes that go left to right on the top and bottom are all connected ● together. The columns of 5 holes are all connected together. ●...
  • Page 87 Basic Electricity Battery ● Involves creating an imbalance of electrons to produce current. ● If both sides have the same amount of water on both sides of a chamber, no ● current can be produced. Water Water 87 87...
  • Page 88 Basic Electricity Battery ● But if all the water is on one side and none on the other, we can create ● current between the chambers. Current will flow because there is an imbalance of energy. ● Water 88 88...
  • Page 89 Basic Electricity Battery ● We make one chamber full of electrons and the other full of protons. ● If we put a wire between the two sides current will flow because there is an ● imbalance of energy. Electrons Protons 89 89...
  • Page 90 Basic Electricity Resistor ● A resistor is a device that impedes the amount of current going through it. ● It acts like a restrictor to water flow. ● Electrons Protons 90 90...
  • Page 91 Basic Electricity Resistor ● The resistor protects other devices by limiting the current that can flow into it. ● Resistors are always paired with LEDs to protect them. ● Electrons Protons 91 91...
  • Page 92 Basic Electricity Variable Resistor ● A variable resistor has a slide that allows you increase or decrease its ● resistance. It's like opening or closing a faucet to let more or less current in.. ● Electrons Protons Variable Resistor 92 92...
  • Page 93 What is an LED An LED is a Light Emitting Diode. It is a semiconductor that allows electrons ● in the wire to flow one way only. A diode has to parts, an N-type silicon which has extra electrons and a P- ●...
  • Page 94 What is an LED Connecting a battery to the diode with the negative the N-type and positive ● to the P-type side of the diode causes the electrons to be pushed from the N side to the P side. The depletion zone will shrink greatly. This is called forward-bias. ●...
  • Page 95 What is an LED Connecting a battery to the diode with the negative the P-type and positive ● to the N-type side of the diode stops all current flow. The depletion zone is greatly increased. This is because the positive side of ●...
  • Page 96 What is an LED An LED is a diode that gives off light when the electrons fill the holes. When ● an electron combines with a positively charged atom, it changes its energy state and gives off a photons. LEDs work only in the forward bias. ●...
  • Page 97 Components The first circuit will use a Light Emitting Diode ● or LED. The LED is a polarized device and only works ● in one direction and gives off light when current flows through it. The positive pin on the LED is the longer pin. It ●...
  • Page 98 First Circuit The first circuit will connect the LED straight to 5 volts ● so the LED will always be lit when there is power. The schematic for the circuit is shown to the right. ● The symbol at label R1 is for the resistor. ●...
  • Page 99 Resistor Code 270 ohm A resistor is a device that is used to limit the flow of current or reduce the voltage depending on how it is used. Resistor values are determined Color Name Digit 1 Digit 2 Multiplier Tolerance by the color bands.
  • Page 100 Wiring Diagram for LED Insert the LED into the bread board as shown. The short lead on the LED should be on the left side. Insert the 270 ohm resistor as shown. One lead should be installed in the same column as the long lead of the LED.
  • Page 101 LED Connected to Digital Pin 3 Move the red jumper from the 5V pin on the processor board to the pin marked Leave everything else as is.
  • Page 102 Connecting the LED to a Digital Pin The LED is not lit at this time ● because the digital pin 3 needs to be programmed to generate a voltage. The program to the right will cause ● the LED to blink. void setup() Create a new program and enter the ●...
  • Page 103 Connecting the LED to a Digital Pin In the setup() function, digital pin 3 is configured ● as an output. The function pinMode() configures digital pin 3 ● to be an output. pinMode() takes two arguments separated by ● void setup() a coma.
  • Page 104 digitalWrite() The digitalWrite() function controls a pin and can set it ● high or low. The function has two arguments separated by a ● coma. The first argument selects the digital pin. – The second argument sets the digital pin. –...
  • Page 105 Next Example The next example will be to detect light intensity. ● Remove the LED and switch circuit. ●...
  • Page 106 Resistor Voltage Divider There is a simple circuit that uses two ● resistors to divide a voltage from a higher level to a lower level. Voltage dividers can be used to ● reduce a voltage that is too high to a lower voltage that can be handled.
  • Page 107 Resistor Voltage Divider The resistors are connected together ● in series. The voltage source which is the ● battery in the picture to the left is connected across both resistors. The divided voltage is located at the ● connection between the two = V * R2/(R1+R2) resistors.
  • Page 108 Analog-to-Digital Converter An analog-to-digital converter or ADC is a device that generates a number ● based on the voltage level it measures. The ADC on the processor board can measure a voltage range from zero to ● 5 volts. If a higher voltage needs to be measured, the voltage divider circuit could be used to reduce the voltage to 5 volts or less.
  • Page 109 Processor Board Pinout The analog ports are highlighted in yellow. ● Six analog inputs are available: 0,1,2,3,6,7. ● The analog ports allow the measurement of ● voltages from sensors that generate a voltage based on what is being measured. Each analog port has 10 bit resolution and an ●...
  • Page 110 Photo Cell The photo cell is a light sensitive device that changes ● its resistance based on light intensity. The photocell can be used in a simple voltage divider ● circuit with a 4.7Kohm resistor. The color code is yellow, violet and red. The photo resistor will have a resistance ranging from ●...
  • Page 111 Photo Cell Software The program to the right will get an ADC value ● from analog port 0. void setup() Create a new program and enter the program to ● Serial.begin(9600); the right. Upload the program and open the serial monitor to view the values.
  • Page 112 Ultrasonic Range Sensor Exercise The next exercise will be to learn how to use the ultrasonic range sensor. ● The sensor uses bursts of sound and listens for an echo similar to a bat. ● Remove the photocell circuit. ●...
  • Page 113 Sensing the Environment To detect things in the environment for purpose of collision avoidance, an ● ultrasonic range sensor will be added to the robot. This sensor sends out a burst of audio signal at 40 Khz and detects the ●...
  • Page 114 Ultrasonic Range Sensor Insert the ultrasonic ranger as shown. It ● should be mounted close to the center of the robot. The pins are inserted at the end of the rows. Connect jumpers from the sensor to the ● processor GND to Analog GND ●...
  • Page 115 Ultrasonic Sensor The ultrasonic sensor has two void setup() ● signals, trigger and echo. Serial.begin(9600); pinMode(3,INPUT); A pulse is sent to the trigger and ● pinMode(5,OUTPUT); then the processor is to time when the echo returns. void loop() This requires two digital pins, one ●...
  • Page 116 Making a Function To make this useful for other ● long ultrasonic() programs, this program needs to digitalWrite(5,LOW); be turned into a function. delayMicroseconds(2); digitalWrite(5,HIGH); A function is a subroutine or ● delayMicroseconds(10); chunk of code that can be called digitalWrite(5,LOW);...
  • Page 117 Using the Function long ultrasonic() digitalWrite(5,LOW); The program to the right ● delayMicroseconds(2); shows how the function digitalWrite(5,HIGH); is included in the delayMicroseconds(10); program and where it is digitalWrite(5,LOW); long distance = pulseIn(3,HIGH); located relative to the if(distance == 0) return(1000); setup() and loop distance = distance/58;...
  • Page 118 Completing The Robot Motion...
  • Page 119 Overview At this point, you should know how to use the digital pins and analog ports. ● You had an introduction to conditional programming. ● Next is completing the robot and write software to make the robot move. ● First move the power selection shorting jumper to EXT. This will be needed ●...
  • Page 120 Mounting Electronics Plate Place the electronics plate on top of the standoffs. Make sure the solderless ● breadboard faces the front of the rover. Secure the electronics plate with four ¼ inch 4-40 screws at the corners. ● ¼ inch screws...
  • Page 121 Installing the Battery Holder To install the battery holder, ● take a pieces of double sided tape and stick it to the underside of the battery holder. Peel the other side and stick it ● to the base plate under the electronics plate.
  • Page 122 Motor Control Controlling the motors is the same as controlling the LED except two signals ● are needed. With two signals, you can control the direction of the motors and turn them ● on and off. The following pages will describe how to hook up the motors. ●...
  • Page 123 Motor Control Dual H-Bridge Driver is used to control the motors. It uses four transistors to control the polarity of the voltage supplied to the motor. The transistors are used as switches turning on and off. Below shows the H-bridge driver circuit and the current flows.
  • Page 124 Motor Control To make the motor turn on one direction, two switches need to be turned on to let power get to the motor. One switch connects the positive side of the battery to to one side of the motor and another switch connects the negative side to the other side of the motor.
  • Page 125 Motor Control Flip all the switches to the opposite position and the motor turns in reverse. Notice the polarity signs on the motor switched sides. Motor Battery...
  • Page 126 Motor Controller The motor controller is the ● interface between the motors and the processor board. It has circuitry to allow control of the motors and can handle the high currents required to operate the motors. The processor board cannot directly power the motors.
  • Page 127 H-Bridge Driver The motor controller module consists of two H-bridge ● drivers to control two motors. The circuit side is shown at the top right. The square ● block in the center contains the two motor drivers. The bottom picture shows the signal names next to ●...
  • Page 128 How the H-Bridge Driver Works This drawing shows how the H-Bridge driver works. Only one is shown. ● There are two signals that control the direction and operation. Control logic ● decodes the two signals and turns on the appropriate switches to control the motor.
  • Page 129 How the H-Bridge Driver Works When AIN1 is set to logic 1, the motor drives in the forward direction. ● You will notice that setting AIN1 = 1, and AIN2=0 turns on two signals that turn ● on the two switches. AIN1=1 Control Motor...
  • Page 130 How the H-Bridge Driver Works When AIN1 is set to logic 1, the motor drives in the reverse direction. ● You will notice that setting AIN1 = 0, and AIN2=1 turns on two signals that turn ● on the two switches. AIN1=0 Control Motor...
  • Page 131 How the H-Bridge Driver Works When you set both AIN1 and AIN2 to logic 1, you get a breaking action. ● This turns on the two bottom switches which shorts the motor connections ● together. The inductance created by the motor turning in one direction will power the motor to turn in the opposite direction.
  • Page 132 Power Selection for Programming Before continuing, the power ● selection shorting jumper needs to be moved to the EXT side. Pull the shorting jumper from the two ● pins and insert where it is marked EXT. Since the USB port cannot provide ●...
  • Page 133 Mount the Motor Controller Orient the motor controller ● module so that the words OUT are toward the processor board. This is so the wires from the motors can reach. Insert the motor controller ● module into the solderless breadboard as shown. The rows of pins need to on either side of the gap down the center of the board.
  • Page 134 Connect the Motors Take the pin connectors from ● the motors and connect to the motor driver. With the rover front facing ● you, take the left rear motor wires and plug into OUT A1 and OUT A2. It doesn't matter which wire is connected where.
  • Page 135 Connecting Power Connect a jumper wire ● from the pin marked BAT to the signal VIN on the motor driver module. Connect a jumper wire ● from the pin next to BAT marked GND to GND on the motor driver module.
  • Page 136 Motor Controller Power Connection Use a black wire and connect ● the pin to the solderless bread board where the motor controller has GND. There are two. Either will work. Connect the other end of the ● black wire to GND on GND below D11 on the processor board.
  • Page 137 Wiring The Motor Controller Use the jumper wires to ● connect the motor controller. Connect A1 IN to D6 ● Connect A2 IN to D9 ● Connect B2 IN to D10 ● Connect B1 IN to D11 ● This completes the ●...
  • Page 138 Digital Signal Connections...
  • Page 139 Testing the Motors To operate the motors, A1 or A2 need to be ● void setup() set high or low. pinMode(6,OUTPUT); Operation is simple if A1 and A2 are set off, ● pinMode(9,OUTPUT); the motors do not operate. pinMode(10,OUTPUT); pinMode(11,OUTPUT); If A1 is set high and A2 is low, the motors will ●...
  • Page 140 Direction Control The digital pins D6 and D9 control the right motors. ● Setting D6 high and D9 low makes the right wheels spin forward. ● Setting D6 low and D9 high makes the right wheels spin reverse. ● Setting D6 low and D9 low turns off the motors. ●...
  • Page 141 Direction Control Code Forward Motion Right Turn digitalWrite(6,HIGH); digitalWrite(6,LOW); digitalWrite(9,LOW); digitalWrite(9,HIGH); digitalWrite(10,HIGH); digitalWrite(10,HIGH); digitalWrite(11,LOW); digitalWrite(11,LOW); Reverse Motion Left Turn digitalWrite(6,LOW); digitalWrite(6,HIGH); digitalWrite(9,HIGH); digitalWrite(9,LOW); digitalWrite(10,LOW); digitalWrite(10,LOW); digitalWrite(11,HIGH); digitalWrite(11,HIGH); Halt digitalWrite(6,LOW); digitalWrite(9,LOW); digitalWrite(10,LOW); digitalWrite(11,LOW);...
  • Page 142 Creating Functions To make programming easier, ● void forward() functions will be created to specify the motions of the robot. digitalWrite(6,HIGH); digitalWrite(9,LOW); A function is a collection of ● digitalWrite(10,HIGH); instructions that are grouped and digitalWrite(11,LOW); given a name. The format is shown to the right ●...
  • Page 143 Motion Functions void forward() void right() digitalWrite(6,HIGH); digitalWrite(6,LOW); digitalWrite(9,LOW); digitalWrite(9,HIGH); digitalWrite(10,HIGH); digitalWrite(10,HIGH); digitalWrite(11,LOW); digitalWrite(11,LOW); void reverse() void left() digitalWrite(6,LOW); digitalWrite(6,HIGH); digitalWrite(9,HIGH); digitalWrite(9,LOW); digitalWrite(10,LOW); digitalWrite(10,LOW); digitalWrite(11,HIGH); digitalWrite(11,HIGH); void halt() digitalWrite(6,LOW); digitalWrite(9,LOW); digitalWrite(10,LOW); digitalWrite(11,LOW);...
  • Page 144 Creating a Separate Function File Start a new program with the ● Arduino program. Click on the down arrow to the right ● where circled in red. A menu will open. Select “New ● Tab” Below, it will ask for a name. ●...
  • Page 145 Driving Around void setup() Click on the tab to the left of 'move' ● tab. Enter the code to the right. pinMode(6,OUTPUT); pinMode(9,OUTPUT); The code to the right is a start. ● pinMode(10,OUTPUT); pinMode(11,OUTPUT); Notice the delay() function is ● included after each motion function.
  • Page 146 Speed Control It may be noticed that the robot may tend ● to drift to the left or right. This is due to the motors not being equally powerful. There is a way to attempt to equalize them ● by controlling their speed. A simple way to control the speed is to ●...
  • Page 147 analogWrite() The function analogWrite() function takes two values. ● First is the pin number. ● Second is the duty cycle represented as a value from 0 to 255. ● 0 is 0% duty cycle. – 255 is 100% duty cycle. –...
  • Page 148 Controlling Motor Speed void setup() Enter the program to the right. This program ● generates a PWM signal to the motor. Only one pinMode(6,OUTPUT); side needs a PWM signal. The other is set to 0 pinMode(9,OUTPUT); so no PWM signal is present. pinMode(10,OUTPUT);...
  • Page 149 Calibrating Travel Distance Since there is no feedback on the motors ● to detect distance or wheel rotation, time Start will be used to specify the distance and the amount of turning. Mark off two feet on the floor. Floor tile is ●...
  • Page 150 Calibrating Turns Now mark on the floor a right angle. If ● the floor has tiles, use the corner of a tile for your right angle. Program the robot to turn right and set ● Floor the delay to 400 ms and turn off. Tile Place the robot on the corner of the ●...
  • Page 151 New Movement Functions The movement functions can be modified using the analogWrite() function. ● Go back to the move file and replace all the digitalWrite() functions with analogWrite(). The pin numbers stay the same but the second parameter gets changed. ●...
  • Page 152 Obstacle Course Time Now for the fun part. Modify and expand the program to go through the ● obstacle course shown below. The large square represent 2 foot grids. This attempt through the course is called dead reckoning. Write a program to ●...
  • Page 153 Robot Sensing This section, you learn about using sensors to control the robots ● movements.
  • Page 154 Photo Cell The photo cell is a light sensitive device ● that changes its resistance based on light intensity. The photocell can be used in a simple ● voltage divider circuit with another resistor. The resistor is 4.7Kohms. The photo resistor will have a resistance ●...
  • Page 155 Photo Cell Program The program to the right will get an ADC ● value from analog port 0. void setup() Create a new program and enter the code. ● Serial.begin(9600); To measure the voltage, the function ● analogRead(port) is used. void loop() Six ports are available on the processor ●...
  • Page 156 Light Seeking Program The photo cell can be used to have the robot chase after a light source. ● Get a flash light and run the program in the previous page. Shine the light on ● the photo cell at some distant and observe the ADC value. The value should increase.
  • Page 157 Light Seeking Code Don't forget to include the movement ● void setup() functions in a separate tab. pinMode(6,OUTPUT); The code uses a conditional statement ● pinMode(9,OUTPUT); called if. pinMode(10,OUTPUT); pinMode(11,OUTPUT); If the photocell circuit detect light, the value ● Serial.begin(9600); from the ADC goes up.
  • Page 158 Sensing the Environment To detect things in the environment for purpose of collision avoidance, an ● ultrasonic range sensor will be added to the robot. This sensor sends out a burst of audio signal at 40 Khz and detects the ●...
  • Page 159 Mounting the Ultrasonic Ranger Insert the ultrasonic ranger as shown. It ● should be mounted close to the center of the robot. The pins are inserted at the end of the rows. Connect jumpers from the sensor to the ● processor GND to Analog GND ●...
  • Page 160 Ultrasonic Sensor The ultrasonic sensor has two void setup() ● signals, trigger and echo. Serial.begin(9600); A pulse is sent to the trigger and pinMode(3,INPUT); ● then the processor is to time when pinMode(5,OUTPUT); the echo returns. This requires two digital pins, one void loop() ●...
  • Page 161 Making a Function To make this useful for other ● long ultrasonic() programs, this program needs to digitalWrite(5,LOW); be turned into a function. delayMicroseconds(2); digitalWrite(5,HIGH); A function is a subroutine or ● delayMicroseconds(10); chunk of code that can be called digitalWrite(5,LOW);...
  • Page 162 Conditional Programming Now it is time to use the ultrasonic sensor ● to do collision avoidance. if(a < c) { execute code here The 'if' command will be used to test if the ● robot will collide with an object. if(a == c) { The format for the if statement is shown to ●...
  • Page 163 Collision Avoidance Program The program on the next page will use the code used to control the ● motors, the ultrasonic function, and the conditional command. Put together, the program will keep the robot from bumping into anything. ● Enter the code on the next page. The code should be written in a single ●...
  • Page 164 Collision Avoidance Program long ultrasonic() digitalWrite(5,LOW); delayMicroseconds(2); digitalWrite(5,HIGH); delayMicroseconds(10); void loop() digitalWrite(5,LOW); long distance = pulseIn(3,HIGH); long distance; if(distance == 0) forward(); return(1000); distance = ultrasonic(); distance = distance/58; if(distance < 10) { return(distance); reverse(); delay(1000); left(); void setup() delay(700); halt();...
  • Page 165 Obstacle Course Time Now for the fun part. Modify and expand the program to go through the ● obstacle course shown below. The large square represent 2 foot grids. The red rectangles represent a barrier that can be detected with the ultrasonic range sensor.
  • Page 166 Remote Control...
  • Page 167 Infrared Remote Control Find a TV remote. Chances are very good that it uses an infrared LED to ● send signals to control the TV. The remote will be used to control the robot. First, the control codes need to be captured. The first program will do that. ●...
  • Page 168 How IR Remotes Work The IR remote uses an LED that operates in the infrared range, specifically ● 990 nanometers. The emitter pulses the infrared light at 38 KHz, 38,000 times per second. The pulsed signal is then turned on and off at a lower rate so that bursts of 38 KHz light is transmitted.
  • Page 169 IR Receiver The infrared Receiver is a device that includes an IR detector and a circuit to ● detect IR signals modulated at 38 Khz. A photo diode is the sensor and connects to an input circuit that converts the ●...
  • Page 170 IR Receiver Add the IR receiver to the ● solderless breadboard. Note the orientation as the connections need to be made in a specific order or the receiver may be damaged. Look at the picture to the right of ● the IR receiver.
  • Page 171 Wiring the IR Sensor Connect pin 3 of the IR ● sensor to GND under Digital pin D3. Connect pin 2 of the IR ● sensor to 5V under Digital pin D3. Connect pin 1 of the IR ● sensor to Digital pin D3. Be careful to not connect ●...
  • Page 172 IR Receiver Connections Connect pin 3 of the IR ● sensor to GND under Digital pin D3. Conenct pin 2 of the IR ● sensor to 5V under Digital pin D3. Connect pin 1 of the IR ● sensor to Digital pin D3.
  • Page 173 Remote Code Capture Program In the Arduino software, select File then Examples. Look for Irremote and ● select IRrecvDemo. When the program is loaded, look for the line 'int RECV_PIN = 11;' and ● change the pin number to 3. Upload the program into the robot.
  • Page 174 Capturing the Remote Codes With the program running, press ● Forward _______________ the button for forward and record the result. Left _______________ Do the same for left, right, and ● reverse. Right _______________ Reverse _______________...
  • Page 175 Robot Control Program The next program will receive the IR commands and active the motors for ● the selected operation. The sequence is to receive a key code, compare it, then execute the proper ● code then go back and wait for the key code to be sent again.
  • Page 176 IR Remote Code #include <IRremote.h> Start a new program. ● unsigned long tt; Under the 'Sketch' menu, select the ● IRrecv irrecv(3); 'IRremote' library. decode_results results; This will insert an include file statement void setup() ● at the top of the program. Two are irrecv.enableIRIn();...
  • Page 177 IR Remote Code (contintued) void loop() if(irrecv.decode(&results)) { FORWARD if(results.value == forward(); LEFT } else if(results.value == left(); RIGHT } else if(results.value == right(); REVERSE } else if(results.value == reverse(); tt = 0; irrecv.resume(); tt++; if(tt > 3400) { // increase value if robot stutters halt();...
  • Page 178 Running the Robot with the Remote Make sure the code includes the movement functions from earlier in the ● lesson material. All those functions should be placed just above the setup() function. Now that the code is complete, test the program and verify the robot moves ●...
  • Page 179 Driving on Sand The suspension system allows the robot ● to operate over a variety of terrain. Sand is another surface that is a ● challenge to robots. Try driving the robot in sand and turn. Build a sand mound and try driving up the slope.
  • Page 180 Conclusion At this point, you should have a functioning rover that can drive through ● sand, gravel, and dirt. It can be controlled with a TV remote control and can be configured for collision avoidance.