Ironcup Mar 2020

Dependencies:   mbed mbed-rtos MotionSensor EthernetInterface

Files at this revision

API Documentation at this revision

Comitter:
starling
Date:
Mon Sep 21 21:45:08 2020 +0000
Parent:
21:8a98c6450e00
Commit message:
01 mar 2020

Changed in this revision

Motor/Motor.cpp Show annotated file Show diff for this revision Revisions of this file
Motor/Motor.h Show annotated file Show diff for this revision Revisions of this file
SensorsLibrary/FXAS21002.cpp Show annotated file Show diff for this revision Revisions of this file
SensorsLibrary/FXAS21002.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Motor/Motor.cpp	Sat Jul 16 19:17:28 2016 +0000
+++ b/Motor/Motor.cpp	Mon Sep 21 21:45:08 2020 +0000
@@ -9,7 +9,7 @@
 #define MINIMUM_VELOCITY 15
 
 void Motor(){
-    PwmOut motor(PTD1);
+    PwmOut motor(PTC3);
     }
     
 void Motor::startJogging(float jog_dc, float jog_p){
--- a/Motor/Motor.h	Sat Jul 16 19:17:28 2016 +0000
+++ b/Motor/Motor.h	Mon Sep 21 21:45:08 2020 +0000
@@ -23,7 +23,7 @@
     void setVelocity(int new_velocity);
     float getVelocity();
     void setSmoothVelocity(int new_velocity);
-    Motor(): motor(PTD1){}
+    Motor(): motor(PTC3){}
     
 private:
      void motorJogging(void);
--- a/SensorsLibrary/FXAS21002.cpp	Sat Jul 16 19:17:28 2016 +0000
+++ b/SensorsLibrary/FXAS21002.cpp	Mon Sep 21 21:45:08 2020 +0000
@@ -55,6 +55,7 @@
 {
     float gyro_data[3];
     acquire_gyro_data_dps(gyro_data);
+    
     angle = angle + (gyro_data[2]-GYRO_OFFSET)*(period/1000000);
     if(angle > 180)
         angle = angle - 360;
--- a/SensorsLibrary/FXAS21002.h	Sat Jul 16 19:17:28 2016 +0000
+++ b/SensorsLibrary/FXAS21002.h	Mon Sep 21 21:45:08 2020 +0000
@@ -27,7 +27,7 @@
 #define FXAS21002_CTRL_REG0 0x0D
 #define FXAS21002_CTRL_REG1 0x13
 #define FXAS21002_WHO_AM_I_VALUE 0xD1
-#define GYRO_OFFSET 0.09
+#define GYRO_OFFSET -0.239 //-0.15 //-0.2396875
 /*  Gyroscope mechanical modes
 *   Mode    Full-scale range [Deg/s]    Sensitivity [(mDeg/s)/LSB]
 *   1       +- 2000                     62.5
@@ -65,6 +65,7 @@
     float sensitivity;
     float angle;
     float period;
+    
 };
 
 #endif
\ No newline at end of file
--- a/main.cpp	Sat Jul 16 19:17:28 2016 +0000
+++ b/main.cpp	Mon Sep 21 21:45:08 2020 +0000
@@ -37,7 +37,7 @@
 
 
 //Control Objetcs
-PwmOut servo(PTD3);         // Servo connected to pin PTD3
+PwmOut servo(PTD1);         // Servo connected to pin PTD3
 Motor motor;
 FXOS8700Q_mag mag(PTE25,PTE24,FXOS8700CQ_SLAVE_ADDR1);
 FXOS8700Q_acc acc( PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1);
@@ -46,7 +46,10 @@
 DigitalOut red_led(LED_RED);
 DigitalOut green_led(LED_GREEN);
 DigitalOut blue_led(LED_BLUE);
-DigitalOut main_led(PTD2);
+DigitalOut red_led_s(PTD0);
+DigitalOut green_led_s(PTB2); //PTC4
+DigitalOut blue_led_s(PTC12);
+DigitalOut main_led(PTC4);
 //Protocol Objects
 Receiver rcv;
 EthernetInterface eth;
@@ -80,6 +83,7 @@
 void turn_leds_off();
 
 int main(){
+    
     // Initializing sensors:
     main_led = 1;
     acc.enable();
@@ -91,16 +95,23 @@
     
     // Protocol initialization
     
+    
+    
+    
     printf("Initializing Ethernet!\r\n");
     set_leds_color(RED);
     eth.init(RECEIVER_IFACE_ADDR, RECEIVER_NETMASK_ADDR, RECEIVER_GATEWAY_ADDR);
     eth.connect();
     printf("Protocol initialized! \r\n");
+    gyro.start_measure(GYRO_PERIOD);
     set_leds_color(BLUE);
     rcv.set_socket();
-    gyro.start_measure(GYRO_PERIOD);
+    
     main_led = 0;
     controller_ticker.attach(&control,Ts);
+    
+    
+    
     //main loop
     while(1){
         readProtocol();
@@ -350,30 +361,42 @@
     switch(color)
     {
         case RED:
-            red_led = RGB_LED_ON;               
+            red_led = RGB_LED_ON;
+            red_led_s = RGB_LED_ON;                 
             break;
         case GREEN:
             green_led = RGB_LED_ON;
+            green_led_s = RGB_LED_ON;
             break;
         case BLUE:
             blue_led = RGB_LED_ON;
+            blue_led_s = RGB_LED_ON;
             break;
         case PURPLE:
             red_led = RGB_LED_ON;
             blue_led = RGB_LED_ON;
+            red_led_s = RGB_LED_ON;
+            blue_led_s = RGB_LED_ON;
             break;
         case YELLOW:
             red_led = RGB_LED_ON;
             green_led = RGB_LED_ON;
+            red_led_s = RGB_LED_ON;
+            green_led_s = RGB_LED_ON;
             break;
         case AQUA:
             blue_led = RGB_LED_ON;
             green_led = RGB_LED_ON;
+            blue_led_s = RGB_LED_ON;
+            green_led_s = RGB_LED_ON;
             break;
         case WHITE:
             red_led = RGB_LED_ON;
             green_led = RGB_LED_ON;
             blue_led = RGB_LED_ON;
+            red_led_s = RGB_LED_ON;
+            green_led_s = RGB_LED_ON;
+            blue_led_s = RGB_LED_ON;
             break;
         default:
             break;