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.
Encoder.cpp
00001 #include "Encoder.h" 00002 00003 //Encoder steps to revolutions of output shaft in radians 00004 float pulsesToRadians(float pulses) { 00005 return ((pulses/ENC_STEPS_PER_REV)*(2.0*PI)); 00006 } 00007 00008 //Encoder steps to revolutions of output shaft in degrees 00009 float pulsesToDegrees(float pulses) { 00010 return ((pulses/ENC_STEPS_PER_REV)*360.0); 00011 } 00012 00013 Encoder::Encoder(PinName enc_a_pin, PinName enc_b_pin): qei_(enc_a_pin, enc_b_pin, NC, ENC_STEPS_PER_REV, QEI::X4_ENCODING) { 00014 //Use X4 encoding. 00015 //(encoder channel 1, encoder channel 2, index (n/a here), counts per revolution, mode (X4, X2)) 00016 //QEI ; 00017 } 00018 00019 float Encoder::get_position(void) { 00020 return pulsesToRadians(qei_.getPulses()); 00021 }
Generated on Tue Jul 12 2022 15:35:31 by
1.7.2