background image

 

94

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. 

N

P

Battery

+

-

Electron

Flow

Содержание StenBOT Rover Kit

Страница 1: ...1 StenBOT Rover Kit Stensat Group LLC Copyright 2013 ...

Страница 2: ...river backwards plugging the power input into an AC outlet applying more than 9 volts to the power input dropping the kit kicking the kit throwing the kit in fits of rage unforeseen damage caused by the user owner or any other method of destruction If you do cause damage we can sell you replacement parts or you can get most replacement parts from online hardware distributors This document can be c...

Страница 3: ...3 Table of Contents Overview Robot Kit Assembly Arduino Programming and Interfacing Robot Motor Control Robot Sensing Robot Remote Control ...

Страница 4: ...4 Overview ...

Страница 5: ...perate 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 quad bot to be controlled by a TV remote control ...

Страница 6: ... 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 ...

Страница 7: ...7 7 Robot Parts The robot is made up structural parts mechanical parts and electronics Gear Motors Wheels Rocker Arm Base Plate Cross Bar and Linkages Electronics Plate Electronics ...

Страница 8: ...8 8 Suspension System The rocker arm suspension system is made of a few main components shown below Rocker Arms Cross Bar Linkages ...

Страница 9: ...ors 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 Pivot Point ...

Страница 10: ...her rocker arm in the opposite direction This helps keep the wheels on the other rocker arm touching the ground The linkages attach the rocker arms to the cross bar The cross bar is attached to the base plate so the base plate changes its angle half way between the two rocker arms Pivot Point Cross Bar Pivot Point Linkage ...

Страница 11: ...w the electrical components are interconnected The battery powers everything The processor board is the brains and controls everything The motor controller provides the proper interfaces to the motors for the processor board to control the motors The radio provides a method for remote control Battery Battery Processor Board Processor Board Motor Controller Motor Controller Left Motor Left Motor Ri...

Страница 12: ...at over time the robot will slow down as the batteries drain Rechargeable cells can be used There is Ni Cad and nickle metal hydride or Ni MH These cells have a slightly lower voltage of 1 25 volts The benefit is the cells can be recharged and reused many times Another benefit is these cells can deliver more current without dropping the voltage unlike alkaline cells These types of batteries also m...

Страница 13: ...obot 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 interfaces Digital signals Servo motor Communications Analog inputs More details will be covered later ...

Страница 14: ...processor board cannot directly power the motors The controller is capable of providing the needed current and is used as the interface The black square in the picture to the right is the actual controller It is an integrated circuit that contains all the circuitry to translate signals from the processor board to the operations of the motors This controller can operate two sets of motors More deta...

Страница 15: ...eels can turn to move the robot The motor is a small DC brush motor shown at the bottom It is inserted into the yellow gear box At the top side of the picture on the opposite side is a white shaft The wheel attaches to the shaft The gears convert the high speed rotation of the motor and produces a slower rotating shaft The torque is also increased at the shaft Motor Gear box ...

Страница 16: ...rts the measurement by generating a pulse on the Trig pin It them measures the size of the pulse on the Echo pin The processor calculates the distance based on the size of the pulse width Distance is calculated by dividing the pulse width measured in microseconds by 58 Answer is in centimeters Connections 5 Volt power Trigger signal Echo signal Ground ...

Страница 17: ...ted the sensor generates a short signal at 40 KHz It then waits for an echo and measures the time from sending the short burst to receiving the echo The sensor then generates a pulse on the echo with a length proportional to the delay measured Trig Transducer Receiver Echo 10us pulse on Trig pin 40 Khz burst signal Echo from target Pulse on Echo pin Delay distance pulse width us 58 ...

Страница 18: ...iberglass 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 ...

Страница 19: ...19 19 Electronics Plate This is another fiberglass board that is used to hold the processor board and solderless bread board ...

Страница 20: ...olderless 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 ...

Страница 21: ...21 21 End of Section In this section you learned the parts of the robot and how they all tie together ...

Страница 22: ...22 22 Assembly ...

Страница 23: ...bly 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 ...

Страница 24: ... standoff 4 1 5 standoffs 3 small right angle brackets 2 large right angle brackets 1 Fiberglass base plate 1 Suspension System 4 geared motors with wheels Dual H Bridge driver module 1 electronics plate 1 processor board 1 solderless bread board 10 jumpers 1 ultrasonic range sensor 1 LED 1 270 ohm resistor 1 Photoresistor 1 4 7K ohm resistor 1 Infrared receiver 1 battery holder 1 USB cable ...

Страница 25: ...25 25 Tools Needed Philips screw driver 1 4 inch nut driver 11 32 inch nut driver Soldering iron Solder Wire strippers Wire cutters ...

Страница 26: ...0 means it is a 4 size screw with threads that wrap around 40 times per inch length 4 size is 112 inches diameter 6 is 138 inches diameter 8 is 164 inches diameter Length is how long the threaded part of screw is The screw pictured at the right is a machine screw Screws with a pointy end are wood screws or sheet metal screws Threaded part Head ...

Страница 27: ...e 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 nut from spinning freely It is used to join things together but let them move against each other Nylon Lock Nut Kep Nut ...

Страница 28: ... 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 They are made in different lengths The rovers uses a 1 5 inch and inch long standoffs Standoff Right Angle Bracket ...

Страница 29: ...shows the motor with the white shaft on the opposite side The motor will either be red or black They both work the same There are two copper tabs This is where the wires will be soldered to the motor Some times the tabs are bent up a bit Use a needle nose plier to straighten them out Copper Tabs ...

Страница 30: ...30 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 ...

Страница 31: ...he 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 Don t waste any wire ...

Страница 32: ...32 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 ...

Страница 33: ...33 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 ...

Страница 34: ...tors 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 three motors ...

Страница 35: ...mbly 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 Rocker Arm Right Angle Bracket Lock Nut 8 32 Screw ...

Страница 36: ...et through the hole in the center of the rocker arm Insert the lock nut onto the screw The lock nut has a nylon insert that makes the nut go on tight A 11 32 nut driver or pliers will be needed to tighten the nut onto the screw Tighten the nut all the way Once tight turn back the nut driver a little bit so the rocker arm can move freely but have little side to side wiggle Right Angle Bracket 8 32 ...

Страница 37: ...37 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 ...

Страница 38: ...mage the plastic structure of the motors Prepare all four motors the same The kep nuts are installed to offset the motor from the rocker arm This allows space for the wire to be between the motor and the rocker arm The tie wrap is used as a strain relief to protect the wire from breaking off the motor connection This also allows the user to easily make repairs or replace the wiring if desired Kep ...

Страница 39: ...n 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 Nuts Right Angle Bracket Opposite Side of Motors ...

Страница 40: ...ors 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 are router toward the center of the rocker arms ...

Страница 41: ... 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 the right angle brackets The hole is threaded so a screw driver is needed Screw in the screws as shown in the lower right ...

Страница 42: ...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 Loosen the nut one turn The right angle bracket needs to be loose Bracket and screw inserted opposite side of motors ...

Страница 43: ... marked Front on the base plate Use the inch 6 32 screws Insert the screws at the center hole along the edges marked suspension Screw in the right angle bracket of the rocker arm Before tightening adjust the rocker arms so they are parallel with the edge of the base plate Tighten the screws when the rocker arms are parallel Front Side 6 32 Screws Brackets This End ...

Страница 44: ... 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 Once tightened loosen the lock nut about a turn The cross bar should rotate freely on the screw Cross Bar 4 40 1 Inch Screw 4 40 Lock Nut ...

Страница 45: ...ert 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 It is made of aluminum Once the nut is tightened by hand a quarter turn with the nut driver is sufficient Too tight and you can break the standoff Standoff ...

Страница 46: ...ket 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 Right Angle Bracket Threaded hole facing the back inch Screw ...

Страница 47: ...47 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 ...

Страница 48: ...nstalling 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 ...

Страница 49: ...e 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 Secure Bottom of Linkages ...

Страница 50: ...ure 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 ...

Страница 51: ...eaded 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 1 5 Inch Standoffs ...

Страница 52: ...52 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 ...

Страница 53: ... blue backing that covers the screw holes Punch holes into the backing material Use the 1 2 inch screws and kep nuts to secure as shown in the next page Insert the screws from the top through the solderless bread board and secure with 4 40 nuts on the back side Make sure the solderless bread board is oriented as shown in the picture on the next page Solderless Bread Board Holes ...

Страница 54: ...54 54 Mount the Solderless Breadboard The solderless breadboard is mounted as shown inch 4 40 Screws ...

Страница 55: ... 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 inch Screws with Nuts ...

Страница 56: ...56 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 ...

Страница 57: ...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 ...

Страница 58: ...58 58 Processor Board and Arduino Software ...

Страница 59: ...verview 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 ...

Страница 60: ...rfaced such as lights motors and sensors There are two types of interfaces that will be used for the robot digital interfaces and analog The digital interfaces can be configured as an input or output As an input the digital interface can detect the state of switches or other signals as being on or off As an output the digital interface can turn things on and off such as lights The analog interface...

Страница 61: ...ere 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 voltage is set to zero volts When the digital pin is set high the voltage is set to 5 volts Digital Pins ...

Страница 62: ... power that can be used It is available when the power switch is set to on and an external power source is connected The USB port does not power this 5 volts for the protection of the host computer The last pin closest to the edge of the board is the ground This is the reference voltage of zero volts The pins are positioned so a servo motor can be directly plugged in Each pin can be configured as ...

Страница 63: ...l Asynchronous Receiver Transmitter The transmitter part takes a byte of data which is made up of 8 bits It sends the byte of data one bit at a time The receiver gets the bits one at a time and the assembles it back into the original byte The advantage of a UART is that it reduces the number of electrical connections to send data to another device Three wires are only needed to send 8 bits instead...

Страница 64: ...e processor a greater than 2 volts Bytes are a group of 8 bits This allows values greater than 1 to be processed There is a weighting scheme so that numbers can be represented using a byte The least significant bit has a weight of zero 2 to the power of 0 is 1 The most significant bit has a weight of seven 2 to the power of 7 is 128 Add up all the weights of the bits that are set to logic 1 to get...

Страница 65: ...65 65 What are Bits and Bytes Example 10111001 equals 27 25 24 23 20 185 128 32 16 8 1 185 Try a couple binary numbers 01100000 10010101 Byte 27 26 25 24 23 22 21 20 ...

Страница 66: ...d 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 power ...

Страница 67: ...67 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 300 600 1200 4800 9600 19200 38400 57600 115200 ...

Страница 68: ...ew byte is being received There is a start bit and a stop bit The start bit indicates the beginning of transmission The stop bit indicates the end When not sending data the transmit signal is always high or logic level 1 The start bit is detected as the signal goes from 1 to 0 A stop bit is a logic level 1 signal D0 D1 D2 D3 D4 D5 D6 D7 IDLE Start Bit Stop Bit ...

Страница 69: ...ssor 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 With the shorting block in the USB position the USB port would power the processor eliminating the need for batteries ...

Страница 70: ... 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 uploading programs and also interacting with the processor Micro USB Port Power Switch ...

Страница 71: ...and upload them to the processor It also allows you to interact with the software running on the processor Only one program can be installed and run at a time The processor is small and does not have an operating system Embedded computers are designed to perform a specific task and not operate like a desktop computer or laptop More information about the arduino software can be found at www arduino...

Страница 72: ...and the software will be there It can be installed anywhere on the computer Open the folder and double click Arduino The first step is to select the correct processor Arduino software supports many different variations In the arduino program select menu Tools Select Board Select Arduino Pro or Pro Mini at or near the top of the menu Go back and select Processor under the Tools menu Select Atmega32...

Страница 73: ...tem find the drivers network connection required The driver is also included with arduino software In the arduino program select menu Tools Select serial Port Select the appropriate COM port If you have a modem built in or existing COM ports the COM number for the processor will usually be the highest number ...

Страница 74: ...and upload the code to the processor board The large white area is where the code is entered The black area below is where error messages will be displayed such as when there is an error in the code or the software cannot upload code for some reason Area for entering code error message area ...

Страница 75: ...and check for errors but not upload the code The next button will do the same as the first but also upload the code New Program button opens a new copy of the program allowing you to start writing another program Open and Save are for opening and saving the code you have written Verify Code Upload Code New Program Open Save ...

Страница 76: ...tor button opens a new window allowing you to interact with the processor The Serial Monitor window allows the processor to display information and you to send information This will be used quite a bit in this section Serial Monitor ...

Страница 77: ...77 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 ...

Страница 78: ... board into the USB port Click on the upload Code button to compile and upload the program When the status message at the bottom of the window says done uploading click on the serial monitor button The Serial Monitor window pops up with the message being displayed Experiment by changing the message Save your program Pick a file name void setup Serial begin 9600 void loop Serial print Hello World S...

Страница 79: ...tructions for a function are bounded by the curly brackets as seen to the right The setup function is used to initialize the processor board variables and devices Inside functions you can call other functions Serial begin is a function It is located somewhere else in the arduino software void setup Serial begin 9600 void loop Serial print Hello World ...

Страница 80: ...nes end with a semi colon This is used to identify the end of an instruction An instruction can be an equation or function call When you create a function such as setup you do not need a semi colon void setup Serial begin 9600 void loop Serial print Hello World ...

Страница 81: ...ce the name loop This program configures the serial interface to send messages at 9600 bits per second The message is Hello World and is repeatedly displayed void setup Serial begin 9600 void loop Serial print Hello World delay 500 Serial begin is a function that intializes the serial interface and sets the bit rate Serial println sends the specified message over the serial interface and move the ...

Страница 82: ...ction it executes the function Serial print Hello world This function send the text in quotes to the UART This is displayed in the Serial Monitor window The other function is called delay This function stops the program for a specified period of time The unit is in milliseconds The code to the write displays the text every half second void setup Serial begin 9600 void loop Serial print Hello World...

Страница 83: ...Serial print works To have the text displayed on its own line change the Serial print to Serial println Serial println adds a line feed which forces the text in the Serial Monitor to move down one line Make the change upload the code and open the Serial Monitor window void setup Serial begin 9600 void loop Serial println Hello World delay 500 ...

Страница 84: ...know that the software consists of two functions setup loop You should know how to initialize the UART and write a program to display text in the Serial Monitor window You should know how to open the Serial Monitor window Next is learning a little about electronics and how to control things ...

Страница 85: ...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 ...

Страница 86: ...onnected 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 The lines in the picture show the connections Components and wires are inserted in the holes to make connections Back side showing how holes are connected ...

Страница 87: ...7 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 ...

Страница 88: ...88 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 ...

Страница 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 ...

Страница 90: ...90 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 ...

Страница 91: ...91 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 LED ...

Страница 92: ...tricity 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 LED Variable Resistor ...

Страница 93: ... A diode has to parts an N type silicon which has extra electrons and a P type silicon that is short of electrons which are called holes where electrons would go A diode has the N type and P type silicon placed next to each other with a depletion zone in between This depletion zone has no free electrons or holes N P Depletion Zone ...

Страница 94: ...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 N P Battery Electron Flow ...

Страница 95: ... N type side of the diode stops all current flow The depletion zone is greatly increased This is because the positive side of the battery is attracting the free electrons from the N type away from the P type side This is called reverse bias and why diodes only conduct current in one direction N P Battery ...

Страница 96: ...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 N P Battery Electron Flow ...

Страница 97: ... one direction and gives off light when current flows through it The positive pin on the LED is the longer pin It is called the anode The other end is the cathode LEDs need the current to be limited otherwise it will take too much and burn out A resistor will be used to limit the current flow through the LED LED Resistors ...

Страница 98: ...the right The symbol at label R1 is for the resistor LED1 is next to the symbol for the LED The symbol at the top is the 5V connection It is called VCC The GND symbol is for ground This is the zero volt reference The LED has an anode and a cathode The anode is the long pin When the anode is at a higher voltage than the cathode the LED will light Anode Cathode Resistor 5V ...

Страница 99: ...stor 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 by the color bands The picture to the left shows how to decipher the color bands The first two bands determine numerical value and the third band is the multiplier A 270 ohm resistor has a red violet and brown band The last band indicates the how far off the v...

Страница 100: ...er resistor lead is inserted in any other column Take the black jumper wire and insert the pin into the column of the short LED lead Plug the other end into the ground pin as shown Take a red jumper and connect the pin into the same column as the resistor lead and the other end into 5V pin as shown Plug the processor board into the computer USB port The LED should light up If not reinsert the LED ...

Страница 101: ...101 101 LED Connected to Digital Pin 3 Move the red jumper from the 5V pin on the processor board to the pin marked D3 Leave everything else as is ...

Страница 102: ...ge The program to the right will cause the LED to blink Create a new program and enter the code Upload the code to the processor board Make sure the processor boar is plugged into the USB port Save the program and use a new file name such as blinky void setup pinMode 3 OUTPUT void loop digitalWrite 3 HIGH delay 500 digitalWrite 3 LOW delay 500 ...

Страница 103: ...in The second argument configures the digital pin as an output in the loop function digital pin 3 is set high which causes the pin to generate 5 volts The LED turns on The delay function halts the program for 500 milliseconds The next digitalwrite command sets digital pin 3 to 0 volts turning off the LED Save the program and use a new file name such as blinky void setup pinMode 3 OUTPUT void loop ...

Страница 104: ...e digital pin The second argument sets the digital pin When set high the pin is set to 5 volts In logic terms a high signal is logic level 1 When set low the pin is set to 0 volts In logic terms a low signal is logic level 0 The function is written as digitalWrite pin setting setting is HIGH or LOW The letters need to be capital HIGH 5 volts Logic 1 LOW 0 volts Logic 0 ...

Страница 105: ...105 105 Next Example The next example will be to detect light intensity Remove the LED and switch circuit ...

Страница 106: ...an be used to reduce a voltage that is too high to a lower voltage that can be handled Another use for this type of circuit is if one of the resistors is a sensor like temperature or light sensor where its resistance changes with what it measures This circuit makes it simple to connect to an analog to digital converter R1 R2 Battery Vout V 0V Vout V R2 R1 R2 ...

Страница 107: ...is connected across both resistors The divided voltage is located at the connection between the two resistors The voltage can be calculated by the equation to the left V is the voltage across both resistors R1 and R2 are the resistors of some value They can be any value to get a variety of different voltages R1 R2 Battery Vout V 0V Vout V R2 R1 R2 ...

Страница 108: ...s to be measured the voltage divider circuit could be used to reduce the voltage to 5 volts or less The ADC is 10 bits This gives a numerical range of zero to 1023 It is a linear relationship to the voltage range of 0 to 5 volts The ADC will generate a value of 0 for 0 volts 1023 for 5 volts and 511 for 2 5 volts The resolution of the ADC is 5 1023 or 0 00489 volts per bit Voltage the ADC measures...

Страница 109: ...alog port has 10 bit resolution and an input range of 0 to 5 volts Signals beyond this range need to be converted to operate within the 0 to 5 volts or damage may occur The processor has an analog to digital converter or ADC to convert the analog voltage to a digital value The ADC has a 10 bit resolution which converts 0 to 5 volts to a number with a range of 0 to 1023 It is a linear relationship ...

Страница 110: ...t and red The photo resistor will have a resistance ranging from 20 Mohm in darkness to 5K ohms in bright light Install the photo cell and 4 7 K resistor on the solderless bread board as shown to the right Connect the free end of the resistor to GND at the analog connector Connect the free end of the photo cell to 5 volts Connect the resistor and photo cell connection to pin 0 of the analog connec...

Страница 111: ...board 0 1 2 3 6 7 Refer to page 5 for the location Once the ADC value is read it can be converted to a voltage value The code to the right shows the equation which can be used for all the analog ports The Serial println function that displays the volts includes a numeric argument which specifies the number of decimal places Save the program Use a new name like photocell void setup Serial begin 960...

Страница 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 ...

Страница 113: ...ollision 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 echo The processor needs to measure the time it takes for the echo to return This sensor has four pins Ground 5 Volt power input Trigger Echo ...

Страница 114: ...robot The pins are inserted at the end of the rows Connect jumpers from the sensor to the processor GND to Analog GND ECHO to pin D3 TRIG to pin D5 VCC to Analog 5V Look on the processor board for the word ANALOG The power connections are done there to isolate the sensor from the motor power to reduce electrical noise ...

Страница 115: ...ed is called pulseIn This measures the time it takes a pulse to occur in microseconds Try the program to the right The results are in centimeters Create a new program and enter the code to the right Save the program and upload it void setup Serial begin 9600 pinMode 3 INPUT pinMode 5 OUTPUT void loop digitalWrite 5 LOW delayMicroseconds 2 digitalWrite 5 HIGH delayMicroseconds 10 digitalWrite 5 LOW...

Страница 116: ...his function will return a result The return command specifies which variable is sent back to the calling code long ultrasonic digitalWrite 5 LOW delayMicroseconds 2 digitalWrite 5 HIGH delayMicroseconds 10 digitalWrite 5 LOW long distance pulseIn 3 HIGH if distance 0 return 1000 distance distance 58 return distance The function pulseIn returns the number of microseconds The result is then divided...

Страница 117: ...ction has to be located before the code that calls the function long ultrasonic digitalWrite 5 LOW delayMicroseconds 2 digitalWrite 5 HIGH delayMicroseconds 10 digitalWrite 5 LOW long distance pulseIn 3 HIGH if distance 0 return 1000 distance distance 58 return distance void set Serial begin 9600 pinMode 3 INPUT pinMode 5 OUTPUT void loop long a ultrasonic Serial println a ...

Страница 118: ...118 118 Completing The Robot Motion ...

Страница 119: ...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 for motor control Remember when uploading code to turn the processor power switch the ON position ...

Страница 120: ... 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 ...

Страница 121: ... 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 Plug the battery wires into the processor board ...

Страница 122: ...direction of the motors and turn them on and off The following pages will describe how to hook up the motors A motor driver module is needed This module allows a computer to control the motors The motors require more power than the computer signals can provide so the module provides the power The motor driver uses what is called an H Bridge Driver ...

Страница 123: ...s 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 Motor Battery ...

Страница 124: ...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 Motor Battery ...

Страница 125: ...125 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 ...

Страница 126: ...ors 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 The controller is capable of providing the needed current and is used as the interface ...

Страница 127: ...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 the pins Power is supplied at pins GND and VIN Control signals for each motor is A1 IN A2 IN and B1 IN B2 IN The motors connect to the pins marked OUT The other pins are not used ...

Страница 128: ...rawing 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 The drawing shows the condition of AIN1 and AIN2 set to logic zero ...

Страница 129: ...e Driver Works Control Logic Motor Battery AIN1 1 AIN2 0 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 ...

Страница 130: ...e Driver Works Control Logic Motor Battery AIN1 0 AIN2 1 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 ...

Страница 131: ...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 It causes the motor to slow down quickly ...

Страница 132: ...is marked EXT Since the USB port cannot provide enough power to operate the motors and should not be connected anyway the power selection needs to be switched to external This will allow the batteries to power the processor and the motors Now that external power is selected the power switch must be in the ON position for programming Don t let the robot drive off the table during programming ...

Страница 133: ...r 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 ...

Страница 134: ...acing you take the left rear motor wires and plug into OUT A1 and OUT A2 It doesn t matter which wire is connected where Do the same for the front left motor Take the wires from the rear right motor and connect to OUT B1 and out B2 Do the same for the front right motor Make sure the wires are connected in the correct rows ...

Страница 135: ...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 The next page shows the jumpers ...

Страница 136: ...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 Connect the pin of a red wire to VIN on the solderless bread board and the other end to a single pin next to the power connector This pin connects directly to the battery ...

Страница 137: ...ontroller 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 connections between the motor controller and the processor board ...

Страница 138: ...138 138 Digital Signal Connections ...

Страница 139: ...site direction The same applies for B1 and B2 Enter the program on the right to turn the motors on See which way the wheels are turning and swap the motor pins if needed to make the wheels spin forward These pin settings will be used for forward motion void setup pinMode 6 OUTPUT pinMode 9 OUTPUT pinMode 10 OUTPUT pinMode 11 OUTPUT void loop digitalWrite 6 HIGH digitalWrite 9 LOW digitalWrite 10 H...

Страница 140: ...The digital pins D10 and D11 control the left motors Setting D10 high and D11 low makes the left wheels spin forward Setting D10 low and D11 high makes the left wheels spin reverse Setting D10 low and D11 low turns off the motors Making the left motors go forward and the right motors go reverse turns the robot right Making the left motors go reverse and the right motors go forward turns the robot ...

Страница 141: ...digitalWrite 6 LOW digitalWrite 9 HIGH digitalWrite 10 LOW digitalWrite 11 HIGH Halt digitalWrite 6 LOW digitalWrite 9 LOW digitalWrite 10 LOW digitalWrite 11 LOW Right Turn digitalWrite 6 LOW digitalWrite 9 HIGH digitalWrite 10 HIGH digitalWrite 11 LOW Left Turn digitalWrite 6 HIGH digitalWrite 9 LOW digitalWrite 10 LOW digitalWrite 11 HIGH ...

Страница 142: ...rouped and given a name The format is shown to the right with one of the motions The code in the loop function can call the forward function eliminating the need to rewrite the digitalWrite functions every time The motion functions should be inserted at the top of all programs void forward digitalWrite 6 HIGH digitalWrite 9 LOW digitalWrite 10 HIGH digitalWrite 11 LOW ...

Страница 143: ...rite 6 LOW digitalWrite 9 HIGH digitalWrite 10 LOW digitalWrite 11 HIGH void halt digitalWrite 6 LOW digitalWrite 9 LOW digitalWrite 10 LOW digitalWrite 11 LOW void right digitalWrite 6 LOW digitalWrite 9 HIGH digitalWrite 10 HIGH digitalWrite 11 LOW void left digitalWrite 6 HIGH digitalWrite 9 LOW digitalWrite 10 LOW digitalWrite 11 HIGH ...

Страница 144: ...the right where circled in red A menu will open Select New Tab Below it will ask for a name Enter move Do not put c on the end of the name or the program will not compile properly Click OK A new tab is created called move You will enter all the movement functions here Enter the functions listed in the previous page ...

Страница 145: ...obot time to perform that motion The value included in the delay function is time in milliseconds Add directions to the program and change up the delays Come up with a complex set of motions Always remember to include a delay after the function to move the robot void setup pinMode 6 OUTPUT pinMode 9 OUTPUT pinMode 10 OUTPUT pinMode 11 OUTPUT void loop forward delay 1000 left delay 400 reverse dela...

Страница 146: ...by controlling their speed A simple way to control the speed is to pulse power to the motors This technique is called pulse width modulation On the arduino the analogWrite function performs this It generates a repeating pulse at about 250 Hz The size of each pulse is the duty cycle The higher the duty cycle the more power the motor gets Adjusting the duty cycle will adjust the motor speed ...

Страница 147: ... 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 127 is 50 duty cycle The function is written as analogWrite pin duty ...

Страница 148: ...rite function Run the code and see which direction the robot drifts Reduce the value for the opposite direction by 10 and try again Keep adjusting until the robot drives relatively straight It won t be perfect The analogWrite functions can replace the digitalWrite functions in the motion functions void setup pinMode 6 OUTPUT pinMode 9 OUTPUT pinMode 10 OUTPUT pinMode 11 OUTPUT void loop analogWrit...

Страница 149: ...he distance and the amount of turning Mark off two feet on the floor Floor tile is usually 1 foot square Write a program to move forward two feet and stop Start with a delay of 1000 ms Adjust the delay until the robot travels two feet Keep this value If necessary adjust the PWM values to keep the robot as straight as possible 2 Feet Start Stop ...

Страница 150: ...ile for your right angle Program the robot to turn right and set the delay to 400 ms and turn off Place the robot on the corner of the right angle facing the left line See how much the robot turns and adjust the delay until it turns 90 degrees Verify the value turning left and adjust if necessary Floor Tile ...

Страница 151: ...ame but the second parameter gets changed Anywhere there is a LOW replace it with 0 Anywhere there is a HIGH replace it with the number to set the speed Save the program under a new name so the original is not overwritten Example is below void forward digitalWrite 6 HIGH digitalWrite 9 LOW digitalWrite 10 HIGH digitalWrite 11 LOW void forward analogWrite 6 250 analogWrite 9 0 analogWrite 10 248 an...

Страница 152: ...e represent 2 foot grids This attempt through the course is called dead reckoning Write a program to go through a sequence of motions to reach the end of the course Adjust the delays between each motion so the rover travels to the finish line without going on off the squares Change the course and make it more complex if you want Start Finish ...

Страница 153: ...153 153 Robot Sensing This section you learn about using sensors to control the robots movements ...

Страница 154: ... The photo resistor will have a resistance ranging from 1 Mohm in darkness to 100 ohms in bright light Install the photo cell and 4 7 K resistor on the solderless bread board Make sure the photo cell and resistor are connected Connect the free end of the resistor to GND at the analog connector Connect the free end of the photo cell to 5 volts Connect the resistor and photo cell connection to pin 0...

Страница 155: ...for the location Once the ADC value is read it can be converted to a voltage value The code to the right shows the equation which can be used for all the analog ports The Serial println function that displays the volts includes a numeric argument which specifies the number of decimal places Save the program to a new file void setup Serial begin 9600 void loop int a float volts a analogRead 0 Seria...

Страница 156: ...previous page Shine the light on the photo cell at some distant and observe the ADC value The value should increase Pick a number a little lower If the value was around 600 then use 500 Adjustments may need to be made The program will have the robot turn in place when the flash light is not detected and drive straight when enough light is detected ...

Страница 157: ...urns in place This motion lets the robot scan around until it finds a strong enough light source Depending on the ambient light in the room and the brightness of the flash light you may need to adjust the number in the if statement When the program is loaded see if the robot will chase the flash light void setup pinMode 6 OUTPUT pinMode 9 OUTPUT pinMode 10 OUTPUT pinMode 11 OUTPUT Serial begin 960...

Страница 158: ...ollision 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 echo The processor needs to measure the time it takes for the echo to return This sensor has four pins Ground 5 Volt power input Trigger Echo ...

Страница 159: ...the robot The pins are inserted at the end of the rows Connect jumpers from the sensor to the processor GND to Analog GND ECHO to pin D3 TRIG to pin D5 VCC to Analog 5V Look on the processor board for the word ANALOG The power connections are done there to isolate the sensor from the motor power to reduce electrical noise ...

Страница 160: ...ed is called pulseIn This measures the time it takes a pulse to occur in microseconds Try the program to the right The results are in centimeters Create a new program and enter the code to the right Save the program and upload it void setup Serial begin 9600 pinMode 3 INPUT pinMode 5 OUTPUT void loop digitalWrite 5 LOW delayMicroseconds 2 digitalWrite 5 HIGH delayMicroseconds 10 digitalWrite 5 LOW...

Страница 161: ...his function will return a result The return command specifies which variable is sent back to the calling code long ultrasonic digitalWrite 5 LOW delayMicroseconds 2 digitalWrite 5 HIGH delayMicroseconds 10 digitalWrite 5 LOW long distance pulseIn 3 HIGH if distance 0 return 1000 distance distance 58 return distance The function pulseIn returns the number of microseconds The result is then divided...

Страница 162: ... an object The format for the if statement is shown to the right Multiple statements can be inserted between the brackets and will be executed if the condition is true To test for equals use else allows two sets of codes to be executed depending on the condition if a c execute code here if a c execute this code if a c execute this code else otherwise execute this code ...

Страница 163: ...ingle file The code is split on the next page since it wouldn t fit in a single column You will notice a delay at the end of the loop function This is needed because the ultrasonic range sensor cannot be operated too fast Incorrect results will occur if the loop runs too fast Test it and see if you need to tweak the timing for going reverse and turning Don t forget to include the movement function...

Страница 164: ...italWrite 5 LOW long distance pulseIn 3 HIGH if distance 0 return 1000 distance distance 58 return distance void setup pinMode 3 INPUT pinMode 5 OUTPUT pinMode 6 OUTPUT pinMode 9 OUTPUT pinMode 10 OUTPUT pinMode 11 OUTPUT void loop long distance forward distance ultrasonic if distance 10 reverse delay 1000 left delay 700 halt delay 50 ...

Страница 165: ...e sensor Set up some barriers out of any solid material Card board boxes poster paper or other large materials will work Use the ultrasonic range sensor to avoid crashing into the barriers and turns the right direction every time a barrier is detected Hint use the collision avoidance program and expand it so that it will complete the maze This requires the rover to back up and turn in specific dir...

Страница 166: ...166 166 Remote Control ...

Страница 167: ...o that There are two ways remotes work One way is for the remote to resend the code for the key pressed repeatedly until the key is released The second is to send the code for the key pressed then send a code that equals all 1 s The next program will be used to capture the codes to be inserted into the robot program The program decodes the key code and displays it in hexidecimal First remove the U...

Страница 168: ...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 The LED is modulated to help the receiver detect the signal from other light in the room including sun light The turning on and off of the modulated light is done in different sequences to generate different codes 26 uS Infrared Emitter 1 0 1 1 1 0 0 0 ...

Страница 169: ...nnects to an input circuit that converts the current to a voltage The signal goes through a bandpass filter This is a filter that only lets a signal of a specific frequency to pass All other signals cannot pass The filtered signal is then sent to a demodulator that converts the modulated signal to the codes being sent Input Bandpass Filter Demo dulator Signal Photo Diode ...

Страница 170: ...ections 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 The leads on the IR receiver are numbered in a specific orientation When mounting on the solderless bread board have the rounded side face forward Pin 1 OUT Pin 2 5V Pin 3 GND ...

Страница 171: ...n 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 power backwards or the the IR sensor will be damaged 1 2 3 ...

Страница 172: ...172 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 ...

Страница 173: ...nt the remote control at the IR receiver and press a button Numbers should be displayed in the serial monitor Remotes operate in one of two ways One type of remote keeps repeating the code for the button pressed as long as the button is pressed The other type will send the code once and then all logic level 1 after that The codes are generally 32 bit numbers The program displays the numbers in hex...

Страница 174: ...he Remote Codes With the program running press the button for forward and record the result Do the same for left right and reverse Forward _______________ Left _______________ Right _______________ Reverse _______________ ...

Страница 175: ...m 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 ...

Страница 176: ... right Enter the program to the right and next page Replace the underlined words with the appropriate code Since the numbers are in hexidecimal insert 0x in front of the number Make sure the move tab is included Retype it in if it is not include IRremote h unsigned long tt IRrecv irrecv 3 decode_results results void setup irrecv enableIRIn pinMode 6 OUTPUT pinMode 9 OUTPUT pinMode 10 OUTPUT pinMod...

Страница 177: ...oop if irrecv decode results if results value FORWARD forward else if results value LEFT left else if results value RIGHT right else if results value REVERSE reverse tt 0 irrecv resume tt if tt 3400 increase value if robot stutters halt tt 0 ...

Страница 178: ... 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 as expected To get better angle bend the IR receiver so the rounded side points upward This will allow you to use the remote from wider angles ...

Страница 179: ... driving up the slope Get a bunch of 4 inch tie wraps To give the wheels more grip secure tie wraps across the tires as shown Loop the tie wraps between the spokes 10 tie wraps per wheel is sufficient Try driving through the sand again and see the difference If the robot doesn t move well it may be that the motors need more power The motors are a bit weak Adding two more AA cells in series will pr...

Страница 180: ...80 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 ...

Отзывы: