
Lol smth
Dependencies: LocalPositionSystem MMA8451Q Motor_Driver Sensors mbed
Fork of TDP_main_BartFork by
Diff: main.cpp
- Revision:
- 9:718987b106a8
- Parent:
- 7:14af656b721f
- Child:
- 10:c9212bbfeae6
--- a/main.cpp Sun Feb 22 17:55:33 2015 +0000 +++ b/main.cpp Mon Feb 23 16:49:59 2015 +0000 @@ -17,12 +17,45 @@ #include "mbed.h" #include "sensor_measure.h" #include "Motor_Driver.h" -#include "Sensors.h" +//#include "Sensors.h" #define PWM_PERIOD_US 10000 +Serial pc(USBTX, USBRX); + +Timer MeasureTimer; //Timer used for measurement + +/* For deleting +double measure1 (){ + + + + sensorTimer.reset(); + double freq,period = 0.0; + int n =0; //number of samples + int sensor_old = 0; + int sensor_new = 0;//variable to remember old sensor state + double time_us = sensorTimer.read(); + while (n < NUMBER_SAMPLES){ + sensor_new = pin_right_right.read(); + if ( sensor_new== 1 && sensor_old == 0){ // detect on rising edge ,sensor_old + n++; + } + sensor_old = sensor_new; + + } + double time_us2 = sensorTimer.read(); + // pc.printf(" delta time is %f , time 2 is %f " , (time_us2 - time_us), time_us2); + period = time_us2/((double)NUMBER_SAMPLES); // Get time + freq = (1/period); // Convert period (in us) to frequency (Hz). Works up to 100kHz. + // pc.printf(" period is %f ", period); + + return freq;//(freq < sensor.black_value*2)? 1 : 0; +} +*/ + int main() { /* @@ -40,10 +73,20 @@ motors.start(); */ - setup_counter(1000, 0); - float frequency = measure_frequency(CHANNEL_1); + // setup_counter(1000, 0); + // float frequency = measure_frequency(CHANNEL_1); sensor_initialise(); // initialise sensor values wait(1); //give time to set up the system + + sensorTimer.start(); // start timer for sensors + pc.printf("Start..."); + MeasureTimer.start(); + + while (1) { + MeasureTimer.reset(); + measure(right_right); + pc.printf("Time taken for the whole thing is %f",MeasureTimer.read()); + } }