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: FastPWM mbed QEI biquadFilter HIDScope MODSERIAL
main.cpp
- Committer:
- efvanmarrewijk
- Date:
- 2018-10-31
- Revision:
- 45:53c4fca47ed4
- Parent:
- 18:ca084c362855
File content as of revision 45:53c4fca47ed4:
// Inclusion of libraries #include "mbed.h" #include "FastPWM.h" #include "QEI.h" // Includes library for encoder #include "MODSERIAL.h" #include "HIDScope.h" #include "BiQuad.h" // Input // Output // Utilisation of libraries MODSERIAL pc(USBTX, USBRX); QEI Encoder1(D11,D10,NC,4200); // Counterclockwise motor rotation is the positive direction QEI Encoder2(D9,D8,NC,4200); // Counterclockwise motor rotation is the positive direction QEI Encoder3(D13,D12,NC,4200); // Counterclockwise motor rotation is the positive direction // Global variables const double pi = 3.14159265358979; // Functions void Encoderinput() { int counts1; int counts2; int counts3; double angle1; double angle2; double angle3; counts1 = Encoder1.getPulses(); counts2 = Encoder2.getPulses(); counts3 = Encoder3.getPulses(); angle1 = ((double)counts1*2.0*pi)/4200.0; angle2 = ((double)counts2*2.0*pi)/4200.0; angle3 = ((double)counts3*2.0*pi)/4200.0; pc.printf("Counts1: %i Angle1: %f Counts2: %i Angle2: %f\r\n",counts1,angle1,counts2,angle2); } // Main program int main() { pc.baud(115200); while (true) { Encoderinput(); } }