![](/media/cache/group/9e3cc099b3b04bca937a1cca1da81b19.jpg.50x50_q85.jpg)
Programma voor HIDScope (lecture 3 tutorial)
Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
Revision 0:a75335365b8c, committed 2019-09-20
- 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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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