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.
main.cpp
00001 #include "mbed.h" 00002 #include "QEI.h" 00003 00004 const float M_PI = 3.14159265358979323846; 00005 00006 Serial pc(USBTX, USBRX); 00007 Ticker flipper1; 00008 00009 Timer timer; 00010 00011 const int PPR = 1024; 00012 const int gear_ratio = 126; 00013 //const float Sampling_time1 = 0.0005; 00014 const float Sampling_time1 = 0.01; 00015 00016 QEI encs[6] = { 00017 QEI(PD_12, PA_15, NC, PPR, &timer), 00018 QEI(PD_3, PB_6, NC, PPR, &timer), 00019 QEI(PB_10, PB_4, NC, PPR, &timer),//, QEI::X4_ENCODING), 00020 QEI(PH_1, PC_0, NC, PPR, &timer), 00021 QEI(PG_2, PC_7, NC, PPR, &timer), 00022 QEI(PB_5, PD_13, NC, PPR, &timer), 00023 }; 00024 00025 void flip1() { 00026 for(int i=0;i<6;i++) 00027 pc.printf("%f\n",encs[i].getAngle()); 00028 pc.printf("\n"); 00029 } 00030 00031 int main() { 00032 pc.baud(115200); 00033 flipper1.attach(&flip1, Sampling_time1); 00034 00035 while(1){ 00036 //pc.printf("%f, %f, %f, %f, %f, %f\n", float(Pulses1), Angle1, Angular_velocity1, float(Pulses2), Angle2, Angular_velocity2); 00037 } 00038 }
Generated on Thu Aug 25 2022 16:56:43 by
1.7.2