Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:93d3d1bd7d73, committed 2018-01-05
- Comitter:
- nlfischer
- Date:
- Fri Jan 05 18:00:27 2018 +0000
- Commit message:
- Luiz Fischer
Changed in this revision
diff -r 000000000000 -r 93d3d1bd7d73 Sinal.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Sinal.h	Fri Jan 05 18:00:27 2018 +0000
@@ -0,0 +1,23 @@
+const int tam = 1000;
+int sinal_pwm[tam] = {
+0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,
+1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,
+1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,
+1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,
+0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1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,1,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,
+1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
+1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
+1,};
\ No newline at end of file
diff -r 000000000000 -r 93d3d1bd7d73 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jan 05 18:00:27 2018 +0000
@@ -0,0 +1,106 @@
+#include "mbed.h"
+#include "Sinal.h"
+
+Ticker aciona_interrupcao;
+
+Serial pc(SERIAL_TX, SERIAL_RX, 115200);
+
+AnalogIn tensao_entrada(A4);
+AnalogIn tensao_saida(A5);
+
+PwmOut pwm(D5);
+
+DigitalOut carga(PB_5);
+
+static int interrupt = 1, k=0, periodo_pwm = 1;
+float tempo = 0.001;
+
+float le_tensao_vin(){
+    return tensao_entrada.read()*3.3;
+    }
+    
+float le_tensao_vout(){
+    return tensao_saida.read()*3.3;
+    }
+
+void teste(){
+    pc.printf("\nTeste ok!");
+    }
+
+void imprime_dados(float u, float vout){
+    pc.printf("\n%d", k);    
+    pc.printf("     ");
+    pc.printf("%f", u);    
+    pc.printf("     ");  
+    pc.printf("%f", vout);  
+}
+
+void interrupcao(){
+    interrupt = 1;
+    k=k+1;
+}
+
+void fim(){   
+    pc.printf("];");
+    pc.printf("\nfigure(1)");
+    pc.printf("\nsubplot(2,1,1)");
+    pc.printf("\nstairs(dados(:,3),'k')");    
+    pc.printf("\ngrid on");
+    pc.printf("\nylabel('saida')");
+    pc.printf("\nsubplot(2,1,2)");    
+    pc.printf("\nstairs(dados(:,2))");
+    pc.printf("\ngrid on");
+    pc.printf("\nsave dados dados");
+    pc.printf("\nylabel('entrada')\n\n");
+      
+    while(1){ 
+      
+    }  
+}
+
+float seta_pwm(int x){
+    float uu = 0.0;
+    if(x==0) {
+            uu = (float)50/255;
+            pwm.pulsewidth_us(1000*uu);
+            return uu;
+        }
+        else {
+            uu = (float)250/255;
+            pwm.pulsewidth_us(1000*uu);
+            return uu;
+        }
+}
+
+int main() {
+    int i = 0;
+    float vin=0.0,vout=0.0, u=0.0;
+    
+    
+    aciona_interrupcao.attach(&interrupcao, 0.03);
+    
+    pwm.period_ms(periodo_pwm);
+    
+    pc.printf("%% Inicio do programa");  
+    pc.printf("\nclear all; clc;");  
+    pc.printf("\ndados = [");  
+    
+    while(1){
+        
+    if(interrupt) {
+        
+        u = seta_pwm(sinal_pwm[k]);        
+           
+        imprime_dados(3.3*u, le_tensao_vout());
+        
+        
+        interrupt = 0;
+        
+        if(k==tam-1) fim();
+            
+      
+    }
+    
+
+}
+}
\ No newline at end of file
diff -r 000000000000 -r 93d3d1bd7d73 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jan 05 18:00:27 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/fb8e0ae1cceb \ No newline at end of file