Wheel Encoder lighting?

Hello, I’m having problems getting good data from the Pololu wheel encoders because it seems they depend on very precise infra-red lighting. I need to get the exact right angle of light to get evenly to both A & B outputs of each encoder aswell as the perfect amount of light (not too much, not too little) so the sensors even work properly.

Tricky business so far! I’m wondering if anyone has had any luck with getting these to work properly, and if so, how were they lit??

Thanks muchly,
Thomas.

Hello,

Can you clarify what you are trying to do? Do you have our encoder as well as the 42mm wheels, or are you trying to use the encoder with some kind of custom wheels? Are you saying that you have to supply some kind of external light source for some reason?

-Paul

I am using them to make a MIDI instrument. Am using the Pololu 42mm wheels, and I presumed the encoders need an external light source because they don’t work properly without one… if it’s too dark they send only 1’s, too much light only 0’s, etc… Are they supposed to function without external lighting??

Yes, they work without external lighting. Can you describe exactly how you have them connected?

-Paul

Hello.

Just to expand a bit on Paul’s response, you can see from the schematic that the two infrared reflectance sensors on the board each consist of an IR LED (emitter) and phototransistor (detector). They produce their own light and detect the reflections from the wheel teeth.

- Ben

Hmm, well that sounds promising…

Any reasons why the emitters might not be working? I have the encoders connected to an ArduinoMega (5V, GND & two digital pins for A & B)

You can check to see if the IR LEDs are on using an inexpensive digital camera (one that doesn’t have an IR filter) such as those commonly found on cell phones. See the description and picture at the bottom of our IR beacon page for more information.

How confident are you in your code? Can you post a picture of your setup? Have you ever adjusted the pots on the board?

- Ben

OK, so the emitters seem to be working as there is just a faint white glow to them when viewed through my cellphone.

Here is my code I am testing them with:

int valM1A = 0; //stores the state of the input pins
int valM1B = 0;

int WHEELM1A = 5;
int WHEELM1B = 6;

void setup()
{
  pinMode(WHEELM1A, INPUT); //sets digital pins as inputs
  pinMode(WHEELM1B, INPUT); 
  Serial.begin(9600);
}

void loop()
{
  valM1A = digitalRead(WHEELM1A); //read input value and store it
  valM1B = digitalRead(WHEELM1B);
  Serial.print ("1A: ");
  Serial.println(valM1A);
  Serial.print ("1B: ");
  Serial.println(valM1B);
  delay(100);  
}

I noticed in the IR Beacon info you mentioned it says “Supply voltage: 6-16 V” - is this supposed to be coming from my computer’s USB port? If so that may be the problem as I don’t think they output that amount of voltage…? Also, I have never adjusted the pots on my board and can’t post a picture sorry!

Thanks for your help on this!

I mentioned looking at the “bottom” of the IR beacon page as a way to get more information about using a camera to tell if your IR LEDs are working. The IR beacon specifications are not relevant to your encoder, which is an entirely different product. Have you read the encoder product page?

Are you actually spinning the wheel while your code is running?

I suspect you might have the board mounted incorrectly or connected incorrectly; a picture would really help us tell. Our forum lets you upload pictures, so all you need is a digital camera. Can you verify that your encoder is mounted exactly as shown in this picture?

- Ben

Here are some pics of the setup. No motor, I’ve drilled out the middle of the wheels to add ball-bearings and mounted them on brackets as you can see…



Hello,

You could have saved a lot of time by telling us about your non-standard setup when you asked your original question!

The encoder depends on precise alignment with the wheels. Getting out of alignment by a fraction of a millimeter could definitely cause the incorrect operation that you are seeing, and from the pictures I can see that you are very far off.

I think that people who do not need a motor typically use a rotary encoder with a built-in shaft - search Google for “rotary encoder” and you will probably find a lot of options that will work much better for you than our encoders.

-Paul

Drat and double drat! Thanks for the help