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.
Diff: main.cpp
- Revision:
- 0:f303c63965dd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Sep 29 01:28:19 2015 +0000
@@ -0,0 +1,51 @@
+//MIDN 2/C Chau
+//Take a temp reading from sensor and send it to MatLab for analysis
+//ES305 Lab2
+#include "mbed.h"
+#include "mbedWSEsbc.h"
+
+float dt; // total change in time
+float totaltime = 5; // total sampling time
+float Ts = 0.01; // sampling period
+int repeat = 17; //Boolean for yes or no
+float Time = 0; // time object
+float measurement = 0; //The measured voltage of the thermocouple
+
+int main()
+{
+ mbedWSEsbcInit(19200); //set baud rate
+ Time = 0; // reset time var
+ t.reset(); // reset time object
+ pc.printf("Enter 1 to begin the loop:\n\r");
+ pc.scanf("%d", &repeat);
+ pc.printf("Enter total sampling time(sec):\n\r");
+ pc.scanf("%f", &totaltime);
+ pc.printf("Enter sampling period(sec):\n\r");
+ pc.scanf("%f", &Ts);
+ while (repeat ==1)
+ {
+ Time = 0; // reset time var
+ t.reset(); // reset time object
+
+ while (Time <= totaltime)
+ {
+ t.start(); // start timing object
+
+ measurement = read_max1270_volts(6,0,0); //read from the device
+ pc.printf("%f,%f\n", Time, measurement); // print measurement
+
+ Time = Time + Ts; // increment time
+
+ dt = Ts - t.read(); // calculate elapsed time
+ wait(dt); // wait
+
+ t.reset(); //restart timing object
+ }
+ pc.printf("Enter 1 to begin the loop:\n\r");
+ pc.scanf("%d", &repeat);
+ pc.printf("Enter total sampling time(sec):\n\r");
+ pc.scanf("%f", &totaltime);
+ pc.printf("Enter sampling period(sec):\n\r");
+ pc.scanf("%f", &Ts);
+ }
+}
\ No newline at end of file