Liyou Zhou
/
wheel_speed_sensor_board
blah
Fork of adxl335_mbed_serial by
Revision 3:b5f6dccb2c08, committed 2013-12-12
- Comitter:
- lz307
- Date:
- Thu Dec 12 15:54:29 2013 +0000
- Parent:
- 2:0715aaf81851
- Child:
- 4:18a440b7b1a5
- Commit message:
- naming changes
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Dec 12 15:48:50 2013 +0000 +++ b/main.cpp Thu Dec 12 15:54:29 2013 +0000 @@ -9,8 +9,9 @@ AnalogIn inputz(p17); DigitalIn selftest(p21); // self test pin for the accelerometer DigitalOut redundant_1(p15); // pull adjacent pins low to reduce noise -DigitalOut redundant_2(p16); +DigitalOut redundant_2(p16); Ticker ticker; +float acc_sampling_time = 1; // time between each sample in s int no_of_spokes = 5; // 5 readings per rev int count_delay_time = 10; // minimum interval between spikes in ms @@ -20,7 +21,7 @@ Timer t_fl, t_fr, t_bl; volatile int count_fl, count_fr, count_bl; Ticker time_interrupt; -float time_interrupt_interval = 2; // time in seconds between output of rpm +float rpm_sampling_time = 2; // time in seconds between samples CAN can(p30, p29); // rx tx int can_id_acc_xy = 0x100; @@ -70,9 +71,9 @@ void time_interrupt_call() { - float rpm_fl = (float)count_fl/(float)no_of_spokes/time_interrupt_interval; - float rpm_fr = (float)count_fr/(float)no_of_spokes/time_interrupt_interval; - float rpm_bl = (float)count_bl/(float)no_of_spokes/time_interrupt_interval; + float rpm_fl = (float)count_fl/(float)no_of_spokes/rpm_sampling_time; + float rpm_fr = (float)count_fr/(float)no_of_spokes/rpm_sampling_time; + float rpm_bl = (float)count_bl/(float)no_of_spokes/rpm_sampling_time; count_fl = 0; count_fr = 0; count_bl = 0; @@ -118,11 +119,11 @@ int main() { - redundant_1 = 0; + redundant_1 = 0; // pull unused analogue in pins low to reduce noise redundant_2 = 0; - //ticker.attach(&read_accelerometer_and_send, 1); - - time_interrupt.attach(&time_interrupt_call, time_interrupt_interval); + + ticker.attach(&read_accelerometer_and_send, acc_sampling_time); + time_interrupt.attach(&time_interrupt_call, rpm_sampling_time); t_fl.reset(); t_fl.start(); @@ -133,6 +134,7 @@ front_left.rise(&count_rev_fl); front_right.rise(&count_rev_fr); back_left.rise(&count_rev_bl); + if(debug) pc.printf("debugging\n"); while(1);