Chapter 5 Assessment

Questions

1) What kind of electrical connection is a whisker?

– The tactile switch; the single-pole, single-throw switch.

2) When a whisker is pressed, what voltage occurs at the I/O pin monitoring it? What binary value will occur in the input register? If I/O pin P8 is used to monitor the input pin, what value does IN8 have when a whisker is pressed, and what value does it have when a whisker is not pressed?

– When a whisker is pressed, the I/O line sees 0 (zero) voltage. The binary value will be 0 (zero). IN8 will have 0 (zero) voltage if a whisker is pressed and will have 1 voltage if a whisker is not pressed.

3) If IN7 = 1, what does that mean? What does it mean if IN7 = 0? How about IN5 = 1 and IN5 = 0?

– IN7 = 1 means the whisker is not pressed.

   IN7 = 0 means the whisker is pressed.

   IN5 = 1 means the whisker is not pressed.

   IN5 = 0 means the whisker is pressed.

4) What command is used to jump to different subroutines depending on the value of a variable? What command is used to decide which subroutine to jump to? What are these decisions based on?

-The GOSUB is used  to jump to different subroutines depending on the value of a variable. The IF…THEN command is used to decide which subroutine to jump to. That decision is based in conditions, which are logical statements that evaluate to true or false.

5) What is the purpose of having nested IF…THEN statements?

– They will be more fully introduced in the next activity.

Exercises

1) Write a DEBUG command for TestWhiskers.bs2 that updates each whisker state on a new line. Adjust the PAUSE command so that it is 250 instead of 50.

2) Using RoamingWithWhiskers.bs2 as a reference, write a Turn_Away subroutine that calls the Back_Up subroutine once and the Turn_Left subroutine twice. Write down the modifications you will have to make to the Main Routine section of RoamingWithWhiskers.bs2.

 

Projects

1) Modify RoamingWithWhiskers.bs2 so that the Boe-Bot makes a 4 kHz beep that lasts 100 ms before executing the evasive maneuver. Make it beep twice if both whisker contacts are detected during the same sample.

2) Modify RoamingWithWhiskers.bs2 so that Boe-Bot roams in a 1 yard (or meter) diameter circle. When you touch one whisker, it will cause the Boe-Bot to travel in a tighter circle (small diameter). When you touch the other whisker, it will cause the Boe-Bot to navigate in a wider diameter circle.

Chapter 4 Assessment

Questions:

1. What direction does the left wheel have to turn to make the Boe-Bot go forward? What does the right wheel have to turn?

– Left wheel counterclockwise, right wheel clockwise.

2. When the Boe-Bot pivots to the left, what are the right and left wheels doing? What PBASIC commands do you need to make the Boe-Bot pivot left?

– The right wheel is turning clockwise (forward), and the left wheel is not moving.

PULSOUT 13, 750

PULSOUT 12, 650

3. If your Boe-Bot veers slightly to the left when you are running a program to make it go straight ahead, how do you correct this? What command needs to be adjusted and what kind of adjustment should you make?

– Slow down the rgiht wheel to correct a veer to the left. The PULSOUT command for the right wheel needs to be adjusted.

PULSOUT 12, 650

4. If your Boe-Bot travels 11 in/s, how many pulses will it take to make it travel 36 inches?

Boe-Bot speed = 11in/s

Boe-Bot distance = 36 in/s

pulses = (Boe-Bot distance / Boe-Bot speed) * (40.65 pulses/s)

              = (36/11) * (40.65)

              = 133.04

              = 133

It should take 133 pulses to travel 36 inches.

5. What’s the relationship between a FOR…NEXT loops’s Counter argument and the Pulsout command’s Duration argument that makes ramping possible?

– The FOR…NEXT loop’s pulseCount variable can be used as an offset (plus or minus) to 750 (the center position) in the Duration argument.

FOR pulseCount = 1 to 100

     PULSOUT 13, 750 + pulseCount

     PULSOUT 12, 750  –  pulseCount

    PAUSE 20

NEXT

6. What directive can you use to pre-store values in the BASIC Stamp’s EEPROM before running a program?

– The DATA directive.

7. What command can you use to retrieve a value stored in EEPROM and copy it to a variable?

– The READ command.

8. What code block can you use to select a particular variable and evaluate it on a case by case basis and execute a different code block for each case?

SELECT…CASE…ENDSELECT.

9. What are the different conditions that can be used with DO…LOOP?

UNTIL and WHILE.

Exercises:

1. Write a routine that makes the Boe-Bot back up for 350 pulses.

FOR counter = 1 to 350                                                      ‘ Backward

     PULSOUT 13, 650

     PULSOUT 12, 850

     PAUSE 20

NEXT

2. Let’s say that you tested your servos and discovered that it takes 48 pulses to make a 180 degrees trun with right-rotate. With this information, write routines to make the Boe-Bot performs 30, 45, and 60 degrees turns.

FOR counter = 1 to 8                                                      ‘ Rotate right 30 degrees

     PULSOUT 13, 850

     PULSOUT 12, 650

     PAUSE 20

NEXT

FOR counter = 1 to 12                                                      ‘ Rotate right 45 degrees

     PULSOUT 13, 850

     PULSOUT 12, 850

     PAUSE 20

NEXT

FOR counter = 1 to 16                                                      ‘ Rotate right 60 degrees

     PULSOUT 13, 850

     PULSOUT 12, 650

     PAUSE 20

NEXT

3. Write a routine that makes the Boe-Bot go straight forward, then ramp in and out of a pivoting turn, and then continue straight forward.

FOR counter = 1 to 100                                                      ‘ Forward

     PULSOUT 13, 750 + counter

     PULSOUT 12, 750

     PAUSE 20

NEXT

FOR counter = 1 to 30                                                      ‘ Ramping pivot turn

     PULSOUT 13, 750 + counter

     PULSOUT 12, 750

     PAUSE 20

NEXT

FOR counter = 1 to 0                                                      ‘ Backward

     PULSOUT 13, 750 + counter

     PULSOUT 12, 750

     PAUSE 20

NEXT

FOR counter = 1 to 100                                                      ‘ Forward

     PULSOUT 13, 850

     PULSOUT 12, 650

     PAUSE 20

NEXT

Projects:

1. It is time to fill in column 3 of Table 2-1: PULSOUT Duration Combinations on page 81. To do this, modify the PULSOUT Duration arguments in the program BoeBotForwardThreeSeconds.bs2 using each pari of values from column 1. Record your Boe-Bot’s resultant behavior for each pair in column 3. Once completed, this table will serve as a reference guide when you design your own custom Boe-Bot maneuvers.

 Table of PULSOUT Duration Combinations

2. Figure 4-9 shows two simple obstacle courses. Write a program that will make your Boe-Bot navigate along each figure. Assume straight line distances (including the diameter of the circle) to be either 1 yd or 1m.

 Circle

Triangle

Assessment 3

Questions

1. What are some of the symptoms of brownout on the Boe-Bot?

– The symptoms of brownout on the Boe-Bot include erratic behavior such as going in unexpected directions.

2. How can a piezospeaker be used to detect brownout?

– A FREQOUT command at the beginning of all Boe-Bot programs causes the piezospeaker to play a tone. This tone will accur every time an accidental reset happens due to brownout conditions.

3. What is reset?

– A reset is when the power is interrupted.

4. What is an intialization routine?

– An intialization routine consists of the lines of code that are used at the beginning of the program. These lines of code run each time the program starts from the beginning.

5. What are three (or more) possible mistakes that can occur when disconnecting and reconnecting the servos?

– The servo lines are swapped.

– The power switch is not on position-2.

– One or both servos is plugged in backwards.

6. What command do you have to change in RightServoTest.bs2 to test the left wheel instead of the right wheel?

– The PULSOUT commands must be PULSOUT 13 instead of PULSOUT 12.

Exercises

1. Write a FREQOUT command that makes a tone that sounds different from the reset detect tone to signify the end of  a program.

– FREQOUT, 4, 2000, 3000

2. Write a FREQOUT command that makes a tone (different from beginning or ending tones) that signifies an intermediate step in a program has been completed. Try a value with a 100 ms at a 4 kHz frequency.

– FREQOUT 4, 100, 4000

Projects

1. Modify RightServoTest.bs2 so that it makes a tone signifying the test is complete.

‘ Robotics with the Boe-Bot – Ch03Prj01_TestCompleteTone.bs2
‘ Right servo turns clockwise three seconds, stops 1 second, then counterclockwise three seconds.  A tone signifies that the
‘ test is complete.

‘ {$STAMP BS2}
‘ {$PBASIC 2.5}
DEBUG “Program Running!”

counter        VAR            Word
FREQOUT 4, 2000, 3000                       ‘ Signal start of program.

FOR counter = 1 TO 122                          ‘ Clockwise just under 3 seconds.
  PULSOUT 12, 650
  PAUSE 20
NEXT

FOR counter = 1 TO 40                            ‘ Stop one second.
  PULSOUT 12, 850
  PAUSE 20
NEXT

FREQOUT 4, 500,3500                           ‘ Signal end of program

END

2. Modify TestServoSpeed.bs2 so that you can use DEBUGIN to enter the pulse width fot the left and the right servo as well as the number of pulses to deliver in the FOR…NEXT loop. Use this program to control your Boe-Bot’s motion via the Debug Terminal’s Transmit windowpane.

‘ Robotics with the Boe-Bot – Ch03Prj02_DebuginMotion.bs2
‘ Enter servo pulsewidth & duration for both wheels via Debug Terminal.

‘ {$STAMP BS2}
‘ {$PBASIC 2.5}

ltPulseWidth     VAR        Word         ‘ Left servo pulse width
rtPulseWidth    VAR        Word         ‘ Right servo pulse width
pulseCount        VAR        Byte           ‘ Number of pulses to servo
counter               VAR        Word         ‘ Loop counter

DO
  DEBUG “Enter left servo pulse width: ”    ‘ Enter values in Debug
  DEBUGIN DEC ltPulseWidth                        ‘ Terminal

  DEBUG “Enter right servo pulse width: ”
  DEBUGIN DEC rtPulseWidth

  DEBUG “Enter number of pulses:        ”
  DEBUGIN DEC pulseCount

  FOR counter = 1 TO pulseCount                ‘ Send specific number of pulses
    PULSOUT 13, ltPulseWidth                        ‘ Left servo motion
    PULSOUT 12, rtPulseWidth                       ‘ Right servo motion
    PAUSE 20
  NEXT

LOOP

Test Servo Speed Chart

PULSOUT Duration Combinations Table

Table 2-1: PULSOUT Duration Combinations
Durations   Description
P13 P12
850 650 Full Speed, P13 servo counterclockwise, P12 servo clockwise.
650 850 Full Speed, P13 servo clockwise, P12 servo counterclockwise.
850 850 Full Speed, P13 servo counterclockwise, P12 servo counterclockwise.
650 650 Full Speed, P13 servo clockwise, P12 servo clockwise.
750 850 Only P12 servo counterclockwise.
650 750 Only P13 servo counterclockwise.
750 750 Both servos should stay still because of the centering adjustments you made in Activity #4.
760 740 Slow, P12 servo clockwise. P13 servo counterclockwise.
770 730 P12 servo clockwise, P13 servo counterclockwise.
850 700 Fast, P12 servo clockwise, P13 servo counterclockwise.
800 650 P12 servo clockwise, P13 servo counterclockwise.

Assignment 2: Boe-Bot ‘s Servo Motors

Questions

1) How do the Parallax Countinuous Rotation servo differ from standard sevos?

– The Parallax Countinuous Rotation servos turn a certain direction at a certain speed.

2) How long does a milisecond last? How do you abbreviate it?

– A milisecond lasts one thousandsth of a second. Milisecond is abbreviated “ms”.

3) What PBASIC commands can you use to make other PBASIC commands execute over and over again?

– The DO…LOOP command is used to make other PBASIC commands execute over and over.

4) What command causes the BASIC Stamp to internally connect one of its I/O pins to Vdd? WHat command makes the same kind of connection, but to Vss?

– HIGH to connect I/O to Vdd and LOW to connect I/O to Vss

5) What are the names of the different size variables that can be declared in a PBASIC program?

– Bit (stores 0 to 1), Nib (stores 0 to 15), Byte (stores 0 to 255) and Word (stores 0 to 65535 or -32768 to +32767)

6) What is the key to controlling a Parallax Countinuous Rotation servo’s speed and direction? How does this relate to timing diagrams? How does it relate to PBASIC commands? What are the command and argument that you can adjust to control a countinuous rotation servo’s speed and direction?

– Pulse width controls servo speed and direction. The pulse width is the high time as seen on a timing diagram. The pulse can be generated with the PULSOUT command in PBASIC. The PULSOUT command’s Duration argument adjusts the speed and direction.

Exercises

1) Write a PAUSE command that makes the BASIC Stamp do nothing for 10 seconds.

– PAUSE 10000

2) Modify this FOR…NEXT loop so that it counts from 6 to 24 in steps of 3. Also, write the variable declaration you will need to make this program work.

FOR counter = 9 TO 21

        DEBUG ? counter

        PAUSE 500

NEXT

– The variable declaration is to choose a variablesize large enough to hold the value 24. Since the maximum value a Nib can store is 15, a Nib will not work. Choose a Byte variable.

counter VAR Byte

FOR counter = 6 to 24 STEP 3

       DEBUG ? counter

       PAUSE 500

NEXT

~~

Project 1

Write a program that causes the LED connected to P14 to light dimly (on/off with every pulse) while the P12 servo is turning.

‘ Robotics with the Boe-Bot – Ch02Prj01_DimlyLitLed.bs2

‘ Run servo and send same signal to the LED on P14,

‘ to make it light dimly.

‘ {$STAMP BS2}

‘ {$PBASIC 2.5}

DEBUG “Program Running!”

DO

  PULSOUT 12, 650                     ‘P12 servo clockwise

  PULSOUT 14, 650                     ‘P14 LED lights dimly

  PAUSE 20

LOOP

~~

Project 2

Write a program that takes the servo through three seconds of each of the four different combinations of rotation.

‘ Robotis with the Boe-Bot – Ch02Prj02_4RotationCombinations.bs2

‘ Move servos through 4 clockwise/counterclockwise rotation ‘

combinations.

‘ {$STAMP BS2}

‘ {$PBASIC 2.5}

DEBUG “Program Running!”

counter       VAR     Word

FOR counter = 1 TO 120                             ‘ Loop for three seconds

  PULSOUT 13, 850                                  ‘ P13 sevo counterclockwise

  PULSOUT 12, 850                                  ‘ P12 servo counterclockwise

  PAUSE 20

NEXT

FOR counter = 1 TO 124                             ‘ Loop for three seconds

  PULSOUT 13, 650                                  ‘ P13 servo clockwise

  PULSOUT 12, 650                                  ‘ P12 servo clockwise

  PAUSE 20

NEXT

FOR counter = 1 TO 122                             ‘ Loop for three seconds

  PULSOUT 13, 650                                  ‘ P13 servo clockwise

  PULSOUT 12, 850                                  ‘ P12 servo counterclockwise

  PAUSE 20

NEXT

FOR counter = 1 TO 122                             ‘ Loop for three seconds

  PULSOUT 13, 850                                  ‘ P13 servo counterclockwise

  PULSOUT 12, 650                                  ‘ P12 srevo clockwise

  PAUSE 20

NEXT

END

Boe-Bot First Assessment

Questions

1. What device will be the brain of your Boe-Bot?

– The device that will be the brain of the Boe-Bot is the BASIC Stamps.

2. When the BASIC Stamp sends a character to your PC/laptop, what type of numbers are used to send the message through the serial cable?

 

– When the BASIC Stamps sends a chracter to the PC/laptop, binary numbers are used to send the message through the serial cable.

3. What is the name of the window that displays messages sent from the BASIC Stamp to your PC/laptop?

– The name of the window that displays messages sent from the BASIC Stamps to the PC/laptop called the DEBUG Terminal window.

4. What PBASIC commands did you learn in this chapter?

– The PBASIC commads that we learnt in this chapter is DEBUG and END.

Exercises

1. Explain what you can do with each PBASIC command you learned in this chapter.

– With each PBASIC command that we learnt in this chapter is we used the DEBUG Terminal to send a message from PC/laptop to the BASIC Stamps and the END used to terminate a PBASIC program and put it to an end.

2. Explain what the asterisk does in this command: DEBUG DEC 7 * 11

– The asterisk does in multiples DEC7 times 11.

3. There is a problem with these two commands. When you run the code, the numbers they display are stuck together so that it looks like one large numberdisplay are stuck together so that it looks like one large number instead of two small ones. Modify these two commands so that the answers appear on different lines in the Debug Terminal.

DEBUG DEC 7 * 11

DEBUG DEC 7 + 11

– Add a carriage returns.

My Boe-Bot First Journey!

I learned something new in Technology class. It was Boe-Bot. It was my first time I had something like that. At first I thought it will be so difficult to do it, but after we started on it, I become more excited! 😀 The Boe-Bot is so smart and amazing! I never thought that it can solve math problems. At the beginning of the class, Mrs. Thompson taught how to put the small parts together. After we did that, Mrs. Thompson want to show how smart the robotics was, so she gave some math problems and it’s true that the robotics is really smart! Now I can’t wait for the next lesson.

Hello world!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!