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: mbed
main.cpp
00001 #include "mbed.h" 00002 #include "math.h" 00003 //------------------------------------------ 00004 #define PI 3.1415927f 00005 //------------------------------------------ 00006 #include "EncoderCounter.h" 00007 #include "DiffCounter.h" 00008 #include "IIR_filter.h" 00009 #include "LinearCharacteristics.h" 00010 00011 PwmOut pwm1(PA_5); 00012 00013 float inc2rad = 2.0f*3.1415927f/(4.0f*6400.0); 00014 00015 int main() 00016 { 00017 00018 EncoderCounter counter1(PB_6, PB_7); 00019 DiffCounter diffc(0.9f,0.05f); 00020 00021 00022 pwm1.period(0.00005f); 00023 00024 while(1) { 00025 short inc = counter1.read(); 00026 float velocity = diffc(inc); 00027 printf("angle = %.2f velocity = %.2f\r\n",inc*inc2rad,velocity); 00028 00029 pwm1.write(0.5f); 00030 wait(0.05f); 00031 } 00032 } 00033 00034
Generated on Mon Jul 18 2022 18:17:56 by
1.7.2