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.
Dependencies: HIDScope QEI mbed
main.cpp
00001 #include "mbed.h" 00002 #include "QEI.h" 00003 #include "HIDScope.h" 00004 HIDScope scope(2); // We’re going to send 2 channels of data 00005 Ticker AInTicker; 00006 AnalogIn pot(A1); 00007 00008 QEI Encoder(D13,D12,NC,32); 00009 00010 00011 volatile float x; 00012 volatile float x_prev =0; 00013 volatile float y; // filtered 'output' of ReadAnalogInAndFilter 00014 volatile float z; 00015 00016 void ReadAnalogInAndFilter() 00017 { 00018 int n_rev= Encoder.getRevolutions(); 00019 int n_pulse= Encoder.getPulses(); 00020 00021 x = n_pulse*(360/32)-(32*n_rev) ; // Capture data scope.set(0, x); // store data in first element of scope memory 00022 // y = 0;// averaging filter 00023 scope.set(1, x); // store data in second element of scope memory 00024 // x_prev = x; // Prepare for next round 00025 // z= button1; 00026 // scope.set(0,z); 00027 scope.send(); // send what's in scope memory to PC 00028 } 00029 00030 int main() 00031 { 00032 AInTicker.attach(&ReadAnalogInAndFilter, 0.01); 00033 00034 Encoder.reset(); 00035 00036 00037 while (true) 00038 { 00039 00040 00041 00042 00043 00044 } 00045 } 00046
Generated on Sun Sep 3 2023 09:35:58 by
