With the ATMega ADC drivers, you can't really go above 17kHz sampling
rate (prescaler value = 5) because of the interrupt handling overhead.
However, if your application allows for disabling all interrupts while
sampling, then you can go above 17kHz.
Please note that disabling the interrupts for a longer period of time
will seize TinyOS: you won't be receiving timer events, radio/serial
messages, etc. Some hardware drivers may end up in invalid states
after the interrupts are re-enabled. That is, you really need to know
what you're doing (i.e. being familiar with the ATMega128 datasheet
and the corresponding TinyOS HPL/HAL code).
If you really want to do high frequency sampling, this is how to do it:
atomic {
// we assume here that ADC is enabled and is in free running mode
// speed up ADC
// 5 -> 17khz
// 4 -> 35khz
// 3 -> 70khz
call HplAtm128Adc.setPrescaler(fastAdcPrescaler );
// loop sampleCount times
while(sampleCount-- > 0) {
register uint16_t sample;
// wait for ADC reading to complete
call HplAtm128Adc.resetInterrupt();
while(call HplAtm128Adc.isComplete());
// read sample
sample = call HplAtm128Adc.getValue();
// here you can do whatever you want to do with the sample
// just make sure that you don't spend here more time than
inter-sample time
// e.g. you can send it out over the UART configured at
921600 baud (assuming you have a MIB520)
}
}
// restore ADC prescaler
Also, please note that this is beyond TinyOS territories (since TinyOS
is effectively disabled), so it is unlikely that you will receive any
help on this from anyone on this mailing list.
Janos
On Mon, Mar 30, 2009 at 10:51 AM, Michael Schippling <[email protected]> wrote:
> I'd think detecting gunshots using a mote would depend
> on how good a shot you are unless it's really close range...
>
> But you probably want to do audio sampling, right?
> I'm afraid I pontificate on that subject because I know
> about it in general, rather than having done it with motes,
> so I can't help more than to recommend that you look at the
> High Frequency Sampling app example. The standard Timer
> component has a low end of 1-3ms depending on your TOS version
> so it's of no use for this. I think there are faster timers
> available, like the JiffyTimer, or you can experiment with
> free-running the ADC using an appropriate clock pre-scale value.
> I suspect there are sample timing jitter problems with all
> the possible techniques so you probably won't get good audio
> but should be able to get enough to detect a short-sharp-sound.
>
> MS
>
> Akankshu Dhawan wrote:
>> Dear Michael
>> I am currently working as a research assistant at University of
>> Massachusetts, Dartmouth. I am working on a project for detecting
>> gunshots using wireless sensor networks . I came across this post from you :
>> https://www.millennium.berkeley.edu/pipermail/tinyos-help/2006-January/014335.html
>> I am having trouble with monitoring and controlling the sampling rate
>> and the timer component of the microphone onboard the MTS310 sensorboard
>> and would be grateful to you if you could guide me with my research. I
>> am using crossbow's moteworks platform for my research.
>>
>> I am attaching my resume for your reference.
>>
>> Looking forward to hearing from you
>>
>>
>>
>> --
>> Regards
>> Akankshu Dhawan
>> Research Assistant,
>> Computer and Information Science Department
>> University of Massachusetts,
>> 285 Old Westport Road, North Dartmouth
>> MA 02747
>>
>
> --
> Platform: WinXP/Cygwin
> TinyOS version: 1.x, Boomerang
> Programmer: MIB510
> Device(s): Mica2, MicaZ, Tmote
> Sensor board: homebrew
>
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help