⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sensing - tinyos documentation wiki.htm

📁 从官方网站上下载tinyos2.0的学习指南
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0040)http://docs.tinyos.net/index.php/Sensing -->
<HTML lang=en dir=ltr xml:lang="en" 
xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>Sensing - TinyOS Documentation Wiki</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<META 
content="Sensing,Sensing,Boot Sequence,Getting Started with TinyOS,Mote-PC serial communication and SerialForwarder" 
name=keywords><LINK href="/favicon.ico" rel="shortcut icon"><LINK 
title="TinyOS Documentation Wiki (English)" href="/opensearch_desc.php" 
type=application/opensearchdescription+xml rel=search>
<STYLE type=text/css media="screen, projection">@import url( /skins/common/shared.css?97 );
@import url( /skins/monobook/main.css?97 );
</STYLE>
<LINK media=print 
href="Sensing - TinyOS Documentation Wiki.files/commonPrint.css" type=text/css 
rel=stylesheet><!--[if lt IE 5.5000]><style type="text/css">@import "/skins/monobook/IE50Fixes.css?97";</style><![endif]--><!--[if IE 5.5000]><style type="text/css">@import "/skins/monobook/IE55Fixes.css?97";</style><![endif]--><!--[if IE 6]>
<STYLE type=text/css>@import url( /skins/monobook/IE60Fixes.css?97 );
</STYLE>
<![endif]--><!--[if IE 7]><style type="text/css">@import "/skins/monobook/IE70Fixes.css?97";</style><![endif]--><!--[if lt IE 7]>
<SCRIPT src="Sensing - TinyOS Documentation Wiki.files/IEFixes.js" 
type=text/javascript></SCRIPT>

<META http-equiv=imagetoolbar content=no><![endif]-->
<SCRIPT type=text/javascript>/*<![CDATA[*/var skin = "monobook";var stylepath = "/skins";var wgArticlePath = "/index.php/$1";var wgScriptPath = "";var wgScript = "/index.php";var wgServer = "http://docs.tinyos.net";var wgCanonicalNamespace = "";var wgCanonicalSpecialPageName = false;var wgNamespaceNumber = 0;var wgPageName = "Sensing";var wgTitle = "Sensing";var wgAction = "view";var wgRestrictionEdit = [];var wgRestrictionMove = [];var wgArticleId = "11";var wgIsArticle = true;var wgUserName = null;var wgUserGroups = null;var wgUserLanguage = "en";var wgContentLanguage = "en";var wgBreakFrames = false;var wgCurRevisionId = "260";/*]]>*/</SCRIPT>

<SCRIPT src="Sensing - TinyOS Documentation Wiki.files/wikibits.js" 
type=text/javascript><!-- wikibits js --></SCRIPT>

<SCRIPT src="Sensing - TinyOS Documentation Wiki.files/index.php" 
type=text/javascript><!-- site js --></SCRIPT>

<STYLE type=text/css>@import url( /index.php?title=MediaWiki:Common.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000 );
@import url( /index.php?title=MediaWiki:Monobook.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000 );
@import url( /index.php?title=-&action=raw&gen=css&maxage=18000 );
</STYLE>
<!-- Head Scripts -->
<SCRIPT src="Sensing - TinyOS Documentation Wiki.files/ajax.js" 
type=text/javascript></SCRIPT>

<META content="MSHTML 6.00.2900.3268" name=GENERATOR></HEAD>
<BODY class="mediawiki ns-0 ltr page-Sensing">
<DIV id=globalWrapper>
<DIV id=column-content>
<DIV id=content><A id=top name=top></A>
<H1 class=firstHeading>Sensing</H1>
<DIV id=bodyContent>
<H3 id=siteSub>From TinyOS Documentation Wiki</H3>
<DIV id=contentSub></DIV>
<DIV id=jump-to-nav>Jump to: <A 
href="http://docs.tinyos.net/index.php/Sensing#column-one">navigation</A>, <A 
href="http://docs.tinyos.net/index.php/Sensing#searchInput">search</A></DIV><!-- start content -->
<P>This lesson introduces sensor data acquisition in TinyOS. It demonstrates two 
sensor applications: a simple application called <A title=Sensing 
href="http://docs.tinyos.net/index.php/Sensing#The_Sense_application">Sense</A> 
that periodically takes sensor readings and displays the values on the LEDs. And 
a more sophisticated application called <A title=Sensing 
href="http://docs.tinyos.net/index.php/Sensing#The_Oscilloscope_application">Oscilloscope</A> 
where nodes periodically broadcast their sensor readings to a basestation node. 
Using the Mote-PC serial communication described in the [Mote-PC serial 
communication and SerialForwarder|previous lesson] the basestation forwards the 
sensor readings to the PC, where they are visualized with a dedicated graphical 
user interface. </P>
<TABLE class=toc id=toc summary=Contents>
  <TBODY>
  <TR>
    <TD>
      <DIV id=toctitle>
      <H2>Contents</H2></DIV>
      <UL>
        <LI class=toclevel-1><A 
        href="http://docs.tinyos.net/index.php/Sensing#Introduction"><SPAN 
        class=tocnumber>1</SPAN> <SPAN class=toctext>Introduction</SPAN></A> 
        <LI class=toclevel-1><A 
        href="http://docs.tinyos.net/index.php/Sensing#The_Sense_application"><SPAN 
        class=tocnumber>2</SPAN> <SPAN class=toctext>The Sense 
        application</SPAN></A> 
        <UL>
          <LI class=toclevel-2><A 
          href="http://docs.tinyos.net/index.php/Sensing#The_DemoSensorC_component"><SPAN 
          class=tocnumber>2.1</SPAN> <SPAN class=toctext>The DemoSensorC 
          component</SPAN></A> 
          <LI class=toclevel-2><A 
          href="http://docs.tinyos.net/index.php/Sensing#Running_the_Sense_application"><SPAN 
          class=tocnumber>2.2</SPAN> <SPAN class=toctext>Running the Sense 
          application</SPAN></A> </LI></UL>
        <LI class=toclevel-1><A 
        href="http://docs.tinyos.net/index.php/Sensing#The_Oscilloscope_application"><SPAN 
        class=tocnumber>3</SPAN> <SPAN class=toctext>The Oscilloscope 
        application</SPAN></A> 
        <UL>
          <LI class=toclevel-2><A 
          href="http://docs.tinyos.net/index.php/Sensing#Running_the_Oscilloscope_application"><SPAN 
          class=tocnumber>3.1</SPAN> <SPAN class=toctext>Running the 
          Oscilloscope application</SPAN></A> 
          <LI class=toclevel-2><A 
          href="http://docs.tinyos.net/index.php/Sensing#Running_the_Java_GUI"><SPAN 
          class=tocnumber>3.2</SPAN> <SPAN class=toctext>Running the Java 
          GUI</SPAN></A> </LI></UL>
        <LI class=toclevel-1><A 
        href="http://docs.tinyos.net/index.php/Sensing#Related_Documentation"><SPAN 
        class=tocnumber>4</SPAN> <SPAN class=toctext>Related 
        Documentation</SPAN></A> </LI></UL>
      <UL></UL></TD></TR></TBODY></TABLE>
<SCRIPT type=text/javascript> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </SCRIPT>
<A name=Introduction></A>
<H1><SPAN class=mw-headline>Introduction</SPAN></H1>
<P>Sensing is an integral part of sensor network applications. In TinyOS 1.x 
sensing was syntactically connected with analog-to-digital converters (ADCs): 
TinyOS 1.x applications such as <CODE>Oscilloscope</CODE> or <CODE>Sense</CODE> 
used the <CODE>ADC</CODE> and <CODE>ADCControl</CODE> interfaces to collect 
sensor data. When new platforms appeared with sensors that were read out via the 
serial interface, not only did additional interfaces like <CODE>ADCError</CODE> 
have to be introduced, but it became clear that equating a sensor with an ADC 
was not always the appropriate thing to do. </P>
<P>Usually sensing involves two tasks: configuring a sensor (and/or the hardware 
module it is attached to, for example the ADC or SPI bus) and reading the sensor 
data. The first task is tricky, because a sensing application like, for example, 
<CODE>Sense</CODE> is meant to run on any TinyOS platform. How can 
<CODE>Sense</CODE> know the configuration details (like ADC input channel, the 
required reference voltage, etc.) of an attached sensor? It can't, because the 
configuration details of sensors will be different from platform to platform. 
Unless <CODE>Sense</CODE> knows about all sensors on all platforms it will be 
unable to perform the configuration task. However, the second task - reading the 
sensor data - can be solved so that the <CODE>Sense</CODE> application can 
collect sensor data even though it is agnostic to the platform it is running on. 
</P>
<P>In TinyOS 2.0 <I>platform independent</I> sensing applications such as 
<CODE>Oscilloscope</CODE>, <CODE>Sense</CODE> or <CODE>RadioSenseToLeds</CODE> 
do not use configuration interfaces like <CODE>ADCControl</CODE> anymore; 
instead they use the standard data acquisition interfaces <CODE>Read</CODE>, 
<CODE>ReadStream</CODE> or <CODE>ReadNow</CODE> for collecting sensor data. All 
configuration details are hidden from the application and this is why you can 
compile <CODE>Sense</CODE> and display sensor data on the <I>telosb</I> or the 
<I>micaz</I> platform, even though the actual sensors and their connection to 
the rest of the system may be completely different. </P>
<P>This raises questions like the following: </P>
<UL>
  <LI>Since the <CODE>Sense</CODE> application component only uses standard data 
  acquisition interfaces who is in charge of defining which sensor it samples? 
  <LI>If the <CODE>Sense</CODE> application component is not configuring the 
  sensor, then who is responsible for that? 
  <LI>How can an applications like <CODE>Sense</CODE> display sensor data when 
  they do not know the details about sensor configuration? This includes 
  questions like "what is the value range of the sensor data" or "is a 
  temperature reading to be interpreted in degrees Celsius or Fahrenheit"? 
  <LI>Let's assume there are several sensors on a platform: what steps have to 
  be taken to let the <CODE>Sense</CODE> or <CODE>Oscilloscope</CODE> 
  application display data from a different sensor? </LI></UL>
<P>After reading this tutorial you should be able to answer these questions. 
Using the <CODE>Sense</CODE> and <CODE>Oscilloscope</CODE> application as an 
example, the following sections explain how the data acquisition interfaces are 
used, how the configuration procedure works and, as an example, how 
<CODE>Sense</CODE> can be hooked up to sensors other than the default one on the 
<I>telosb</I> platform. </P><A name=The_Sense_application></A>
<H1><SPAN class=mw-headline>The Sense application</SPAN></H1>
<P><CODE>Sense</CODE> is a simple sensing demo application. It periodically 
samples the default sensor and displays the bottom bits of the readings on the 
LEDs. The <CODE>Sense</CODE> application can be found in 
<CODE>tinyos-2.x/apps/Sense</CODE>. Let's first look at the <CODE><A 
class="external text" 
title=http://www.tinyos.net/tinyos-2.x/apps/Sense/SenseAppC.nc 
href="http://www.tinyos.net/tinyos-2.x/apps/Sense/SenseAppC.nc" 
rel=nofollow>SenseAppC.nc</A></CODE> configuration: </P><PRE>configuration SenseAppC
{
}
implementation {
  components SenseC, MainC, LedsC, new TimerMilliC();
  components new DemoSensorC() as Sensor;

  SenseC.Boot -&gt; MainC;
  SenseC.Leds -&gt; LedsC;
  SenseC.Timer -&gt; TimerMilliC;
  SenseC.Read -&gt; Sensor;
}
</PRE>
<P>The <CODE>SenseAppC</CODE> configuration looks similar to the 
<CODE>BlinkAppC</CODE> configuration described in <A 
title="Getting Started with TinyOS" 
href="http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS">lesson 1</A> 
(if you have not done so, read the sections on the Blink application in lesson 
1). To understand the wiring let's look at the signature of the <CODE><A 
class="external text" 
title=http://www.tinyos.net/tinyos-2.x/apps/Sense/SenseC.nc 
href="http://www.tinyos.net/tinyos-2.x/apps/Sense/SenseC.nc" 
rel=nofollow>SenseC.nc</A></CODE> module: </P><PRE>module SenseC
{
  uses {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -