Help getting these ir sensor working

So, I bought an old robot that is based on a 1/10 RC car. It has optical encoders - in total, there are 5: 4 for each wheel and 1 for the motor. I would like to connect them to an Arduino somehow, but I have no idea where to start. The original proprietary controller, which the robot would have had from the factory, didn’t come with it. Any help is greatly appreciated



Can you post a schematic of the sensors or at least a make and model number.

it's all proprietary. The company never released any files or schematics

I'm assuming you have an Uno.

From the pictures, each sensor has a GND, VCC, CHA and CHB. So, without much effort, I deduce that you might connect GND to the Arduino GND, VCC to the Arduino +5V, and CHA and CHB to, for example, pins 2 and 3, then write a small program to, maybe, output the state of CHA and CHB to Serial Monitor, then try to cause the inputs to change state.
I'd hook one up to begin with, since they're all identical.

Good luck.

Two years ago, I used a basic code to connect it to my Uno, but I never got consistent results. It would be very sporadic, jumping from single digits to triple digits. So, it was shelved until now, when I will have some more time to dedicate to the project.

Just noted the "ENC-100" designator in the part number. Makes me think it's actually some form of encoder providing a quadrature signal based (perhaps) on some surface irregularity on the wheels of the device. That would make me think that you might not get any useful signal, unless the sensor were pointed at (gasp) a surface with that irregularity. So not a surprise you got nothing worthwile.

The encoder wheel is perfectly flat and the distance from the sensor doesn't change since it is all bolted together. But even then those numbers would be all over the place.

What "numbers"? Did you use a code capable of capturing quadrature encoder signals? If you look at CHA and CHB with an oscilloscope as the wheel is turning, you'll see two square waves, 90 degrees out of phase. There seems to be much you're not telling us about prior testing, etc. Why is that?

1 Like

Because you haven’t asked, how can I tell you about something you haven’t asked about? Other than just saying I’ve done simple testing before. Why are you assuming something is intentionally being hidden?
I think this was the code I used:

const int pinA = 2; // CHA connected to pin 2
const int pinB = 3; // CHB connected to pin 3

volatile int encoderPos = 0;
int encoderPinALast = LOW;

void setup() {
  pinMode(pinA, INPUT);
  pinMode(pinB, INPUT);
  attachInterrupt(digitalPinToInterrupt(pinA), updateEncoder, CHANGE);
  Serial.begin(9600);
}

void loop() {
  Serial.println(encoderPos);
  delay(1000);
}

void updateEncoder(){
  int MSB = digitalRead(pinA); //MSB = most significant bit
  int LSB = digitalRead(pinB); //LSB = least significant bit

  int encoded = (MSB << 1) |LSB; //converting the 2 pin value to single number
  int sum  = (encoderPinALast << 2) | encoded; //adding it to the previous encoded value

  if(sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011) encoderPos ++;
  if(sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000) encoderPos --;

  encoderPinALast = encoded; //store this value for next time
}

well, for what it's worth, because you said:

But that's okay. I'm on my way. Cheers!

I said ‘them’ as in plural meaning multiple which still stands as true. I don’t know how to connect multiple of them to an Arduino. Finding a basic code to test something is not the same as being able to hook up multiples of something and get it all working together.

I will guess those photos are of transceivers. The two dots in the plastic are TX and RX, probably IR. Anything very close, with encoded knockouts, moving past will cause a pulse. Perhaps CHA is TX and CHB is RX, or the reverse.

Hi, @PicoSavvy

Can you please post some pictures of what the sensors were looking at?
The wheel or marker on the wheel, what surface were they detecting?

Do you have a DMM? (Digital MultiMeter)

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.