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
Diff: main.cpp
- Revision:
- 45:53c4fca47ed4
- Parent:
- 18:ca084c362855
--- a/main.cpp Mon Oct 22 14:00:42 2018 +0000 +++ b/main.cpp Wed Oct 31 17:35:57 2018 +0000 @@ -17,7 +17,7 @@ QEI Encoder3(D13,D12,NC,4200); // Counterclockwise motor rotation is the positive direction // Global variables -const float pi = 3.14159265358979; +const double pi = 3.14159265358979; // Functions @@ -25,15 +25,15 @@ { int counts1; int counts2; int counts3; - float angle1; - float angle2; - float angle3; + double angle1; + double angle2; + double angle3; counts1 = Encoder1.getPulses(); counts2 = Encoder2.getPulses(); counts3 = Encoder3.getPulses(); - angle1 = ((float)counts1*2.0*pi)/4200.0; - angle2 = ((float)counts2*2.0*pi)/4200.0; - angle3 = ((float)counts3*2.0*pi)/4200.0; + 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); }