Connecting an n20 motor encoder to TB6612fng and arduino

I bought a 1:100 HP Micro Metal Gearmotor with the magnetic encoder from Pololu and was wondering how I can hook it up to a TB6612fng motor driver and then that to and arduino. I have looked online and can’t seem to find a diagram or tutorial on how to do so. I am new to electronics so can someone please show me how I can get it up and running?

Hello.

We do not have a specific diagram or tutorial for connecting those specific components, but for basic use of the driver you need the following connections:

  • 4.5 V to 13.5 V motor power to VMOT and GND
  • 2.7 V to 5.5V logic power (e.g. power from your Arduinio) to VCC and GND
  • Motor terminals to O1 and O2 (pick either the A or B channel)
  • Any Arduino I/O to corresponding IN1 and IN2 pins to control direction
  • Any Arduino I/O capable of generating PWM signals (i.e. pins that support the analogWrite() function) to corresponding driver PWM pin to control speed
  • Logic high voltage or any Arduino I/O to nSTBY (which must be driven high to enable the driver)

For more detailed information, I suggest reviewing the TB6612FNG datasheet, which is available on the driver carrier’s product page under the “Resources” tab. In particular, the “H-SW Control Function” table at the top of page 4 shows how to drive the pins for different functions.

As for the encoders, how you connect those depends on what particular Arduino you are using since it’s generally better to connect those to pins with interrupts. You might look at resources on Arduino’s “Reading Rotary Encoders” page for guidance.

- Patrick

Thanks

I am using an Arduino Uno.

Also do I have to use the pwn pins? I do not need speed control.

If you do not want to do speed control, you can connect PWMA and PWMB with non-pwm digital pins. You will have to give logic HIGH to enable these pins.

Alternatively, you could connect the driver’s PWM pin to a constant logic high voltage and use the IN1 and IN2 pins to control both direction and on/off per the “H-SW Control Function” table I mentioned in my earlier post.

- Patrick