This is an experiment to ascertain the maximum frequency of the DAC. A sine wave is created initially with 64 samples. This is then output to the DAC at maximum speed. The real sine wave frequency is observed on the scope. The reconstruction frequency is 64* signal frequency on the scope.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
tgartlan
Date:
Wed Apr 15 14:08:29 2015 +0000
Commit message:
This is a simple experiment to try and ascertain the maximum reconstruction frequency of the DAC. A sine wave is created with 512 samples. We observe the real frequency of the sine wave on the scope. The reconstruction frequency is 512*frequency.

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
diff -r 000000000000 -r 7ae9ba701ec5 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Apr 15 14:08:29 2015 +0000
@@ -0,0 +1,44 @@
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+AnalogOut Aout(p18);
+
+//Note if w_hat is pi/4 this means 8 samples/period. If we measure frequency of this output signal.
+//then reconstruction frequency is 8 times this.
+//Could put it through a low pass filter to smooth out.
+//Also check the offset.
+
+//Sine wave reconstruction in this case is much faster(tahn test4_sine) since I calculate the sample values before hand.
+//Sine wave period is 2.2*5us = 12us
+//Sine wave freq = 83KHz
+//Reconstruction freq is 666KHz
+
+
+
+unsigned short n;
+#define pi 3.1415192
+#define N 64                  //Numebr of samples in one period 
+#define w_hat 2*pi/N          //Normalised radian frequency               
+float sine1 [N];              //contains sine wave sample values
+
+void init_sine_array(void);
+
+int main() {
+    init_sine_array();
+    n=0;
+    while(1) {
+        
+            Aout = sine1[n];
+            n=(n+1)%N;
+    }
+}
+
+void init_sine_array(void)
+{
+    unsigned short n = 0;
+    for (n=0;n<N;n++)
+    {
+        sine1[n] = 0.5 + 0.5*sin(n*w_hat);   //note the 0.5 V of offset since DAC outputs voltage between 0 and 3.3V
+    }
+    
+ }   
diff -r 000000000000 -r 7ae9ba701ec5 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Apr 15 14:08:29 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file