Programma voor HIDScope (lecture 3 tutorial)

Dependencies:   mbed QEI HIDScope biquadFilter MODSERIAL FastPWM

Files at this revision

API Documentation at this revision

Comitter:
freek100
Date:
Fri Sep 20 12:46:54 2019 +0000
Commit message:
Eerste versie voor assignment 2 van lecture 3 tutorial

Changed in this revision

FastPWM.lib Show annotated file Show diff for this revision Revisions of this file
HIDScope.lib Show annotated file Show diff for this revision Revisions of this file
MODSERIAL.lib Show annotated file Show diff for this revision Revisions of this file
QEI.lib Show annotated file Show diff for this revision Revisions of this file
biquadFilter.lib Show annotated file Show diff for this revision Revisions of this file
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 a75335365b8c FastPWM.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FastPWM.lib	Fri Sep 20 12:46:54 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Sissors/code/FastPWM/#c0b2265cff9c
diff -r 000000000000 -r a75335365b8c HIDScope.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HIDScope.lib	Fri Sep 20 12:46:54 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/tomlankhorst/code/HIDScope/#d23c6edecc49
diff -r 000000000000 -r a75335365b8c MODSERIAL.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MODSERIAL.lib	Fri Sep 20 12:46:54 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Sissors/code/MODSERIAL/#d2a5e26fd658
diff -r 000000000000 -r a75335365b8c QEI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEI.lib	Fri Sep 20 12:46:54 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/aberk/code/QEI/#5c2ad81551aa
diff -r 000000000000 -r a75335365b8c biquadFilter.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/biquadFilter.lib	Fri Sep 20 12:46:54 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/tomlankhorst/code/biquadFilter/#26861979d305
diff -r 000000000000 -r a75335365b8c main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Sep 20 12:46:54 2019 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#include "HIDScope.h"
+//#include "QEI.h"
+#include "MODSERIAL.h"
+//#include "BiQuad.h"
+//#include "FastPWM.h"
+#include <string> 
+
+        
+DigitalOut ledr(LED_RED);
+DigitalOut ledg(LED_GREEN);
+DigitalOut ledb(LED_BLUE);
+PwmOut led1(D10);
+DigitalIn button1(D2);
+AnalogIn potmeter(A1);
+DigitalIn sw(SW2);
+MODSERIAL pc(USBTX, USBRX);
+
+HIDScope scope(2); //Going to send 2 channels of data. To access data go to 'http:/localhost:18082/' after starting HIDScope application.
+Ticker AInTicker;
+AnalogIn aIn1(A1);
+
+volatile float x;
+volatile float x_prev=0;
+volatile float y; //filtered 'output' of Read Analog
+
+void ReadAnalogInAndFilter()
+{
+    x=aIn1; //capture data
+    scope.set(0,x); //store data in first element of scope memory (store 1st data point)
+    y=(x_prev+x)/2.0; //averaging filter
+    scope.set(1,y); //store data in second element of scope memory (store second data point)
+    x_prev= x; //prepare for next round
+    
+    scope.send(); //send what's in scope memory to PC
+}
+
+int main()
+{
+    pc.baud(115200);
+    pc.printf("\r\nStarting...\r\n\r\n");
+  
+    AInTicker.attach(&ReadAnalogInAndFilter, 0.01);
+    while(true){/*do nothing. You could use y here if you wish*/};
+
+}
\ No newline at end of file
diff -r 000000000000 -r a75335365b8c mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Sep 20 12:46:54 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/675da3299148
\ No newline at end of file