CSEP567 Lab 9: “Programming in TinyOS”

Objectives

The goal of this lab is to complete a program in TinyOS.

Important Warnings

  1. DO NOT power the mote from the AC adapter and batteries at the same time. ALWAYS turn off the motes 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 and sound board- do NOT bend the pins.
  3. Some other courses use software that changes your windows profile to point to a network copy of cygwin, not the local copy of cygwin. To complete these labs you will need to make sure to use the local copy of cygwin. If for some reason TinyOS is not working please inform a TA or lab staff member and we will attempt to undo the profile change. In a few extreme cases, students' profiles have had to be wiped clean by support staff.

Important Notes

Reading

Resources

TinyOS Tutorials
ATmega128 data sheet
avr-gcc manual
Application notes section for the AVR 8-bit RISC family
nesC 1.1 Language Reference Manual

Suggested Steps

In this lab you will control the tri-color led over a wireless network. The motes will act as a wireless communication conduit and you will control the color of the LED with the accelerometer on your breadboard. You will need to add the MoteConn class to SPI/USB control to send mote packets to the SerialForwarder provided in TinyOS.

Goal: Use the accelerometer, potentiometer, and button on the ATMega16 breadboard to control the TriColor LED on the SoundBoard_1 similar to the light control in Lab 6. The interaction should be the same as in Lab 6, which means the LED's color should only change when the button is pressed.

  1. Create a new folder in your apps directory for your solution to part 2. In this folder you will want to create your application files and a dimmer module (HPLTriLEDM.nc) to control the PWM. Your application should consist of a configuration file (LightNode.nc) and a module (LightNodeM.nc) that receives radio packets, parses the light value from the radio packet, and sends the light value to HPLTriLEDM.nc to output the correct brightness. You will also need to create an interface(TriColorLED.nc) to issue commands to your dimmer module. NOTE: Leave all files in your application directory as the compiler will look in the local directory first before moving on to tos/system, tos/interfaces, tos/platform, and tos/libs. This will avoid problems with files being deleted when you log off.
  2. Implement your LED dimmer module (HPLTriLEDM.nc) in TinyOS using Timer 1 of the ATmega128. Refer to the ATmega128 microcontroller datasheet and the SoundBoard_1   datasheet to determine how to control the tri-color LED. Your LightNode application should update the tri-color LED based on the last RGB value received from the radio (use AM message type #33). You should send update packets approximately every 250-500ms. NOTE: We suggest using TOSH_INTERRUPT instead of TOSH_SIGNAL to make sure your program doesn't interfere with anything important in TinyOS.
  3. Modify your SPI/USB code to use the MoteConn class to transmit the desired light level in a TinyOS radio packet with AM message type #33. The light level being sent over the radio should be controlled by your accelerometer. MoteConn is a simple class that opens up a connection to the TinyOS SerialForwarder and allows you to send packets. MoteConn needs to link to ws2_32.lib. Instructions on how to link MoteConn to ws2_32.lib in MSVC are provided in MoteConn.h. Here are the MoteConn Files

Deliverables

Turn in your code from the exercises in answers to the two questions above. All your files should contain comments that include: both partners' full name, login, the lab number (e.g. “Lab 9”), as well as important words about how your code works.

  1. Demonstrate working code to a TA and hand-in all the modified TinyOS files. (i.e. LightNode.nc, LightNodeM.nc, HPLTriLEDM.nc, TriColorLED.nc)