The following instructions are specific to the Mica2/MicaZ family with the MTS310 sensor board. The same basic instruction apply when you are using other motes and sensor boards, but doing so may require modifying some of the source code.
By default, Agilla does not have the MTS310 sensor board enabled. To enable it, open $AGILLA/nesc/agilla/Makefile.Agilla and change the value of ENABLE_MTS310 to be one. This will wire in $AGILLA/nesc/agilla/opcodes/OPsenseMTS310CAC.nc, which accesses the MTS310 sensor board. After changing MakefileAgilla, recompile and reinstall Agilla onto the mote that is attached to the programming board. See step 4 of Lesson 1 for instructions on how to install Agilla onto a mote.
Sensor readings are obtained using instruction sense. This is a blocking instruction that takes a value as a parameter that determines which type of sensor to query. The types of sensors are:
Consider the agent found in $AGILLA/agents/oscope/oscope_1reading.ma:
// This agent takes an x-axis acceleration reading, // packages it in a tuple, and sends it to the PC. // Each tuple only contains one sensor reading and // contains a sequence number. // // It only works on Mica2 and MicaZ motes with the // MTS310 sensor board. // // It must be injected on the mote that is attached // to the programming board. // // Author: Chien-Liang Fok pushc 0 setvar 0 // set heap[0] = 0 (init seq. no.) BEGIN pushc 26 putled // toggle green LED getvar 0 copy inc setvar 0 // increment counter pushc accelx sense // sense x axis of accelerometer pushc 2 pushcl uart rout // send tuple [reading, seq. no.] to the PC pushc 1 sleep // sleep for 1/8 of a second rjump BEGIN
This agent sits in a loop reading the x-axis of the accelerometer and sending it to the PC. It sleeps 1/8 of a second during each loop.
Launch the AgentInjector and open $AGILLA/agents/oscope/oscope_1reading.ma. Click on the "Clients" tab and select "oscilloscope" as shown below:
The following oscillosope GUI should appear:
This client repeatedly perform an "in" on the base station's tuple space searching for tuples containing sensor data readings.
Inject $AGILLA/agents/oscope/oscope_1reading.ma onto the mote directly attached to the programming board. Observe the green LED blink. Each time the green LED blinks, a new sensor reading is taken and sent to the PC. On the PC, the oscilloscope GUI should display the measurements. You may have to zoom in or out the axis to view the data. Here is an example of what you should see:
You have now successfully taken sensor readings and viewed them on the PC.
So far, you have obtained sensor data from a mote that is directly attached to a base station. How do you take sensor readings from nodes that are not directly attached to the base station? Suppose mote 1 is remote and mote 0 is attached to the base station. Here's basically how the application will work:
An agent on mote 1 will take the sensor readings and send them to an agent on mote 0. The agent on mote 0 will take this sensor reading and forward it to the PC.
The code for the agent on mote 1 is located in $AGILLA/agents/oscope/oscope_1reading_remote.ma and is shown below:
// This agent takes an x-axis acceleration reading, // packages it in a tuple, and sends it to mote 0. // Each tuple only contains one sensor reading and // contains a sequence number. // // It only works on Mica2 and MicaZ motes with the // MTS310 sensor board. // // It must be injected on the mote that is attached // to the programming board. It will automatically // migrate onto mote 1. // // Mote 0 must be attached to the programming board, // mote 1 must be one hop away from mote 0. // // Author: Chien-Liang Fok pushc 1 smove // move onto mote 1 pushc 0 setvar 0 // set heap[0] = 0 (init seq. no.) BEGIN pushc 26 putled // toggle green LED getvar 0 copy inc setvar 0 // increment counter pushc accelx sense // sense x axis of accelerometer pushc 2 pushcl 0 rout // send tuple [reading, seq. no.] to mote 0 pushc 1 sleep // sleep for 1/8 of a second rjump BEGIN
Notice how this agent immediately migrates onto mote 1, but sends sensor readings to mote 0.
The agent that resides on mote 0 is located in $AGILLA/agents/oscope/oscope_forwarder.ma and is shown below:
// This agent takes tuples containing sensor data and // forwards them to the PC. It toggles the green LED // each time it forwards a sensor reading. // // Author: Chien-Liang Fok BEGIN pusht VALUE pushrt ACCELX pushc 2 in // read in tuples containing sensor readings pushcl uart rout // send tuple [reading, seq. no.] to the PC pushc 26 putled // toggle green LED rjump BEGINInject $AGILLA/agents/oscope/oscope_forwarder.ma onto mote 0, which is attached to the programming board. Then inject $AGILLA/agents/oscope/oscope_1reading_remote.ma onto mote 0. It will migrate onto mote 1 and immediately taking and sending accleration readings. At the same time, oscope_forwarder will be working on mote 1 blinking its green LED. The actual sensor readings is viewable on the oscilloscope GUI.
Last Updated on April 8, 2008 9:15 PM .