Converting Quadrature Encoder signals to 3 channel Hall sensor

Hi I am trying to use a Seeduino XIAO RP2040 to convert a quadrature encoder signal into a simple 3 channel rotational hall sensor. The first problem I have ran into is that the board will not pick up the output signal from the encoder.

I verified the problem using the following basic code:


// Test that the pins are being read correctly

void setup() {
  //start serial connection
  Serial.begin(9600);
  //configure pin 7
  pinMode(7, INPUT);
}

void loop() {

  // Read pin and store value
  int sensorVal = digitalRead(7);

  // If pin is High print 1
  if (sensorVal == HIGH) {
    Serial.println("1");
  }
}

When rotating the encoder by hand I can confirm, with an oscilliscope, that the pin is getting approximately 5v for a brief moment as the encoder rotates. Unfortunately when running this code the board never recognizes the input and nothing prints to the screen when I turn the encoder by hand.

Is there a problem with my code?

The signal is only on for about 500 microseconds, is that too short of a time to be picked up?

No, that is plenty of time for the Arduino to see it, using the code you posted. Something else must be wrong, like forgetting to connect the grounds.

Please post a link to the quadrature encoder and a hand drawn wiring diagram.

the pin is getting approximately 5v

The Seeeduino Xiao RP2040 is a 3.3V processor, and will be destroyed if you apply 5V to an I/O pin.

Oh then I must have fried the processor because I have been trying to use it with a 5V signal. I'm surprised because I have seen this same board wired directly to a 5V encoder signal with an off the shelf wiring harness, there were no resistors in series.

You can see all sorts of bad ideas on the web.

The Seeeduino Xiao seller is responsible, and put this warning right on the product web page.

Yeah for some reason because it is powered by 5V I assumed the pins could handle 5V. I think maybe they were using the analog pins in the applications I have seen. The analog pins can handle 5V, correct?

No, not on a 3.3V processor. "All the I/O pins" includes analog pins.

I'd try adding:

if (sensorVal == LOW) {
    Serial.println("0");

so you can see each state.

That's strange because the chip used is in this product:

I have measured 5 volts off of the encoder. I have opened one up and there are no resistors between the encoder wires and the I/O pins on the board. Is it possible it works but isn't recommended? The reason I bought this particular board is because it is the same one used in another 5V encoder converter.

NEVER connect 5V to ANY pin on a 3.3 processor, unless the processor data sheet EXPLICITLY states that this is allowed.

The data sheet will very clearly state "5V tolerant I/O pins".

If it does not, assume that sooner or later, the processor will be destroyed if you do this.

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