Logic Level Shifter for reading motor encoders

I am building a 2 wheel balancing robot and my design has been heavily inspired by https://www.youtube.com/watch?v=fFwkQZr8wnQ

I am using the following components:

  • 2x Pololu 30:1 Metal Gearmotor 37Dx68L mm 12V with 64 CPR Encoder
  • 2x Pololu VNH5019 Motor Driver
  • 2x Wild Thumper wheels
  • Pololu Logic Level Shifter
  • Arduino Nano 33 IoT microcontroller
  • 3x 18650 batteries in serial

The Arduino Nano 33 IoT runs on 3.3V, and I was originally planning to use 3.3V as the logic level for everything in the robot. However, I noticed that the minimum Vcc for the motor encoder is 3.5V. I assume that this is accurate, and I assume that 3.5V would be too high for the input pins on the Nano.

The solution I have in mind is to use 5V as Vcc for the motor driver, then use the Pololu Logic Level Shifter to translate the 5V signal from the encoder to the 3.3V level for the Nano. I believe that the level shifter should be fast enough to handle the encoder signals. The encoder signals each have 16 pulses per revolution, and the motor maximum speed is 10,000 rpm skills. If my math is right, that equates to 160kHz, and the level shifter can handle 400kHz.

First question: Is there another solution besides the level shifter that I haven’t thought of? Second question: Is the logic level shifter fast enough for the encoder signals?


Instead of using a logic level shifter, you could also just use appropriate voltage dividers on the encoder outputs, but if you decide to use the logic level shifter, that would be fast enough to handle the encoder signals.

By the way, the maximum frequency should be about 2.7kHz (well within the limits of what the level shifter can handle). In case you are interested, here is how I calculated that:

Max motor speed = speed • gear ratio = 330rpm • 30 = 9900rpm = 165rps

encoder pulses per rotation per channel = 64cpr / 2 channels / 2 counts per pulse (high and low) = 16 pulses per rotation

frequency = Max motor speed • encoder pulses per rotation per channel = 165rps • 16 pulses per rotation = 2640Hz = 2.64kHz

(I suspect your error might have been using speed in rpm rather than rps in the last equation.)

- Patrick

Haha - rpm instead of rps is just the kind of error I used to make in university exams! Thanks for pointing this out. I already purchased the level shifter at the same time as the other components, so I’ll just use that. But now I know its speed is more than adequate.

Thanks for your help!

And as a side note, I love the Lego space man next to the level shifter on the product page. As an Australian, I found it easier to see how tiny the level shifter is :slight_smile:

1 Like