Basic library to interface a 2 channel quadrature encoder with mBed
Embed:
(wiki syntax)
Show/hide line numbers
QuadratureEncoder.h
00001 /** 00002 * @file QuadratureEncodere.h 00003 * @brief this library allows the MCU to intepret the signal coming from a quadrature encoder. 00004 * @author Lupo Manes 00005 * @date 24/07/2017 00006 */ 00007 #ifndef _QUADRATUREENCODER_H_ 00008 #define _QUADRATUREENCODER_H_ 00009 00010 #include "mbed.h" 00011 /** QuadrtureEncoder class. 00012 * Used to interface with quadrature encoder. 00013 */ 00014 class QuadratureEncoder 00015 { 00016 public: 00017 /** Create QuadratureEncode instance 00018 * @param pinA Pin to which is connected channel A of the encoder 00019 * @param pinB Pin to which is connected channel Bof the encoder 00020 */ 00021 QuadratureEncoder(PinName pinA, PinName pinB); 00022 00023 /** Return the total number of pulses sent by the encoder. 00024 */ 00025 int getTicks(); 00026 /** Set the total number of ticks back to 0. 00027 */ 00028 void reset(); 00029 00030 private: 00031 void _Bfalling(); 00032 void _Brising(); 00033 InterruptIn _channelB; 00034 DigitalIn _channelA; 00035 int _ticks; 00036 }; 00037 00038 #endif
Generated on Thu Jul 21 2022 15:47:21 by
1.7.2