Go Down

Topic: Errors with AdaEncoder (Read 878 times) previous topic - next topic

warren631

Jul 01, 2013, 01:55 am Last Edit: Jul 01, 2013, 02:16 am by warren631 Reason: 1
I am looking for an encoder library so I tried AdaEncoder and got the following compile errors when trying the AdaEncoder example.  

I need to add speed feedback to two geared robot wheel motors which turn slowly (10 rpm).  I can't add an encoder on the high speed motor shafts before the gears.  I need to get accurate speed based upon a fraction of a rotation.  What encoder library can provide speed based on measuring the TIME BETWEEN pulses rather than just COUNTING pulses?

AdaEncoder compile errors:
Quote
MyEncoder:1: error: 'ByteBuffer' does not name a type
MyEncoder:10: error: no matching function for call to 'AdaEncoder::AdaEncoder(char, int, int)'
C:\Documents and Settings\Warren\My Documents\Arduino\libraries\AdaEncoder/AdaEncoder.h:160: note: candidates are: AdaEncoder::AdaEncoder()
C:\Documents and Settings\Warren\My Documents\Arduino\libraries\AdaEncoder/AdaEncoder.h:129: note:                 AdaEncoder::AdaEncoder(const AdaEncoder&)
MyEncoder:11: error: no matching function for call to 'AdaEncoder::AdaEncoder(char, const uint8_t&, const uint8_t&)'
C:\Documents and Settings\Warren\My Documents\Arduino\libraries\AdaEncoder/AdaEncoder.h:160: note: candidates are: AdaEncoder::AdaEncoder()
C:\Documents and Settings\Warren\My Documents\Arduino\libraries\AdaEncoder/AdaEncoder.h:129: note:                 AdaEncoder::AdaEncoder(const AdaEncoder&)
MyEncoder.ino: In function 'void loop()':
MyEncoder:24: error: 'printBuffer' was not declared in this scope
MyEncoder:26: error: cannot convert 'encoder*' to 'AdaEncoder*' in assignment
MyEncoder:28: error: 'class AdaEncoder' has no member named 'getID'
MyEncoder:29: error: 'class AdaEncoder' has no member named 'query'
MyEncoder.pde: At global scope:
MyEncoder:9: error: redefinition of 'int8_t clicks'
MyEncoder:13: error: 'int8_t clicks' previously defined here
MyEncoder:10: error: redefinition of 'char id'
MyEncoder:14: error: 'char id' previously defined here
MyEncoder.pde: In function 'void setup()':
MyEncoder:12: error: redefinition of 'void setup()'
MyEncoder:16: error: 'void setup()' previously defined here
MyEncoder.pde: In function 'void loop()':
MyEncoder:19: error: redefinition of 'void loop()'
MyEncoder:21: error: 'void loop()' previously defined here

The Adaencoder example code:
Code: [Select]
// Version 1.1: OO version
#include <ByteBuffer.h>
#include <ooPinChangeInt.h> // necessary otherwise we get undefined reference errors.
#define DEBUG
#ifdef DEBUG
ByteBuffer printBuffer(200);
#endif
#include <AdaEncoder.h>

#define ENCA_a 2
#define ENCA_b 3
#define ENCB_a A3
#define ENCB_b A4

AdaEncoder encoderA = AdaEncoder('a', ENCA_a, ENCA_b);
AdaEncoder encoderB = AdaEncoder('b', ENCB_a, ENCB_b);

int8_t clicks=0;
char id=0;

void setup()
{
 Serial.begin(115200); Serial.println("---------------------------------------");
}

void loop()
{
 char outChar;
 while ((outChar=(char)printBuffer.get()) != 0) Serial.print(outChar);
 AdaEncoder *thisEncoder=NULL;
 thisEncoder=AdaEncoder::genie();
 if (thisEncoder != NULL) {
   Serial.print(thisEncoder->getID()); Serial.print(':');
   clicks=thisEncoder->query();
   if (clicks > 0) {
     Serial.println(" CW");
   }
   if (clicks < 0) {
      Serial.println(" CCW");
   }
 }
}


Thanks for any help!


PeterH

You would need to read the inputs from the encoder to determine when movement events had occurred - either using a library, or by writing your own code. Once you are capable of detecting movement events, measuring the elapsed time between successive events is relatively easy to code.
I only provide help via the forum - please do not contact me for private consultancy.

warren631

Yes. I understand. Thanks.  I'm still looking for a 'slow' encoder library for slow wheels.

PaulS

Start at the top of the list of messages.
Quote
MyEncoder:1: error: 'ByteBuffer' does not name a type

Look at the code that triggers that error:
Code: [Select]
#ifdef DEBUG
ByteBuffer printBuffer(200);
#endif

So, you need to backtrack to determine where ByteBuffer should be defined. It is NOT a native type, like int, float, etc., so there needs to be a header file that defines it.

Code: [Select]
#include <ByteBuffer.h>
Aha, this looks like a reasonable candidate. Since, for some (probably really stupid) reason, missing include files are no longer considered fatal errors (they are, absolutely), it is reasonable to assume that you did not download and install this library in the proper place, or that you did not restart the IDE after doing so.

Docedison

#4
Jul 01, 2013, 12:40 pm Last Edit: Jul 01, 2013, 12:46 pm by Docedison Reason: 1
A quad encoder is relatively simple to make. Create your own photomask whether by holes or reflective/non-reflective materials and set the required resolution there... Much easier than finding a particular piece of code.
The encoder might well be a piece of paper or plastic film with the appropriate pattern printed on it and affixed to the drive shaft being measured.
There are many tutorials on the subject so applicable or adaptable construction information is readily available from Mr Google, You do know him?

Doc

Edit: You might also consider gearing a 'regular' rotary encoder. Gear up the encoder and use 'normal' code. You could also measure the motor before the gearing and use the gear ratio as the 'magic' number to convert to wheel position
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

warren631

I found the compiling problem: It seems that I must move any examples (such as the AdaEncoder examples which were downloaded with the library zip file) into ..\my documents\arduino\ then the examples compile properly.  They don't compile properly if I leave the downloaded library examples under the library directory as they were zipped.  I had not noticed this problem before updating to 1.0.5. 

GreyGnome

Sounds like you got it figured out.

You don't need ByteBuffer to work with AdaEncoder. That's just for me to work with my test code and such. Using it is really an exercise for the programmer; I just include it to be complete. Plus, it's kind of interesting.

You should probably remove the #include from your code, as it's not necessary. (unless you need a ByteBuffer).

Go Up