blah

Dependencies:   mbed

Fork of adxl335_mbed_serial by Sumit Pandey

Revision:
2:0715aaf81851
Parent:
1:c4129110f970
Child:
3:b5f6dccb2c08
--- a/main.cpp	Thu Dec 12 15:23:29 2013 +0000
+++ b/main.cpp	Thu Dec 12 15:48:50 2013 +0000
@@ -1,7 +1,6 @@
 #include "mbed.h"
 
 int debug = 1;
-
 Serial pc(USBTX, USBRX); // tx, rx
 
 AnalogIn spare(p20); // spare pin for extra sensors if needed
@@ -12,10 +11,6 @@
 DigitalOut redundant_1(p15); // pull adjacent pins low to reduce noise
 DigitalOut redundant_2(p16); 
 Ticker ticker;
-Ticker time_interrupt;
-float time_interrupt_interval = 2; // time in seconds between output of rpm
-CAN can(p30, p29); // rx tx
-int can_id = 1337;
 
 int no_of_spokes = 5; // 5 readings per rev
 int count_delay_time = 10; // minimum interval between spikes in ms
@@ -24,7 +19,14 @@
 InterruptIn back_left(p7);
 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
 
+CAN can(p30, p29); // rx tx
+int can_id_acc_xy = 0x100;
+int can_id_acc_z = 0x101;
+int can_id_rpm_front = 0x102;
+int can_id_rpm_back = 0x103;
 typedef union {
     char can_string[8];
     float fl_data[2];
@@ -84,8 +86,8 @@
         can_msg_1.fl_data[1] = rpm_fr;
         can_msg_2.fl_data[0] = rpm_bl;
         can_msg_2.fl_data[1] = 0;
-        can.write( CANMessage(can_id, can_msg_1.can_string, 8) );
-        can.write( CANMessage(can_id, can_msg_2.can_string, 8) );
+        can.write( CANMessage(can_id_rpm_front, can_msg_1.can_string, 8) );
+        can.write( CANMessage(can_id_rpm_back, can_msg_2.can_string, 8) );
     }
 }
 
@@ -108,8 +110,8 @@
         can_msg_1.fl_data[1] = y;
         can_msg_2.fl_data[0] = z;
         can_msg_2.fl_data[1] = 0;
-        can.write( CANMessage(can_id, can_msg_1.can_string, 8) );
-        can.write( CANMessage(can_id, can_msg_2.can_string, 8) );
+        can.write( CANMessage(can_id_acc_xy, can_msg_1.can_string, 8) );
+        can.write( CANMessage(can_id_acc_z, can_msg_2.can_string, 8) );
     }
 }