This post replace my previous one.
I'm a univerisity student in China. And currently I'm doning a project on gunshot detection with wireless sensor networks. We are using MICAz and MTS300 as the devices. I met with a problem. The sampling rate  we need is about 6k-8kHz. But the sampling rate of TimerM.nc is to limited and we have to deploy MicroTimer.nc. I'v already change the code of MicroTimer.nc so it's suitable for use in MICAz. I've integrated it into the application like XSensorMTS300 to replace the previous Timer. The yellow led does not act as what the codes act. And I set the maximun samples to 8000 and send the last sample. I rarely got the sample. Why?I add our codes to this mail.What should I do? I've attach part of our codes in this mail. Thanks!

/****************************************************************************
 * Start the component. Start the clock.
 ****************************************************************************/
  command result_t StdControl.start()
  {
      call Leds.redOn();

      call UARTControl.start();
      call RadioControl.start ();
      call MicControl.start();
      call MicroTimer.start(10); /*jerry*/

      call Leds.greenOn();

      return SUCCESS;   
  }


async event result_t MicroTimer.fired() {
      char l_state;
      atomic my_counter ++;  /*jerry*/
    //  call Leds.redToggle();
      if(my_counter > 8000)
      {
        call Leds.yellowToggle();
        post send_uart_msg();
        call MicroTimer.stop ();
       
          }
      if(my_counter == 5000)
      {
              call Leds.yellowOn();
      }

      atomic l_state = main_state;
     
      if (sending_packet)
       return SUCCESS;                //don't overrun buffers

      l_state = START;

      switch (l_state) {
      case SOUND_DONE:
          atomic main_state = START;

      case START:
          atomic main_state = BUSY;
          //call BattControl.start ();
          //call ADCBATT.getData();     //get sensor data;

        call MicControl.start();
              call MicADC.getData();

          break;

      case BUSY:
      default:
          break;
      }

      return SUCCESS;
  }

/****************************************************************************
 * MicroPhone ADC data ready
 *****************************************************************************/  
 async event result_t MicADC.dataReady(uint16_t data) {
      data = "">      msg_uart->data[MIC] = data & 0xff;
      msg_uart->data[MIC+1] = data >> 8;     

      return SUCCESS;
  }

--
Yours sincerely.

                Jerry Xu
------------------------------------------------
Department of Computer Science
         Nanjing University
    Nanjing, P.R.China, 210093
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to