It’s the Wires, Dummy

After doing some reading this week, I discovered a few additional ways to check if the encoders are working properly:

  1. Use the Analog Input pins on the Arduino to see what voltage the encoder outputs on high and low signals. It will give an idea of what the voltage is across a range of rotation speeds.
  2. Use a potentiometer as a pullup or pulldown resistor to bring the high signal higher or the low signal lower if they end up not being high enough. This lets you determine a good resistance value to use.

Checking the encoder signal voltage with the Arduino revealed that the low signal was 0.00V, and the high signal was in the neighborhood of 4.38 to 4.71V depending on the speed the encoder rotates at. I would expect this out of two $60 encoders, and it’s in line with the datasheet, although a little lower than the advertised 4.5V. So I don’t see any need to use pullup resistors to differentiate between the high and low outputs.

So taking a step back, the encoder symptoms are:

  1. When both left and right wheels rotate in the same direction at a static speed of ~90RPM, the rpm1 and rpm2 values in Mission Planner randomly oscillate between positive and negative numbers, but roughly equal in magnitude.
  2. Rotating one wheel by itself causes both rpm1 and rpm2 values to oscillate around zero RPM.
  3. Both encoders function normally when plugged into the Arduino.

Come to think about it, if the A and B signals are cross wired, that would cause the behavior described above. You’d be sending the A signal from two separate encoders into the A and B inputs on the Pixhawk, which would explain the random positive and negative switches, and the otherwise random magnitude RPM values I was seeing. Quadrature encoders work by measuring a predictable state change in the A and B channels, and cross wiring the A signal output on encoder 1 with the B signal input would cause chaos.

But I always wire everything right the first time, so it can’t be that. No sir. Gotta be some really obscure with the hardware issue, or a problem with the Ardupilot code. Sarcasm, in case that wasn’t apparent.

Well after checking both of those issues, it turns out thereĀ was a wiring issue. I had the encoders wired through the power enclosure and then up into the control enclosure through the DB15 cable into the Pixhawk. Lots of places that wiring can be done incorrectly. And I had the A wire on encoder 1 cross wired into the B input for encoder 2. I need to start taking my own advice about troubleshooting.

After swapping wires, things worked wonderfully. In fact, after doing some brief autonomous testing in my backyard I decided to take the wheelchair robot up to the parking lot for some more thorough testing. I’ll have a writeup on that soon.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s