José Antônio Bechara / Mbed OS APS1-Maquinas_e_Acionamentos

Files at this revision

API Documentation at this revision

Comitter:
zezo
Date:
Mon Sep 13 22:08:15 2021 +0000
Commit message:
oi;

Changed in this revision

.gitignore 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-os.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Mon Sep 13 22:08:15 2021 +0000
@@ -0,0 +1,4 @@
+.build
+.mbed
+projectfiles
+*.py*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Sep 13 22:08:15 2021 +0000
@@ -0,0 +1,49 @@
+#include "mbed.h"
+
+PwmOut EN_A(D2);
+DigitalOut IN1A(D5);
+DigitalOut IN2A(D4);
+AnalogIn pot(A5);
+
+InterruptIn Encoder_interrupt(D3);
+
+float DC;
+float Va;
+
+int up;
+float w;
+
+Timer t;
+
+void contador()
+{
+    up++;
+}
+
+int main()
+{
+    while(1) {
+        DC = pot.read();
+        EN_A.write(DC);
+        IN1A = 1;
+        IN2A = 0;
+        Va = 12*DC;
+
+        t.start();
+        Encoder_interrupt.rise(&contador);
+        Encoder_interrupt.fall(&contador);
+
+        if(t.read()>=0.5 ) {
+            w = up/t.read();
+            printf("W = %1.2f rpm\n\r",w);
+            printf("DC = %1.2f\n\r",DC,"V\n\r");
+            printf("Va = %1.2f V\n\r",Va);
+            printf("\n\r");
+            up =0;
+            t.reset();
+        }
+
+        wait(0.001);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Mon Sep 13 22:08:15 2021 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#cf4f12a123c05fcae83fc56d76442015cb8a39e9