Motor is operated by keyboard commands, encoder reads out position but not yet speed
Dependencies: HIDScope
Dependents: Project_motor Project_motor Motor_poscontrol Conceptcontroller_v_1_0
Fork of Encoder by
Diff: encoder.h
- Revision:
- 4:69be34f39c9f
- Parent:
- 2:0998a8fd7727
- Parent:
- 3:dcb7bdc73882
- Child:
- 5:04c4a90c7a0a
--- a/encoder.h Mon Nov 04 09:56:06 2013 +0000 +++ b/encoder.h Mon Sep 29 15:51:28 2014 +0000 @@ -5,12 +5,14 @@ /** Encoder class. * Used to read out incremental position encoder. Decodes position in X2 configuration. * + * Speed estimation is very crude and computationally intensive. Turned off by default + * * Example: * @code * #include "mbed.h" * #include "Encoder.h" * - * Encoder motor1(PTD0,PTC9); + * Encoder motor1(PTD0,PTC9,true); * Serial pc(USBTX,USBRX); * pc.baud(115200); * while(1) { @@ -26,7 +28,8 @@ @param int_a Pin to be used as InterruptIn! Be careful, as not all pins on all platforms may be used as InterruptIn. @param int_b second encoder pin, used as DigitalIn. Can be any DigitalIn pin, not necessarily on InterruptIn location */ - Encoder(PinName pos_a, PinName pos_b); + + Encoder(PinName int_a, PinName int_b, bool speed=false); /** Request position @returns current position in encoder counts */ @@ -42,6 +45,7 @@ private: void encoderFalling(void); void encoderRising(void); + bool m_speed_enabled; Timer EncoderTimer; //Timeout EncoderTimeout; InterruptIn pin_a;