1

Dependencies:   mbed-dev-f303 FastPWM3

Revision:
44:efcde0af8390
Parent:
43:dfb72608639c
Child:
45:aadebe074af6
diff -r dfb72608639c -r efcde0af8390 main.cpp
--- a/main.cpp	Fri May 25 16:10:46 2018 +0000
+++ b/main.cpp	Sat Jul 14 22:03:52 2018 +0000
@@ -9,7 +9,7 @@
 #define SETUP_MODE 4
 #define ENCODER_MODE 5
 
-#define VERSION_NUM "1.5"
+#define VERSION_NUM "1.6"
 
 
 float __float_reg[64];                                                          // Floats stored in flash
@@ -41,7 +41,7 @@
 Serial pc(PA_2, PA_3);
 
 
-CAN          can(PB_8, PB_9);      // CAN Rx pin name, CAN Tx pin name
+CAN          can(PB_8, PB_9, 1000000);      // CAN Rx pin name, CAN Tx pin name
 CANMessage   rxMsg;
 CANMessage   txMsg;
 
@@ -83,12 +83,19 @@
 void enter_menu_state(void){
     printf("\n\r\n\r\n\r");
     printf(" Commands:\n\r");
+    wait_us(10);
     printf(" m - Motor Mode\n\r");
+    wait_us(10);
     printf(" c - Calibrate Encoder\n\r");
+    wait_us(10);
     printf(" s - Setup\n\r");
+    wait_us(10);
     printf(" e - Display Encoder\n\r");
+    wait_us(10);
     printf(" z - Set Zero Position\n\r");
+    wait_us(10);
     printf(" esc - Exit to Menu\n\r");
+    wait_us(10);
     state_change = 0;
     gpio.enable->write(0);
     gpio.led->write(0);
@@ -96,13 +103,21 @@
 
 void enter_setup_state(void){
     printf("\n\r\n\r Configuration Options \n\r\n\n");
+    wait_us(10);
     printf(" %-4s %-31s %-5s %-6s %-5s\n\r\n\r", "prefix", "parameter", "min", "max", "current value");
+    wait_us(10);
     printf(" %-4s %-31s %-5s %-6s %.1f\n\r", "b", "Current Bandwidth (Hz)", "100", "2000", I_BW);
+    wait_us(10);
     printf(" %-4s %-31s %-5s %-6s %-5i\n\r", "i", "CAN ID", "0", "127", CAN_ID);
+    wait_us(10);
     printf(" %-4s %-31s %-5s %-6s %-5i\n\r", "m", "CAN Master ID", "0", "127", CAN_MASTER);
+    wait_us(10);
     printf(" %-4s %-31s %-5s %-6s %.1f\n\r", "l", "Torque Limit (N-m)", "0.0", "18.0", TORQUE_LIMIT);
+    wait_us(10);
     printf(" %-4s %-31s %-5s %-6s %d\n\r", "t", "CAN Timeout (cycles)(0 = none)", "0", "100000", CAN_TIMEOUT);
+    wait_us(10);
     printf("\n\r To change a value, type 'prefix''value''ENTER'\n\r i.e. 'b1000''ENTER'\n\r\n\r");
+    wait_us(10);
     state_change = 0;
     }
     
@@ -327,7 +342,6 @@
     }
        
 int main() {
-    can.frequency(1000000);                                                     // set bit rate to 1Mbps
     controller.v_bus = V_BUS;
     controller.mode = 0;
     Init_All_HW(&gpio);                                                         // Setup PWM, ADC, GPIO
@@ -348,7 +362,6 @@
     
     NVIC_SetPriority(CAN1_RX0_IRQn, 3);
     can.filter(CAN_ID<<21, 0xFFE00004, CANStandard, 0);
-    //can.filter(CAN_ID, 0xF, CANStandard, 0);
                                                                     
     txMsg.id = CAN_MASTER;
     txMsg.len = 6;