WIP

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
mnewton1
Date:
Sat Apr 06 17:16:49 2013 +0000
Commit message:
Work in progress.

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 c146143219c5 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Apr 06 17:16:49 2013 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+
+ volatile int rpmcount;
+ unsigned int rpm;
+ unsigned long timeold;
+ 
+ InterruptIn speed(p9);
+ 
+ void setup()
+ {
+    
+    rpmcount = 0;
+    rpm = 0;
+    timeold = 0;
+ }
+ 
+ void loop()
+ {
+   if (rpmcount >= 20) { 
+     //Update RPM every 20 counts, increase this for better RPM resolution,
+     //decrease for faster update
+     rpm = 30*1000/(millis() - timeold)*rpmcount;
+     timeold = millis();
+     rpmcount = 0;
+     Serial.println(rpm,DEC);
+   }
+ }
+ void rpm_fun()
+ {
+   rpmcount++;
+   //Each rotation, this interrupt function is run twice
+ }
\ No newline at end of file
diff -r 000000000000 -r c146143219c5 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Apr 06 17:16:49 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/71b101360fb9
\ No newline at end of file