PDA

View Full Version : Rotary Encoder?



djsz
11-05-2012, 06:30 PM
It seems that the Encoder library linked from PJRC (http://www.pjrc.com/teensy/td_libs_Encoder.html) won't compile. Here are the errors using the example from the library:


...\libraries\Encoder/Encoder.h:59: error: ISO C++ forbids declaration of 'IO_REG_TYPE' with no type
...\libraries\Encoder/Encoder.h:59: error: expected ';' before '*' token
...\libraries\Encoder/Encoder.h:60: error: ISO C++ forbids declaration of 'IO_REG_TYPE' with no type
...\libraries\Encoder/Encoder.h:60: error: expected ';' before '*' token
...\libraries\Encoder/Encoder.h:61: error: 'IO_REG_TYPE' does not name a type
...\libraries\Encoder/Encoder.h:62: error: 'IO_REG_TYPE' does not name a type
...\libraries\Encoder/Encoder.h: In constructor 'Encoder::Encoder(uint8_t, uint8_t)':
...\libraries\Encoder/Encoder.h:80: error: 'struct Encoder_internal_state_t' has no member named 'pin1_register'
...\libraries\Encoder/Encoder.h:80: error: 'PIN_TO_BASEREG' was not declared in this scope
...\libraries\Encoder/Encoder.h:81: error: 'struct Encoder_internal_state_t' has no member named 'pin1_bitmask'
...\libraries\Encoder/Encoder.h:81: error: 'PIN_TO_BITMASK' was not declared in this scope
...\libraries\Encoder/Encoder.h:82: error: 'struct Encoder_internal_state_t' has no member named 'pin2_register'
...\libraries\Encoder/Encoder.h:83: error: 'struct Encoder_internal_state_t' has no member named 'pin2_bitmask'
...\libraries\Encoder/Encoder.h:90: error: 'struct Encoder_internal_state_t' has no member named 'pin1_register'
...\libraries\Encoder/Encoder.h:90: error: 'struct Encoder_internal_state_t' has no member named 'pin1_bitmask'
...\libraries\Encoder/Encoder.h:90: error: 'DIRECT_PIN_READ' was not declared in this scope
...\libraries\Encoder/Encoder.h:91: error: 'struct Encoder_internal_state_t' has no member named 'pin2_register'
...\libraries\Encoder/Encoder.h:91: error: 'struct Encoder_internal_state_t' has no member named 'pin2_bitmask'
...\libraries\Encoder/Encoder.h:91: error: 'DIRECT_PIN_READ' was not declared in this scope
...\libraries\Encoder/Encoder.h: In static member function 'static void Encoder::update(Encoder_internal_state_t*)':
...\libraries\Encoder/Encoder.h:373: error: 'struct Encoder_internal_state_t' has no member named 'pin1_register'
...\libraries\Encoder/Encoder.h:373: error: 'struct Encoder_internal_state_t' has no member named 'pin1_bitmask'
...\libraries\Encoder/Encoder.h:373: error: 'DIRECT_PIN_READ' was not declared in this scope
...\libraries\Encoder/Encoder.h:374: error: 'struct Encoder_internal_state_t' has no member named 'pin2_register'
...\libraries\Encoder/Encoder.h:374: error: 'struct Encoder_internal_state_t' has no member named 'pin2_bitmask'

Any ideas?

recri
11-11-2012, 06:33 AM
The problem is that the library needs to be rewritten for the Teensy 3.0, the list of boards supported is on the web page you linked.

The FlexTimer module (FTM) is described in chapter 35 of the processor reference manual. It has hardware support for quadrature decoding.

PaulStoffregen
11-18-2012, 08:00 PM
Please see this thread regarding the Encoder library.

http://forum.pjrc.com/threads/610-Teensy-3-Encoder-Lib