linear actuator

Dependencies:   Motor PinDetect mbed

Fork of xbee_robot by Shubhojit Chattopadhyay

Files at this revision

API Documentation at this revision

Comitter:
conantina
Date:
Fri Feb 26 23:08:38 2016 +0000
Parent:
4:580ea208038b
Commit message:
latest_version

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Feb 26 20:49:08 2016 +0000
+++ b/main.cpp	Fri Feb 26 23:08:38 2016 +0000
@@ -1,5 +1,5 @@
 //Linear Actuator to control the moving rod. 
-
+/*
 #include "mbed.h"
 #include "Motor.h"
 #include "PinDetect.h"
@@ -84,13 +84,13 @@
   
 }
 
-/*
+*/
 
 #include "mbed.h"
 #include "Motor.h"
 #include "PinDetect.h"
 
-float moving_time1 = 15.0;            //we control the Table Actuator stop position by play with the moving time1; longer rising time,higher stop position
+float moving_time1 = 10.0;            //we control the Table Actuator stop position by play with the moving time1; longer rising time,higher stop position
 float moving_time2 = 20.0;            //we control the Connector Actuator stop position by play with the moving time2; longer rising time,higher stop position
 float charging_time = 20.0;           //the time needed to charge the battery, during which the Connector Actuator will stay at its highest position
 float wait_time = 3.0;                //time waiting for the drone to slide to the triangle hindge
@@ -105,8 +105,8 @@
 PinDetect load_sensor(p5);
 PinDetect start(p6);
 PinDetect reset(p7);
-
-
+DigitalOut led(LED1);
+DigitalOut led2(LED2);
 
 //********************************************* Pb Interrupt Functions **************************************************
 
@@ -143,6 +143,7 @@
 //********************************************* Functions for Base Station System *********************************************************
 void reset_schedule()
 {
+    led = 0;
     for(int i = 0; i<(moving_time2/pulse_width);i++){
          fall(m2,pulse_width);   
     }    
@@ -156,32 +157,61 @@
 {
     for(int i=0;i<(moving_time1/pulse_width);i++)    //Table Actuator lift the table up
     {   if(is_reset){reset_schedule();return;}
+        led = !led;
         raise(m1,pulse_width);
     }
+    led2 = 1;
+    wait(0.2);
+    led2 = 0;
     for(int i=0;i<(wait_time/pulse_width);i++)       //Waiting for the quadcoptor to slide into the triangle hindge
     {   if(is_reset){reset_schedule();return;}
+        led = !led;
         hold();
     }
+    led2 = 1;
+    wait(0.2);
+    led2 = 0;
+    for(int i = 0; i<(moving_time1/pulse_width);i++) //Table Actuator goes down
+    {   if(is_reset){reset_schedule();return;}
+        led = !led;
+        fall(m1,pulse_width);   
+    } 
+    led2 = 1;
+    wait(0.2);
+    led2 = 0; 
     for(int i = 0; i<(moving_time2/pulse_width);i++) //Connector Actuator lifts up
     {   if(is_reset){reset_schedule();return;}
+        led = !led;
         raise(m2,pulse_width);   
     } 
+    led2 = 1;
+    wait(0.2);
+    led2 = 0;
     for(int i=0;i<(charging_time/pulse_width);i++)   //Waiting for the battery to charge
     {   if(is_reset){reset_schedule();return;}
+        led = !led;
         hold();
     }
+    led2 = 1;
+    wait(0.2);
+    led2 = 0;
     for(int i = 0; i<(moving_time2/pulse_width);i++) //Connector Actuator goes down
     {   if(is_reset){reset_schedule();return;}
+        led = !led;
         fall(m2,pulse_width);   
     } 
+    led2 = 1;
+    wait(0.2);
+    led2 = 0;
     for(int i=0;i<(hold_time/pulse_width);i++)       //Waiting for the quadcoptpr to take off
     {   if(is_reset){reset_schedule();return;}
+        led = !led;
         hold();
     }      
-    for(int i = 0; i<(moving_time1/pulse_width);i++) //Table Actuator goes down
-    {   if(is_reset){reset_schedule();return;}
-        fall(m1,pulse_width);   
-    }        
+    led2 = 1;
+    wait(0.2);
+    led2 = 0;
+          
 }
 
 //********************************************* Main Function *********************************************************
@@ -198,11 +228,14 @@
     reset.attach_deasserted(&break_loop);
     reset.setSampleFrequency();
     while(1){
-        
+        led = 1;
         if(running_schedule){
             schedule();
             running_schedule = 0;       //return to reset after finish the schedule
         }
+        if(is_reset){
+            reset_schedule();
+        }
     }
 }
-*/
+