1 / 6

PROMGRAMING YOUR ROBOT

PROMGRAMING YOUR ROBOT. Controlling Distance. Loops. Infinite loops Doesn’t know when to stop Can’t get out of the loop Finite loops Defined start and stop time For… next commands to specify the number of times to execute the loop. Example Code. ‘ ------Declarations -----

monita
Download Presentation

PROMGRAMING YOUR ROBOT

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PROMGRAMING YOUR ROBOT Controlling Distance 1

  2. Loops • Infinite loops • Doesn’t know when to stop • Can’t get out of the loop • Finite loops • Defined start and stop time • For… next commands to specify the number of times to execute the loop

  3. Example Code ‘ ------Declarations ----- pulse_count var word ‘Declare a variable for counting LOW 12 ‘reset ports LOW 13 ' ---- Main routine ----- main: forward: ' Forward routine FOR pulse_count = 1 TO 100 ' Loop that sends 100 forward-move pulses PULSOUT 12, 500 '1.0 ms pulse to right servo PULSOUT 13, 1000 '2.0 ms pulse to left servo PAUSE 20 pause for 20 millisecond (20 ms) NEXT STOP‘stop until the reset button is pressed

  4. Variable Declaration

  5. Now Your Turn • Make the robot go backwards and then stop • Make the robot go forward, pause, and then backwards, and stop

  6. Left and right wheels Pause Distance Calculation • Circumference of the Boe-Bot wheel: • π* wheel diameter = 3.14159 * 6.67 cm » 21 cm. • We need 21cm for one complete turn • At full speed, the servos turn at 37.5rpm or 0.625 rev/sec • 21 cm/revolution * 0.625 revolutions/sec = 13.125 cm/s. • The time it takes to make the Boe-Bot travel 50 cm is ; • ttravel = 50 cm/13.125 cm/s » 3.81 seconds • Since the pulse and pause periods are known, the time it takes for a single loop can be calculated: • tloop = 1.0 ms + 2.0 ms + 20 ms = 23 ms

More Related