Cristian Castro / Mbed 2 deprecated D05_F407_TraccionDClass

Dependencies:   mbed Motor

Files at this revision

API Documentation at this revision

Comitter:
CCastrop1012
Date:
Fri Sep 03 05:11:24 2021 +0000
Commit message:
Clase Traccion que implementa 2 objetos del tipo motor para controlar la direccion, velocidad, angulo de giro de un vehiculo a base de 2 motores, tanto continuos como discretos. Esta clase genera los comandos para cada motor para cada movimiento.

Changed in this revision

Motor.lib Show annotated file Show diff for this revision Revisions of this file
comments.txt 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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.lib	Fri Sep 03 05:11:24 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/CCastrop1012/code/Motor/#f1ea96183c35
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/comments.txt	Fri Sep 03 05:11:24 2021 +0000
@@ -0,0 +1,77 @@
+
+
+/// Constructores para Motores Continuos
+ /*
+ Motor::Motor(PinName L1, PinName L2, PinName speedPin, PinName encodin, PinName PosInicial, int EncodPulses ):
+ _L1(L1), _L2(L2), _speedPin(speedPin), _encodin(encodin), _PosInicial(PosInicial), _EncodPulses(EncodPulses)
+{
+    _speedPin.period_ms(5);
+    _speedPin.write(0);
+    
+};
+
+
+
+ 
+ Motor::Motor(PinName L1, PinName L2, PinName speedPin) 
+{
+    _L1(L1);
+    _L2(L2);
+    _speedPin(speedPin);
+   
+    _speedPin.period_ms(5);
+    _speedPin.write(0);
+};
+ 
+ 
+ Motor::Motor(PinName L1, PinName L2, PinName speedPin, PinName EncodIn, int EncodPulses): // Constructor del Objeto
+_L1(L1), _L2(L2), _speedPin(speedPin), _EncodIn(EncodIn), _EncodPulses(EncodPulses)
+{
+    _speedPin.period_ms(5);
+    _speedPin.write(0);
+};
+ 
+
+
+/// Constructores para Motores  Discretos
+
+Motor::Motor(char tipo, PinName Dir, PinName Step): _Dir(Dir), _Step(Step) // Constructor del Objeto
+{
+        
+};
+
+Motor::Motor(char tipo, PinName Dir, PinName Step, PinName EncodIn, int EncodPulses): _Dir(Dir), _Step(Step), // Constructor del Objeto
+             _EncodIn(EncodIn), _EncodPulses(EncodPulses)
+{
+        
+}; // Constructor del Objeto
+
+Motor::Motor(char tipo, PinName Dir, PinName Step,  PinName EncodIn, int EncodPulses, PinName PosInicial): _Dir(Dir), _Step(Step), // Constructor del Objeto
+             _EncodIn(EncodIn), _EncodPulses(EncodPulses), _PosInicial(PosInicial)
+{
+        
+}; // Constructor del Objeto
+    
+Motor::Motor(char tipo, PinName Dir, PinName Step, PinName ustep1, PinName ustep2,PinName ustep3): _Dir(Dir), _Step(Step), // Constructor del Objeto
+            _ustep1(ustep1), _ustep2(ustep2), _ustep3(ustep3)
+{
+        
+}; // Constructor del Objeto
+
+Motor::Motor(char tipo, PinName Dir, PinName Step, PinName ustep1, PinName ustep2,PinName ustep3,
+          PinName EncodIn, int EncodPulses): _Dir(Dir), _Step(Step,_ustep1(ustep1), _ustep2(ustep2),
+           _ustep3(ustep3), _EncodIn(EncodIn), _EncodPulses(EncodPulses)  // Constructor del Objeto
+          
+{
+        
+};
+
+ // Constructor del Objeto
+Motor::Motor(char tipo, PinName Dir, PinName Step, PinName ustep1, PinName ustep2,PinName ustep3,
+          PinName EncodIn, int EncodPulses, PinName PosInicial): _Dir(Dir), _Step(Step,_ustep1(ustep1),
+          _ustep2(ustep2), _ustep3(ustep3), _EncodIn(EncodIn), _EncodPulses(EncodPulses), _PosInicial(PosInicial) // Constructor del Objeto
+{
+        
+}; // Constructor del Objeto
+    */
+    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Sep 03 05:11:24 2021 +0000
@@ -0,0 +1,71 @@
+#include "mbed.h"
+#include "Motor.h"
+
+Serial PC(PA_2, PA_3);
+
+
+TraccionD M1(PC_14, PE_6, PE_4, PE_2, 200, 3.3, 7.5);
+
+
+
+DigitalOut LED(PD_14);
+
+int main() {
+        
+        long SOH1;
+
+        
+        PC.printf("Hello World...\n");
+        M1.StepFreq(20); 
+        M1.Giro(270, true); 
+        
+        //M1.Run(2.5); 
+        
+        while(1)
+        {
+            SOH1 = M1.getStepOnHold();
+            PC.printf("StepOnHold M1 = %d ;\n" , SOH1); 
+            if(SOH1 < 10){ M1.StopT(); break; }
+            wait(0.3);
+        }
+        
+        wait(0.3);
+        M1.StepFreq(20); 
+        M1.Giro(270, false); 
+        //M1.Run(2.5); 
+        
+        while(1)
+        {
+            SOH1 = M1.getStepOnHold();
+            PC.printf("StepOnHold M1 = %d ;\n" , SOH1); 
+            if(SOH1 < 10){ M1.StopT(); break; }
+            wait(0.3);
+        }
+        
+        
+        
+            long cont;
+    while(1) {
+        
+        PC.printf("run %d...\n", cont++);
+        
+        //////// Giro sentido 1
+        LED = 1;
+        wait(2);
+        
+        SOH1 = M1.getStepOnHold();
+        PC.printf("StepOnHold M1 = %d ;\n" , SOH1);
+        
+        wait(0.5);
+        
+        //////// Giro sentido contrario
+        LED = 0;
+        wait(2);
+        
+        SOH1 = M1.getStepOnHold();
+        PC.printf("StepOnHold M1 = %d ;\n" , SOH1);
+        
+        wait(0.5);
+        
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Sep 03 05:11:24 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file