Hi..! Friends..! I am trying to detect the number of steps on accelerometer. For which I want to Plot the accelerometer values in real time (with minimum rate 50values/sec) such that I can analyse the data while walking.
The ways in my mind are:-
- Plotting on keil while debugging using logic analyzer but I am not able to implement
- In UART Problem is the values printing are less than 50.
please anyone tell how can I solve the problem code is i.e. want to plot the l_a[i] variable of main loop
int main()
{
uint32_t err_code;
bool erase_bonds;
int i=0;
long count=0;
uint8_t id;
float l_xo,l_a[17];
float s;
float put_1,put_2,put_3,put_4,put_5,put_6,put_7,put_8,put_9,put_10,put_11,put_12,put_13,put_14,put_15,sum_5;
int fre_count=1;
// Initialize
timers_init();
buttons_leds_init(&erase_bonds);
const app_uart_comm_params_t comm_params =
{
RX_PIN_NUMBER,
TX_PIN_NUMBER,
RTS_PIN_NUMBER,
CTS_PIN_NUMBER,
APP_UART_FLOW_CONTROL_DISABLED,
false,
UART_BAUDRATE_BAUDRATE_Baud9600
};
APP_UART_FIFO_INIT(&comm_params,
UART_RX_BUF_SIZE,
UART_TX_BUF_SIZE,
uart_error_handle,
APP_IRQ_PRIORITY_LOW,
err_code);
APP_ERROR_CHECK(err_code);
twi_master_init();
ble_stack_init();
device_manager_init(erase_bonds);
// gap_params_init();
// advertising_init();
conn_params_init();
mpu6050_init(0x68);
/*if(mpu6050_init(0x68) == false)
{
printf("mpu6050 init fail\r\n");
}*/
mpu6050_register_read(0x75U, &id, 1);
// Start execution.
// err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
// APP_ERROR_CHECK(err_code);
// Enter main loop.
for (;;)
{
/* power_manage();
advertising_init(); // To Update advertising Packets
MPU6050_ReadAcc( &tem1[0], &tem1[1] , &tem1[2] );
//MPU6050_ReadGyro(&tem2[0] , &tem2[1] , &tem2[2] );
now=tem1[0]/10000;
nrf_delay_ms(1000);
if(flag2==1)// enters in this if timeout occurs or advertisement stops
{
if(flag==0)
{
prev=now;
flag=1;
}
if(now!=prev)
{
err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code);
flag2=0; // stating that advertisement starts
}
prev=now;
} */
MPU6050_ReadAcc( &tem1[0], &tem1[1], &tem1[2] );
s = tem1[0]*tem1[0]+tem1[1]*tem1[1]+tem1[2]*tem1[2];
if (fre_count==1)
put_1=s;
if (fre_count==2)
put_2=s;
if (fre_count==3)
put_3=s;
if (fre_count==4)
put_4=s;
if (fre_count==5)
put_5=s;
if (fre_count==6)
put_6=s;
if (fre_count==7)
put_7=s;
if (fre_count==8)
put_8=s;
if (fre_count==9)
put_9=s;
if (fre_count==10)
put_10=s;
if (fre_count==11)
put_11=s;
if (fre_count==12)
put_12=s;
if (fre_count==13)
put_13=s;
if (fre_count==14)
put_14=s;
if (fre_count>=15)
put_15=s;
if (fre_count>=15)
{
fre_count=16;
sum_5 = ( put_1+put_2+put_3+put_4+put_5+put_6+put_7+put_8+put_9+put_10+put_11+put_12+put_13+put_14+put_15 )/15;
l_a[i] = sum_5;
put_1 = put_2;
put_2 = put_3;
put_3 = put_4;
put_4 = put_5;
put_5 = put_6;
put_6 = put_7;
put_7 = put_8;
put_8 = put_9;
put_9 = put_10;
put_10 = put_11;
put_11 = put_12;
put_12 = put_13;
put_13 = put_14;
put_14 = put_15;
printf("%f, %d, %d\n",l_a[i],i,count);
if(i==15)
{
i=0;
}
}
fre_count++;
i++;
count++;
}
}