Sorry, I have to reformat everyone's code before I can read it,
and then I often just re-write the whole thing too...
if( data > ALPHA )
{
msg_uart->data[PHOTO] = data & 0xff;
}
else
{
msg_uart->data[PHOTO] = 0 & 0xff;
}
msg_uart->data[PHOTO+1] = data >> 8;
What you are doing is setting the low byte of the [PHOTO] data to 0
when the 12bit ADCdata is less/equal to ALPHA, but you are always
setting the high byte [PHOTO+1]. If you really expect to get 2345
DECIMAL as your light value I don't know why you see "0100 or 0200
or 0300" (which I assume are HEX values) because 2345 is 0x0929...
But in any case what I think you want is to find the part of the code
that actually posts a message and inhibit it when your ADCdata light
value is less than your threshold. It looks like this happens in
MicADC.dataReady() where it calls post send_uart_msg(). You could
just add a flag in Light.dataReady() and test it in MicADC.dataReady()?
MS
salman shahi wrote:
Hi
I wanted the sensor to send me the light value it
detects only if its value is above a particular
threshold. I used XSensorMTS300 and xlisten, TOSBase.
I modified th nesC code in TestSensorM.nc
msg_uart->data[PHOTO] = data & 0xff;
msg_uart->data[PHOTO+1] = data >> 8;
to if(data>ALPHA){msg_uart->data[PHOTO] = data &
0xff;}
else{msg_uart->data[PHOTO]=0 & 0xff;}
msg_uart->data[PHOTO+1] = data >> 8;
I expect the output to be around 2345ADC which is the
normal light in the room. and when i cover it to
become 0 if my threshold is less than 2345ADC.
But I get light= 0000 or 0100 or 0200 or 0300
depending on the amount of light the sensor is exposed
to.
my guess is its doing some kind of averaging. If so
where is the code where the averaging is performed?
another guess is its related to the temp/photo Pin
being shared.
Can someone please tell me what is wrong, any help
would be highly appreciated.
Thanks in advance.
SS.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help