Page 1 of 1

accelerometer swith between data and event

Posted: Thu Sep 24, 2015 5:42 pm
by hugo
Hello,
I would like to read raw data from accelerometer, when an event is coming.

I wrote this function, which is a callback from the move:

void MoveDetected(uint8_t source)
{
tfp_printf("move detected\r\n");
TD_ACCELERO_MonitorEvent(false, // Monitoring enabled
TD_ACCELERO_1HZ, // Sampling rate 10 Hz
TD_ACCELERO_ALL_AXIS, // Axis mask: all axis
TD_ACCELERO_2G, // Scale 2 g
TD_ACCELERO_ALL_HIGH_IRQ, // Only monitor high IRQs, as low IRQs are always set in
// accelerometer registers
10, // Threshold in mg = 10 * 2 g / 127 = +- 160 mg (with scale 2 g)
1, // Duration in ms = 1 * (1 / 10 Hz) = 100 ms (with rate 10 Hz)
1, // High-pass filter enabled
MoveDetected);

TD_ACCELERO_MonitorData(true, // Monitoring enabled
false, // Low-power mode disabled
TD_ACCELERO_1HZ, // Sampling rate 1 Hz
TD_ACCELERO_ALL_AXIS, // Axis mask: all axis
TD_ACCELERO_2G, // Scale 2 g
0, // High-pass filter disabled
TD_ACCELERO_STREAM, // FIFO stream mode
ACCELERO_AVERAGE_SAMPLE, // Update watermark disabled (32 max, 0 is real-time)
DataCallback);
}


The problem is if the Datacallback gives great results if configured directly from the setup, it gives high pass filtered results on x an y axis only (?), when TD_ACCELERO_MonitorEvent is only called here.

I also don't know if both MonitorEvent and MonitorData ca work at the same time, and so if I must switch one off when I want to use the other one.
Thank you for your help.

Re: accelerometer swith between data and event

Posted: Fri Sep 25, 2015 12:09 pm
by hugo
I solved the problem by adding:
TD_ACCELERO_WriteRegister(0x21,0x00);
before coming back to data polling mode.
But it's an ugly solution I think.

Re: accelerometer swith between data and event

Posted: Mon Jun 20, 2016 2:18 pm
by thomas110594
hi !

I'm encountering the same problem as you. Can you be more specific concerning the way to solve it?

Thanks,

thomas