running on mbed now
Dependencies: Classic_PID iC_MU mbed-rtos mbed
main.cpp
- Committer:
- ms523
- Date:
- 2016-03-22
- Revision:
- 0:3a132f85c1a8
- Child:
- 1:0f0423207b62
File content as of revision 0:3a132f85c1a8:
#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", &litude); 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))); } }