CSE466 Lab 7: “The Flock”

Objectives

The goal of this lab is to implement a TinyOS application that will implement some behavior loosely corresponding to a bird in a flock.  It will use a well-defined rule set to contribute sounds as part of a group of similar nodes. You and your lab partner will contribute two nodes (one for each partner) to this class wide project to produce a cellular automata-like system for bird songs. The combination of all the nodes will hopefully produce a sound similar to a flock of birds. In this lab you will learn the following:

Important Warnings

  1. DO NOT power the mote from the AC adapter and batteries at the same time. ALWAYS turn off the mote’s battery power before placing it in the programming board. Only one mote should be plugged into the MIB510 programmer.
  2. Be careful when placing your mica2dot into your MIB510 programmer - do not bend the pins.

Important Notes

1)      The types of motes you will be using in lab are the "mica2" and "mica2dot". Make sure to compile your program for the correct piece of hardware. (e.g. 'make mica2' NOT 'make mica') For mote programming you will be using the MIB510 serial programming board.

2)      When testing your nodes, use your lab partner number (from the lab partner assignments page - for the second group of labs) as your group number in hex. Please make sure to type in your group number as a hex number. NOTE: For the final demonstration you will ALL need to use 122 at the GroupID.

3)      The mica2 and mica2dot are built around the ATmega128 microcontroller not the ATmega16. Register names may vary slightly between the two chips.

4)      Use the default radio frequency and programming board. If you don't specify the radio frequency or programming board it will automatically choose a correct value.

5)      Make sure your MOTECOM variable is properly set when trying to communicate to the devices over serial. The mica2 communicate at 57600 baud while the mica2dots communicates at 19200.

Resources

TinyOS Tutorials
ATmega128 datasheet
avr-gcc manual
nesC 1.1 Language Reference Manual (in course pak)

Suggested Steps

 

1.      Attach the piezoelectric speaker to the mica2dot between TP15(PWM1B) and TP18(ground). You will need to solder smaller gauge wire onto the pins of the speaker as the speaker pins are too big to fit into the mica2dot directly.

2.      Download the bird song module and answer the following questions about how it works.

 

QUESTION 1: How is the frequency of a note controlled? Please point to the relevant lines of code when answering the question.

 

QUESTION 2: How is a note’s duration envelope varied? Please point to the relevant lines of code when answering the question.

 

3.      Implement the Flock Specification. Use the bird song module to generate the bird calls. NOTE: This specification may need to be updated if any ambiguities or bugs are found. Please check the online version of the specification frequently to make sure the modification date is the same. All changes to the specification will appear in red starting after the Tuesday lab section. Be careful if you print the description out early as small changes may occur to the specification until the first lab begins.

4.      Create a startled song and add it to the Sound Generation module. (Hint: the songs are stored in songData.h)

5.      Use the test fixture provided by the course staff to test your algorithm. You will need to create your own testing scripts to verify your implementation of the flock protocol. Please feel free to generate elaborate testing scenarios and to share those testing scenarios with other members of the class. The more testing completed before the final check off the better. DO NOT SHARE YOUR CODE, you may only share the testing scripts. Download Tester

6.      WRITTEN EXERCISE: Design a different algorithm for determining what song a node in the flock should sing. You and your partner will need to define a new rule set (similar to the flock specification) that each node of the flock will execute. The algorithm design should include the goals that were discussed in class. You design description should also include a discussion on why you are confident that your algorithm will work (e.g. converge and diverge) and explain how your algorithm integrates the goals of the flock project. A few of the goals mentioned in class are:

    1. The songs should be chosen randomly based off dynamic network elements.
    2. Birds should converge to singing one song then diverge from that song to another set of songs.
    3. The birds should sing all the songs eventually.
    4. All the birds must run exactly the same rule set. (i.e. the same code)
    5. The flock should be dynamically controllable by adjusting parameters.

 

Deliverables

For all files turned in, the comments at the top of the file should contain:

1)      The flock application is not designed to be robust to birds that do not follow the specification. This means that any bird that does not follow the flock specification could cause problems and prevent the flock from behaving as expected. Therefore, we need to verify that your solution is reasonably complete and correct before your bird (mote) can participate in the flock demonstration. Your bird will need to qualify by passing a series of tests preformed by the TAs. A schedule of times for qualification testing will be posted during the final week of the class.

a)      This final set of tests MUST be completed before the final demo and the results of the tests will account for the largest chunk of your project grade. You should bring a mote to the tests that you are HIGHLY confident has no errors.

b)      For every error discovered by the TAs during the qualification tests you will be allowed to fix the bug; however, you can only receive HALF the points back. NOTE: Every time the TAs perform a test and discover an error the amount of points you can receive back for fixing that error will be reduced by half. If the TAs discover the same error twice you can only get a quarter of the points back.

c)      Once your bird passes all the screening tests it is qualified to participate in the final demonstration in the atrium.

c)      Sign up for a Flock Qualification/Grading Meeting   The qualification will take place in CSE446.

2)      The flock demonstration will occur at the regular class time, 9:30am, on Friday, Dec 10 in the atrium.  Attendance is required.

3)      Turn in a hardcopy of your commented nesC code for the flock application. We will be looking for the following when grading your code:

a)      If you use an atomic statement, you MUST justify its use in your code comments. Reasonable use of atomics is encouraged. The indiscriminate use of atomic blocks will count against you! Be sure to describe in your comments why an atomic block was necessary, and why it is better than a different design. Your compile should not show any atomic or async warnings; we may check this during the grading process. If you choose to ignore the warning you will be asked to explain why you ignored it and it will be up to the TAs to determine if there was another design that you could have chosen that would have worked better and eliminated the warning. Essentially, the course staff will be grading based on whether you and your partner understood the TinyOS concurrency model and put thought into your design.

b)      Do not use the norace keyword in your application.

c)      When grading, we will be paying attention to how well you followed the TinyOS coding conventions.

4)      Email a copy of your bird’s code to cse466-tas@cs.washington.edu (make sure to include ALL relevant files in a single message).

5)      Turn in at least 3 testing scripts you used to test the flock with an explanation of why the test scripts helped to convince you that your program works correctly.

6)      Turn in the answers to the two questions about the sound module.

7)      Turn in your flock design description. Remember to prove/convince the course staff that your algorithm will work. The length of description should range from a half a page to a full page.