Community
cancel
Showing results for 
Search instead for 
Did you mean: 
bbro
New Contributor I
1,224 Views

Uploading a sketch with Servo.h and Encoder.h gives compile errors

My robot uses Parallax motors and quadrature encoders. Originally I used an Uno and it ran fine with the Servo.h and Encoder.h included. Now I want to use my new Galileo2. Problem is, when I try to upload the following sketch:

//--------------------------------------------------------------------------------------

// Sweep Sample - Copyright (c) 2012 Dimension Engineering LLC

// See license.txt for license details.

# include

# include

// Change these pin numbers to the pins connected to your encoder.

// Best Performance: both pins have interrupt capability

// Good Performance: only the first pin has interrupt capability

// Low Performance: neither pin has interrupt capability

Encoder Left_Encoder(2, 4);

Encoder Right_Encoder(3, 5);

// avoid using pins with LEDs attached

Servo Left_Motor, Right_Motor, Actuator, Fans; // We'll name the Sabertooth servo channel objects Left Motor and Right Motor.

// For how to configure the Sabertooth, see the DIP Switch Wizard for

// http://www.dimensionengineering.com/datasheets/SabertoothDIPWizard/start.htm http://www.dimensionengineering.com/datasheets/SabertoothDIPWizard/start.htm

// Be sure to select RC Microcontroller Mode for use with this sample.

//

// Connections to make:

// Arduino Pin 9 -> Sabertooth S1

// Arduino Pin 10 -> Sabertooth S2

// Arduino GND -> Sabertooth 0V

// Arduino VIN -> Sabertooth 5V (OPTIONAL, if you want the Sabertooth to power the Arduino)

//

// Sabertooth accepts servo pulses from 1000 us to 2000 us.

// We need to specify the pulse widths in attach(). 0 degrees will be full reverse, 180 degrees will be

// full forward. Sending a servo command of 90 will stop the motor. Whether the servo pulses control

// the motors individually or control throttle and turning depends on your mixed mode setting.

// Notice these attach() calls. The second and third arguments are important.

// With a single argument, the range is 44 to 141 degrees, with 92 being stopped.

// With all three arguments, we can use 0 to 180 degrees, with 90 being stopped.

// the rest of the code here ...blah blah blah

blah blah blah

blah blah blah

//--------------------------------------------------------------------

, I get the following error

WARNING: library Servo claims to run on [i586-uclibc] architecture(s) and may be incompatible with your current board which runs on [i586] architecture(s).

In file included from C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:46:0,

from sketch_jan23a.ino:5:

C:\Users\username\Documents\Arduino\libraries\Encoder-master/utility/interrupt_pins.h:166:2: error: # error "Interrupts are unknown for this board, please add to this code"

C:\Users\username\Documents\Arduino\libraries\Encoder-master/utility/interrupt_pins.h:169:2: error: # error "Encoder requires interrupt pins, but this board does not have any :("

C:\Users\username\Documents\Arduino\libraries\Encoder-master/utility/interrupt_pins.h:170:2: error: # error "You could try defining ENCODER_DO_NOT_USE_INTERRUPTS as a kludge."

In file included from sketch_jan23a.ino:5:0:

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:61:11: error: 'IO_REG_TYPE' does not name a type

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:62:11: error: 'IO_REG_TYPE' does not name a type

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:63:2: error: 'IO_REG_TYPE' does not name a type

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:64:2: error: 'IO_REG_TYPE' does not name a type

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:135:50: error: 'CORE_NUM_INTERRUPT' was not declared in this scope

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h: In constructor 'Encoder::Encoder(uint8_t, uint8_t)':

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:82:11: error: 'struct Encoder_internal_state_t' has no member named 'pin1_register'

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:82:46: error: 'PIN_TO_BASEREG' was not declared in this scope

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:83:11: error: 'struct Encoder_internal_state_t' has no member named 'pin1_bitmask'

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:83:45: error: 'PIN_TO_BITMASK' was not declared in this scope

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:84:11: error: 'struct Encoder_internal_state_t' has no member named 'pin2_register'

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:85:11: error: 'struct Encoder_internal_state_t' has no member named 'pin2_bitmask'

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:92:31: error: 'struct Encoder_internal_state_t' has no member named 'pin1_register'

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:92:54: error: 'struct Encoder_internal_state_t' has no member named 'pin1_bitmask'

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:92:66: error: 'DIRECT_PIN_READ' was not declared in this scope

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:93:31: error: 'struct Encoder_internal_state_t' has no member named 'pin2_register'

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:93:54: error: 'struct Encoder_internal_state_t' has no member named 'pin2_bitmask'

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:93:66: error: 'DIRECT_PIN_READ' was not declared in this scope

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h: In static member function 'static void Encoder::update(Encoder_internal_state_t*)':

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:271:40: error: 'struct Encoder_internal_state_t' has no member named 'pin1_register'

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:271:60: error: 'struct Encoder_internal_state_t' has no member named 'pin1_bitmask'

C:\Users\username\Documents\Arduino\libraries\Encoder-master/Encoder.h:271:72: error: 'DIRECT_PIN_READ' was not dec...

6 Replies
bbro
New Contributor I
98 Views

Hi All

After further study it appears its just the Encoder.h that is giving the errors.

Is there an updated Encoder.h that is compatible with the Galileo2?

Thanks

RoboBill

Diego_V_Intel
Employee
98 Views

Hello RoboBill,

Some of the projects that run perfectly fine in Arduino UNO don't work in Galileo because the libraries used are based on the AVR architecture. Some Arduino libraries have been written based on the registers and architecture of the Arduino MCU. Since the Galileo has different architecture, the sketches won't compile.

In this case, the Encoder library doesn't seem to be Galileo compatible because it has references to registers that don't exist in Galileo. Unfortunately there isn't a version of this library compatible with Galileo. My recommendation for you is to try to write a library for the encoder based on the Arduino library and the encoder functionality.

Regards,

Diego.

bbro
New Contributor I
98 Views

Good morning Diego,

Thanks for the clarification to my suspicions. Unfortunately I have very little experience writing Arduino code so libraries are way over the top. I will continue to look online.

BR

RoboBill

bbro
New Contributor I
98 Views

Diego,

Could I use the RotaryEncoder.h instead?

Thanks

RoboBill

Diego_V_Intel
Employee
98 Views

Hi RoboBill,

I'm not familiar with that library, but you could do a quick test to know if it works. Just try to compile a sketch that uses that library. If there are errors during compilation the library might be written based on AVR architecture.

Regards,

Diego.

bbro
New Contributor I
98 Views

Hi Diego,

Well I successfully compiled the SimplePollRotator example which includes the RotaryEncorder.h,

I believe this might be the library for your https://software.intel.com/en-us/iot/hardware/sensors/grove-rotary-encoder Grove rotary encoder.

Whether it will work with my Parallax quad encoders remains to be seen

Many thanks,

RoboBill

Reply