Pages: [1]   Go Down
Author Topic: Errors with AdaEncoder  (Read 801 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 1
Posts: 109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
// 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!

« Last Edit: June 30, 2013, 07:16:18 pm by warren631 » Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Full Member
***
Karma: 1
Posts: 109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 653
Posts: 50912
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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:
#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.
Logged

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 48
Posts: 2935
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: July 01, 2013, 05:46:52 am by Docedison » Logged

--> 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

Offline Offline
Full Member
***
Karma: 1
Posts: 109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. 
Logged

0
Offline Offline
Jr. Member
**
Karma: 4
Posts: 94
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

Pages: [1]   Go Up
Jump to: