running on mbed now

Dependencies:   Classic_PID iC_MU mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
ms523
Date:
Tue Mar 22 08:33:17 2016 +0000
Child:
1:0f0423207b62
Commit message:
swept sine working

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	Tue Mar 22 08:33:17 2016 +0000
@@ -0,0 +1,42 @@
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+Serial pc (USBTX,USBRX);
+Timer t;
+
+int main()
+{
+    float run_time = 5.0;
+    float start_Hz = 1.0, stop_Hz = 2.0;
+    float amplitude;
+    
+
+    pc.printf("\n\r Enter Start frequency (Hz): ");
+    pc.scanf("%f", &start_Hz);
+    pc.printf("%f",start_Hz);
+    
+    pc.printf("\n\r Enter Stop frequency (Hz): ");
+    pc.scanf("%f", &stop_Hz);
+    pc.printf("%f",stop_Hz);
+    
+    pc.printf("\n\r Enter Amplitude (encoder counts): ");
+    pc.scanf("%f", &amplitude);
+    pc.printf("%f",amplitude);
+    
+    pc.printf("\n\n\r Press any key to start test...");
+    pc.getc();
+    
+    float w1 = start_Hz * 3.14159 * 2;
+    float w2 = stop_Hz * 3.14159 * 2; 
+    float a = (w2 - w1) / (2 * run_time); 
+    float b = w1;    
+    float now;
+       
+    t.start();
+
+    while(t.read() < run_time) {
+        now = t.read();
+        pc.printf("\n\r%f",amplitude * sin((a*now*now)+(b*now)));
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Mar 22 08:33:17 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/c0f6e94411f5
\ No newline at end of file