Hi.
I need to make a pedometer.
Use MSP430F5529LP, ADXL345 connection via SPI, and library http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSP430_Pedometer/latest/index_FDS.html (ti_pedometer) .
ADXL is working correctly and the data is read depending on the impact on him. But the library ti_pedometer always returns 0 steps.
This code is taken from the library ti_pedometer and modified slightly.
void adxl_loop()
{
static accel_data_t SensorData;
while(1)
{
// IF SENSOR HAS DATA, GO READ IT
if(dataReadyFlag)
{
//Read data from ADXL. Data is correct .
Accelerometer_Read(&SensorData);
sprintf(buf_usbToBcuart,"raw: x = %d, y = %d, z = %d || x = %d, y = %d, z = %d\r\n",
SensorData.x_raw, SensorData.y_raw, SensorData.z_raw, SensorData.x, SensorData.y, SensorData.z);
bcUartSend(buf_usbToBcuart, strlen(buf_usbToBcuart));
// PASS THE RESULTS TO THE ALGORITHM AND CHECK IF TIME TO PERFORM STEP DETECT
// ped_update_sample accumulate 20-30 values.
if(ped_update_sample((signed short*) SensorData.x) == 1)
{
stepCount = ped_step_detect(); // Always return 0
sprintf(buf_usbToBcuart,"stepcount = %d\r\n", stepCount);
bcUartSend(buf_usbToBcuart, strlen(buf_usbToBcuart));
if(stepCount > lastStepCount)
{
lastStepCount = stepCount;
updateReadyFlag = 1;
}
}
if(updateReadyFlag)
{
sprintf(buf_usbToBcuart,"stepcount = %d\r\n", stepCount);
bcUartSend(buf_usbToBcuart, strlen(buf_usbToBcuart));
updateReadyFlag = 0;
}
dataReadyFlag = 0;
}
}
}
What could be the problem ?