Recent Changes - Search:

TEAMS Academy Wiki

THS

Explore TEAMS!
for visiting sophomores & juniors


Robotics


EnvBioTech

Bat Design

Assistive Tech

Students

Instructors

TEAMS Forum

TEAMS Calendar

TEAMS Web Site

Wiki Info

edit Robots.SideBar

Notes103108

Let's write code for this scenario...

Suppose the boss tells us to make a robot that does the following:

When the program is run the program will run for 15 seconds and do the following...
  • Initially, the robot drives in a circle.
  • If the left bumper is pressed, the robot reverses direction and beeps once.
  • If the right bumper is pressed, the robot reduces it's speed by 10% and beeps twice.
  • After 15 seconds, the robot stops.

Read between the lines...

The blue cohort filled in a few details by making a few assumptions, perhaps asked the boss a few questions (in ).

When the program is run the program will run for 15 seconds and do the following...
turn on the power LED green to indicate power is "on" and play LED on to show program is running.
  • Initially, the robot drives in a circle.
    Assume v = 200 mm/sec and r = 300 mm to start.
  • If the left bumper is pressed, the robot reverses direction and beeps once.
    Assume that reverse direction means that we go in the opposite direction around the same circle. For example, if the robot was traveling clockwise, a left bump would change to counterclockwise (see diagram below). If left bump hit again, the robot would go back to clockwise. In C, we could define a variable for velocity (v) and use: v = -v; to assign (change) the value of v on the "memory shelf" to the opposite value.
  • If the right bumper is pressed, the robot reduces it's speed by 10% and beeps twice.
    Assume that each time bumper is pressed, reduce speed by 10%, e.g. 200 -> 180 -> 162 -> 145.8 ... etc. This is an example of exponential decay. In C, we could use: v = 9 * v / 10 to assign 9/10 of the the current v value and store/write that value into memory on the "v memory shelf"
  • After 15 seconds, the robot stops.
    turn on the power LED RED to indicate power is still "on" but program finished and play LED off to show program is running. Also, "beep error" just to catch their attention!

Flowchart

Here's the flowchart developed in class...

C Program (in main.c)

We got off to a good start, but didn't quite finish the program. We need to add some comments to the top and after each variable or constant we declared to let the reader know what they are for.

Mr. Rhine did state that there was a significant logic error in the code that we developed so far, but nobody discover the problem you.

Here is a copy of the main.c file for you to download and finish/fix:

Right click and save as "main.c" in a new program folder!!

Homework Due Next Class:

Your task for next class is to finish writing the code, compile, correct compiling errors, then download and rerun the program to see if it works. If it doesn't, see if you can troubleshoot and figure out the logical errors in the code and correct them!

Edit - History - Print - Recent Changes - Search
Page last modified on November 03, 2008, at 08:15 AM