Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 101BOE-BOT Lecture #2 EGR 120 – Introduction to EngineeringServos and the BOE-BOTReference: For more complete documentation, the following items are available from www.parallax.com or www.tcc.edu/faculty/webpages/PGordy • Robotics with the BOEBOT Version 2.2• BASIC Stamp Syntax and Reference Manual Version 2.12ServoA servo is a single device that contains:•Motor•Gearbox that gears down the motor to provide slower speeds (than most motors) and higher torque (power to turn).•Built-in electronics such that the motor position or speed can be controlled by a series of pulses. The servo is powered using 5V (4.8 – 6.0 V)BOE-BOT Lecture #2 EGR 120 – Introduction to Engineering3Types of servosThere are two types of servos:•Unmodified servos – the servo can turn over a certain range, such as 180º–This type of servo is commonly used on RC (radio control) cars and airplanes for steering, moving control flaps, etc.–Most servos are of this type–Available in hobby stores, such as Hobbytown USA or Hungates–The servo position is controlled by varying the pulse width of a control signal (see below)•Modified servos–This type of servo has been modified internally so that it will turn continuously.–This type of servo is useful as a drive motor for a robot, such as the BOE-BOT.–The servo speed is controlled by varying the pulse width of a control signal (see below)0 degrees90 degrees180 degrees0º90º180ºFull speed CWStopFull speed CCWCW Stop CCWPass around servos of each type in classBOE-BOT Lecture #2 EGR 120 – Introduction to Engineering4Controlling servos with the BASIC StampAs just seen, servos are controlled by varying the pulse width of a control signal.This is easily done using the PULSOUT command. Recall that this command was also used to turn ON and OFF an LED with the BOE-BOT in an earlier lab. The form of the PULSOUT command is shown below:PULSOUT Command PULSOUT Pin Duration - this command is used to set the specified Pin HIGH for a time equal to Duration multiplied by 2 us.Example:PULSOUT 6, 500 - set P5 HIGH for 1000 us = 1 msIf the example command above was used in the program shown below, it would produce the waveform shown.DO PULSOUT 6, 500 ‘Set P6 HIGH for 1 ms PAUSE 20 ‘Pause for 20 msLOOP ‘ Loop continuously1 ms 1 msP620 msBOE-BOT Lecture #2 EGR 120 – Introduction to Engineering5Additional PBASIC Commands Variables are defined in PBASIC as follows.VAR CommandName VAR Size where size can be BIT, NIB, BYTE, or WORDwhere BIT uses 1 binary digit (bit) to store the value (so the max value is 1) NIB uses 4 bits to store the value (so the max value is 11112 = 1510) BYTE uses 8 bits to store the value (so the max value is 111111112 = 25510) WORD uses 16 bits to store the value (so the max value is 11111111111111112 = 6553510)Examples:X VAR BYTEX = 37Mouse VAR BIT ‘Value can be 0 or 1Cat VAR NIB ‘Value can be 0 to 15Dog VAR BYTE ‘Value can be 0 to 255Rhino VAR WORD ‘Value can be 0 to 65535Mouse = 1Cat = 8Dog = 48Rhino = 12345BOE-BOT Lecture #2 EGR 120 – Introduction to Engineering6Additional PBASIC Commands Loops can be created in PBASIC in several manners. If a set of instructions are to be performed a specific number of times, the FOR … NEXT loop is convenient.FOR … NEXT Loop CommandCount VAR Word ‘Use any variable name to serve as a loop counterFOR Count = InitialValue TO FinalValue STEP Increment List of instructionsNEXTExample: (What does this program do?)N VAR BYTEFOR N = 0 TO 50 STEP 2 DEBUG CR,”HELL0”NEXTBOE-BOT Lecture #2 EGR 120 – Introduction to Engineering7Example: (What does this program do if an LED is connected to P12?)Number VAR WordFOR Number = 0 TO 10 ‘The increment equals 1 if STEP is omitted HIGH 12 PAUSE 1000 LOW 12 PAUSE 1000NEXTWhat is the difference between the two programs shown below?DO PULSOUT 6, 500 PAUSE 20LOOPM VAR WordFOR M = 1 TO 100 PULSOUT 6, 500 PAUSE 20NEXTEstimate how long the second program will run (recall that the BASIC Stamp 2 executes about 4000 instructions/second so each instruction takes about 0.25 ms, not including any delays specified by the instruction).BOE-BOT Lecture #2 EGR 120 – Introduction to Engineering8Servos typically operate by receiving control signals where the pulse width varies from about 1.3us to about 1.7ms. So the signals shown below and the corresponding programs can be used to control a servo.1.3 ms 1.3 msP620 msDO PULSOUT 6, 650 ‘Set P6 HIGH for 1.3 ms PAUSE 20 ‘Pause for 20 msLOOP ‘ Loop continuouslyFull speed CW1.5 ms 1.5 msP620 msDO PULSOUT 6, 750 ‘Set P6 HIGH for 1.5 ms PAUSE 20 ‘Pause for 20 msLOOP ‘ Loop continuouslyStop1.7 ms 1.7 msP620 msDO PULSOUT 6, 850 ‘Set P6 HIGH for 1.7 ms PAUSE 20 ‘Pause for 20 msLOOP ‘ Loop continuouslyFull speed CCWBOE-BOT Lecture #2 EGR 120 – Introduction to Engineering9PULSOUT Duration Servo speed and direction650 40 rpm CW660 40 rpm CW670 39 rpm CW680 37 rpm CW690 34 rpm CW700 30 rpm CW710 25 rpm CW720 19 rpm CW730 12 rpm CW740 3 rpm CW750 0 rpm (Stop)760 3 rpm CCW770 11 rpm CCW780 18 rpm CCW790 27 rpm CCW800 31 rpm CCW810 35 rpm CCW820 39 rpm CCW830 42 rpm CCW840 42 rpm CCW850 43 rpm CCWExample: Right-wheel servo testEach servo is a little different from the next, so in Team Assignment #3, each group will test their two servos by varying the pulse width gradually in order to determine the servos speed and direction for each value of Duration used with the PULSOUT Pin Duration command.Sample Test Program (servo connected to P13)FOR N = 1 T0 1000 PULSOUT 13, 650 PAUSE 20NEXTVary the Duration from 650 to 850 and count the wheel revolutionsPick a number large enough so that you will have time to count the wheel revolutions.BOE-BOT Lecture #2 EGR 120 – Introduction to Engineering10Team Assignment #3In Team Assignment #3 you will record the number of RPM’s for each PULSOUT comment for each servo. You will also graph the information (similar to the graphs shown below). Your data will be used in later labs to determine which PULSOUT commands are needed to make your BOEBOT move around a track.BOE-BOT Lecture #2 EGR 120 – Introduction to


View Full Document
Download Servos and the BOE BOT
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Servos and the BOE BOT and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Servos and the BOE BOT 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?