Applied engineering Team / Mbed 2 deprecated Sinusoide

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
eneko
Date:
Sat Dec 05 18:47:51 2015 +0000
Commit message:
sinusoid eneko

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	Sat Dec 05 18:47:51 2015 +0000
@@ -0,0 +1,54 @@
+#include "mbed.h"
+
+AnalogOut Aout(p18);
+AnalogIn Ain(p20);
+//AnalogIn Ain1(p19);
+//AnalogIn Ain2(p20);
+
+DigitalIn sw1(p7);
+DigitalIn sw2(p8);
+DigitalIn sw3(p9);
+DigitalIn sw4(p10);
+
+int main() {
+    float A,T,f,Ts;//A=amplitude, T=period, f=frequency, Ts= sampling time
+    const float PI=3.141592;
+    int SinNumPoints=100;
+    
+    //with only one potenciometer
+    while(1) {
+        if (sw1==1){//mode1: amplitude control
+            A=Ain;
+            f=50000;
+            T=1/f;
+            Ts= T/SinNumPoints;
+            for (int i=0;i<SinNumPoints;i++){
+                Aout=0.5+A/2*sin(2*PI*f*i*Ts);
+                wait(Ts);
+        }else if(sw2==1){// mode2: period control
+            A=1;
+            f=50000*Ain;
+            T=1/f;
+            Ts= T/SinNumPoints;
+            for (int i=0;i<SinNumPoints;i++){
+                Aout=0.5+A/2*sin(2*PI*f*i*Ts);
+                wait(Ts);
+        }
+            /* with 2 potenciometer to control simuntaneously both parameter, amplitude and frequency
+            
+            while(1){
+                A=Ain1;
+                f=50000*Ain2;(20ms)
+                T=1/f;
+                Ts=T/SinNumPoints;
+                for (int i=0;i<SinNumPoints;i++){
+                    Aout=0.5+A/2*sin(2*PI*f*i*Ts);
+                    wait(Ts);
+                }
+            }
+            
+            */
+    }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Dec 05 18:47:51 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/165afa46840b
\ No newline at end of file