Uso de la clase Motor para el control de velocidad de un motor continuo con encoder.

Dependencies:   mbed

Revision:
0:75421f27540e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Sep 03 05:04:12 2021 +0000
@@ -0,0 +1,61 @@
+#include "mbed.h"
+#include "Motor.h"
+
+Serial Mbed(PB_6, PB_7);
+//Serial Mbed(PA_2, PA_3);
+InterruptIn Encoder(PC_9);
+DigitalOut LED(PA_5);
+DigitalIn  Button(PA_0);
+MotorContinuo Mizq(PD_13, PD_11, PB_15, NC,NC,0);
+
+
+long x = 0;
+long muestras[200];
+int  t = 10; 
+int escalon_1 = 10, escalon_2 = 80, escalon_3 = 30, escalon_4 = 50,  escalon_5 = 65, escalon_6 = 5, escalon_7 = 20, escalon_8 = 40;   
+
+
+
+
+
+void interrupt()
+{
+    x ++;
+    
+}
+
+
+
+int main() {
+    
+    Mbed.printf("Hello World\n!");
+    Encoder.rise(&interrupt);
+    
+    long temp = 0;
+    int  duty = 10;
+    
+    
+    
+    while(1) 
+    {
+        
+             //////// Giro sentido 1
+
+            Mbed.printf("Motor Velocidad = %d%% : ",duty);
+            LED = 1;
+            
+            Mizq.Forward();
+            Mizq.SpeedDuty(duty);
+            x = 0;  temp = 0;
+            wait(1); 
+            temp = x;
+            Mbed.printf("PPS = %d : \n",temp);
+            LED = 0;
+            if(Button == 0) { duty++; if(duty > 100) duty = 10; }
+            wait(1);
+            
+        
+    
+        
+    }
+}