Betago / Mbed 2 deprecated BETAGO

Dependencies:   PID mbed MaxSonar eeprom iSerial Fork_Boss_Communication_Robot

Files at this revision

API Documentation at this revision

Comitter:
palmdotax
Date:
Sun Jan 17 20:34:12 2016 +0000
Parent:
8:8fbc0c858875
Child:
10:4bc59f8bfa18
Commit message:
GG

Changed in this revision

MaxSonar.lib Show annotated file Show diff for this revision Revisions of this file
UNTRASONIC.cpp Show annotated file Show diff for this revision Revisions of this file
UNTRASONIC.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
move.cpp Show annotated file Show diff for this revision Revisions of this file
move.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MaxSonar.lib	Sun Jan 17 20:34:12 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/mkanli/code/MaxSonar/#b439ab68c8d9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UNTRASONIC.cpp	Sun Jan 17 20:34:12 2016 +0000
@@ -0,0 +1,79 @@
+#include "mbed.h"
+#include "MaxSonar.h"
+#include "UNTRASONIC.h"
+sensor::sensor()
+{
+    sen_1=0;
+    sen_2=0;
+    sen_3=0;
+    sen_4=0;
+    sen_5=0;
+    sen_6=0;
+    sen_7=0;
+    sen_8=0;
+    sen_9=0;
+    sen_10=0;
+    
+    
+}
+void sensor::get_sen()
+{
+    
+    
+}
+void sensor::inti()
+{
+    MaxSonar *range1;
+    range1 = new MaxSonar(MS_LV, MS_ANALOG, PA_10, PA_0);
+    range1->setVoltage(3.3);
+    range1->setUnits(MS_CM);
+    
+    MaxSonar *range2;
+    range2 = new MaxSonar(MS_LV, MS_ANALOG, PA_10, PA_1);
+    range2->setVoltage(3.3);
+    range2->setUnits(MS_CM);
+    
+    MaxSonar *range3;
+    range3 = new MaxSonar(MS_LV, MS_ANALOG, PA_10, PA_4);
+    range3->setVoltage(3.3);
+    range3->setUnits(MS_CM);
+    
+    MaxSonar *range4;
+    range4 = new MaxSonar(MS_LV, MS_ANALOG, PA_10, PB_0);
+    range4->setVoltage(3.3);
+    range4->setUnits(MS_CM);
+    
+    MaxSonar *range5;
+    range5 = new MaxSonar(MS_LV, MS_ANALOG, PA_10, PC_1);
+    range5->setVoltage(3.3);
+    range5->setUnits(MS_CM);
+    
+    MaxSonar *range6;
+    range6 = new MaxSonar(MS_LV, MS_ANALOG, PA_10, PC_0);
+    range6->setVoltage(3.3);
+    range6->setUnits(MS_CM);
+    
+    MaxSonar *range7;
+    range7 = new MaxSonar(MS_LV, MS_ANALOG, PA_10, PC_2);
+    range7->setVoltage(3.3);
+    range7->setUnits(MS_CM);
+    
+    MaxSonar *range8;
+    range8 = new MaxSonar(MS_LV, MS_ANALOG, PA_10, PC_3);
+    range8->setVoltage(3.3);
+    range8->setUnits(MS_CM);
+    
+    MaxSonar *range9;
+    range9 = new MaxSonar(MS_LV, MS_ANALOG, PA_10, PC_4);
+    range9->setVoltage(3.3);
+    range9->setUnits(MS_CM);
+    
+    MaxSonar *range10;
+    range10 = new MaxSonar(MS_LV, MS_ANALOG, PA_10, PC_5);
+    range10->setVoltage(3.3);
+    range10->setUnits(MS_CM);
+    
+    
+    
+    
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UNTRASONIC.h	Sun Jan 17 20:34:12 2016 +0000
@@ -0,0 +1,11 @@
+#ifndef UNTRASONIC_H
+#define UNTRASONIC_H
+class sensor
+{
+    private:float sen_1,sen_2,sen_3,sen_4,sen_5,sen_6,sen_7,sen_8,sen_9,sen_10;
+    public : void get_sen();
+            void inti();
+            sensor();
+    
+};
+#endif 
\ No newline at end of file
--- a/main.cpp	Mon Dec 14 19:35:08 2015 +0000
+++ b/main.cpp	Sun Jan 17 20:34:12 2016 +0000
@@ -3,55 +3,83 @@
 #include "PID.h"
 
 DigitalOut led1(LED1);
-InterruptIn encoderA(D10);
-InterruptIn encoderB(D11);
+InterruptIn encoderA_d(PB_12);
+DigitalIn encoderB_d(PB_13);
+InterruptIn encoderA_1(PB_1);
+DigitalIn encoderB_1(PB_2);
+InterruptIn encoderA_2(PB_14);
+DigitalIn encoderB_2(PB_15);
 Timer timerStart;
 Timeout timecount;
 move m1;
 PID P1(0.005,0.005,0,0.1);
 double setp1=0,setp2=0;
 //DigitalIn encoderB(D5);
-int times;
+
 
-Serial pc(SERIAL_TX,SERIAL_RX);
- int Encoderpos = 0;
- float valocity =0,pulse=0,count=0,r=0.125,velocityreal=0;
+ Serial pc(SERIAL_TX,SERIAL_RX);
+ int Encoderpos = 0,times=0;
+ int real_d=0;
+ float valocity =0,pulse_1=0,pulse_2=0,count=0,r=0.125,velocityreal=0,pulse_d=0,Z_d=0;
  float outPID =0;
  //double Input,Output,setp,Kp=0.005,Ki=0.005,Kd=0;
 
 
-void EncoderA()
-{   if(encoderB==0)
+void EncoderA_1()
+{   if(encoderB_1==0)
         { Encoderpos = Encoderpos + 1;}
     else
    { Encoderpos = Encoderpos -1;}
-   
+   pulse_1+=1;
    //Encoderpos = Encoderpos + 1;
   // valocity+=1;
   // pc.printf("%d \n",Encoderpos);
-  pulse+=1;
-  //pc.printf("pulse=%f  \n",pulse);
+   //pc.printf("pulse=%f  \n",pulse);
  // if(pulse==128)
   //{count+=1;pulse=0; pc.printf("count=%f  \n",count);}
-  
 }
-  
-
-/*void EncoderB()
+  void EncoderA_2()
 { 
-    if(encoderA==1)
+    if(encoderB_2==0)
+    { Encoderpos = Encoderpos + 1;}
+    else
+    { Encoderpos = Encoderpos -1;}
+    pulse_2+=1;
+    //pc.printf("%d",Encoderpos);
+}
+void EncoderA_D()
+{ 
+    if(encoderB_d==0)
     { Encoderpos = Encoderpos + 1;}
     else
     { Encoderpos = Encoderpos -1;}
-    pc.printf("%d",Encoderpos);
-}*/
-void getvelo()
+    pulse_d+=1;
+    if(pulse_d==128)
+    {
+        Z_d+=1;
+        pulse_d=0;
+    }
+   // pc.printf("%d",Encoderpos);
+}
+void getvelo1()
 {
-    valocity=pulse*((2*3.14*r)/128);
+    valocity=pulse_1*((2*3.14*r)/128);
     pc.printf("valocity=%f  \n",valocity);
     count=0;
     timerStart.reset();
 }
+void getvelo2()
+{
+    valocity=pulse_2*((2*3.14*r)/128);
+    pc.printf("valocity=%f  \n",valocity);
+    count=0;
+    timerStart.reset();
+}
+void get_d()
+{
+    real_d=Z_d*(2*3.14*r);
+    
+}
 double map(double x, double in_min, double in_max, double out_min, double out_max)
 {
     return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
@@ -64,10 +92,10 @@
      times=timerStart.read();
        if(times==1)// m/s
        {   
-           getvelo();
+           getvelo1();
            //pc.printf("TIME \n");
            times=0;
-           pulse=0;
+           pulse_1=0;
         }
     P1.setProcessValue(valocity);
     outPID=P1.compute();
@@ -81,10 +109,10 @@
      times=timerStart.read();
        if(times==1)// m/s
        {   
-           getvelo();
+           getvelo2();
            //pc.printf("TIME \n");
            times=0;
-           pulse=0;
+           pulse_2=0;
         }
     P1.setProcessValue(valocity);
     outPID=P1.compute();
@@ -94,10 +122,10 @@
 
 int main()
 {
-       int times=0;
+      
        
        pc.baud(115200);
-       encoderA.rise(&EncoderA);
+       encoderA_1.rise(&EncoderA_1);
        timerStart.start();   
        P1.setMode(1);
        //setp=map(1,0,1.0916,0,1);
--- a/move.cpp	Mon Dec 14 19:35:08 2015 +0000
+++ b/move.cpp	Sun Jan 17 20:34:12 2016 +0000
@@ -3,12 +3,13 @@
 
 
 
-DigitalOut dir1(D6);
-DigitalOut dir2(D7);
-PwmOut speeds(PC_8);
-DigitalOut dirr1(D4);
-DigitalOut dirr2(D5);
-PwmOut speeds2(D3);
+DigitalOut dir1(PA_5);
+DigitalOut dir2(PA_6);
+PwmOut speeds(PA_5);
+DigitalOut dirr1(PB_6);
+DigitalOut dirr2(PC_7);
+PwmOut speeds2(PA_7);
+DigitalOut relays(PA_8);
  void move:: movespeed_1(int dir,float setpoint,float spd)
 {
      double dc=0;
@@ -44,4 +45,8 @@
       speeds.write(dc);
       
              
+}
+void move::pump(int on_off)
+{
+    relays=on_off;
 }
\ No newline at end of file
--- a/move.h	Mon Dec 14 19:35:08 2015 +0000
+++ b/move.h	Sun Jan 17 20:34:12 2016 +0000
@@ -1,11 +1,12 @@
 #ifndef MOVE_H
 #define MOVE_H
-//#include "mbed.h" 
+
 
 class move
 {
     public: void movespeed_1(int dir,float setpoint,float spd);
-    public: void movespeed_2(int dir,float setpoint,float spd);
+            void movespeed_2(int dir,float setpoint,float spd);
+            void pump(int on_off);
     
 };
 #endif 
\ No newline at end of file