Hi Fangming,
You don't have to wait for a readDone() to read the other, you can call both
Reads because accelconfigp has an arbiter that prevents simultaneous access.
It is also better that you call them both because that way the sensor is not
turned off between the two readings, doubling your maximum sample frequency.
That's 60Hz, not quite the 64Hz you want
For higher frequencies you have to use the AccelXStreamC component instead,
as well the ReadStream interface instead of Read. ReadStream interface is
similar to the Read interface, but you have to provide a buffer to be filled
with the readings, and then you can call the read(). You can check
ReadStream.nc for more details.
Remember that while you are stream reading one axis you're not reading the
other for the duration of how_many_samples*sample_period_in_microseconds. If
you want samples from both sensors from the same (or almost) instant in time
at more than 60Hz I think you'll have to make modifications to the
underlying components to keep the sensor on
Hugo
On 5/13/07, Fangming Zhang <[EMAIL PROTECTED]> wrote:
Hi Hugo,
Your guess is right. I read one axis, then wait readDone() to start
another axis. Your explanation let me understand what caused this problem.
However, I still cannot understand how to use accelStream. I list my old
methods as follows. Please help find how to solve the problem.
I created a DemoSensorXC and a DemoSensorYC, which look like:
generic configuration DemoSensorXC() {
provides interface Read<uint16_t>;
}
implementation {
components new AccelXC() as Sensor;
Read = Sensor;
}
In the application code, it look like:
module GetAccelC
{
uses {
interface Read<uint16_t> as ReadX;
interface Read<uint16_t> as ReadY;
...
}
}
implementation
{
//start to read X axis
event void Timer.fired() {
if (call ReadX.read() != SUCCESS)
report_problem();
}
//start to read Y axis after X is done
event void ReadX.readDone(error_t result, uint16_t data)
{
if (result != SUCCESS)
{
data = 0xffff;
report_problem();
}
local.readings[0] = data;
//start to read Y axial acceleration
if (call ReadY.read() != SUCCESS)
report_problem();
}
//send message out when Y is done
event void ReadY.readDone(error_t result, uint16_t data)
{
if (result != SUCCESS)
{
data = 0xffff;
report_problem();
}
local.readings[1] = data;
//send
if (!sendbusy && sizeof local <= call AMSend.maxPayloadLength ())
{
memcpy(call AMSend.getPayload(&sendbuf), &local, sizeof
local);
if (call AMSend.send(AM_BROADCAST_ADDR, &sendbuf, sizeof
local) == SUCCESS)
sendbusy = TRUE;
}
if (!sendbusy)
report_problem();
/* Part 2 of cheap "time sync": increment our count if we didn't
jump ahead. */
if (!suppress_count_change)
local.count++;
suppress_count_change = FALSE;
}
}
I think the key is the AccelConfigP.nc is used only once, but I still
don't know how to realize it. Is that right?
Regards,
Fangming
On 5/12/07, Hugo Sousa <[EMAIL PROTECTED] > wrote:
>
> We need more information about your application, but I'm guessing you
> are reading one axis, and when you get the readDone() you read the other
> axis, right?
>
> The accelerometer sensor has a warmup time of 17 ms (check AccelP.nc),
> that means that every time you do a Read.read() it takes 17 ms to turn
> it on and receive one reading. So the time for two readings (one X axis
> read and one Y axis read) can be 34ms and that value comes allows 30Hz
> sampling frequency,
>
> Try using the accelStream components to get that frequency sampling.
>
> Cheers
> Hugo
>
>
> On 5/12/07, Fangming Zhang < [EMAIL PROTECTED]> wrote:
>
> > Hi everyone,
> >
> > My hardwares are MIB520, MTS310, and MICAZ. The transmitting rate of
> > MIB520 is 57.4Kbps, and that of MICAZ is 250Kbps. The platform is
> > Tinyos2.0. My objective is getting sample frequency of 64Hz when I
> > only need data of accelerometer data, X and Y axis. However, it shows we can
> > only obtain about 31Hz in my test expriment. Does this limited my
> > TinyOs2.0? Or, is there any methods could improve this result?
> >
> > Regards,
> > Fangming
> >
> > _______________________________________________
> > 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