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:dd4331d7abaf, committed 2018-01-05
- Comitter:
- nlfischer
- Date:
- Fri Jan 05 17:59:10 2018 +0000
- Commit message:
- Luiz Fischer
Changed in this revision
| 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/main.cpp Fri Jan 05 17:59:10 2018 +0000
@@ -0,0 +1,90 @@
+#include "mbed.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, tam = 500;
+float tempo = 0.001;
+
+
+float le_tensao_vout(){
+ return tensao_saida.read()*3.3;
+ }
+
+
+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_degrau dados");
+ pc.printf("\nylabel('entrada')\n\n");
+
+ pwm.pulsewidth_us(1);
+
+ while(1){
+
+ }
+}
+
+
+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) {
+
+ if(k>50){
+ u = 3.3;
+ pwm.pulsewidth_us(1000);
+ }
+ imprime_dados(u, le_tensao_vout());
+
+
+ interrupt = 0;
+
+ if(k==tam-1) fim();
+
+
+ }
+
+
+}
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jan 05 17:59:10 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/fb8e0ae1cceb \ No newline at end of file