H-Bridge Motor Controller Connection to Raspberry Pi

H-Bridge Motor Controller Connection to Raspberry Pi

We can use Raspberry Pi to drive 2 powerful motors with a help of H-Bridge Motor Controller chip.  This IC works a lot like Darlington transistor array for driving motors, except is allows for reverse motion.   The battery used is 7.4V Lithium Ion pack or 4xAA battery box.  The diagram below shows SN754410 H-Bridge controller connection to Raspberry Pi, it is broken down into 4 steps for clarity:

This IC has 16 pins:

1 – Motor 1 enable

2 – Motor 1 forward

3 – Motor 1 Out A

4 – Ground

5 – Ground

6 – Motor 1 Out B

7 – Motor 1 reverse

8 – Motor Power

9 – Motor 2 Enable

10 – Motor 2 Forward

11 – Motor 2 Out A

12 – Ground

13 – Ground

14 – Motor 2 Out B

15 – Motor 2 Reverse

16 – +5V Control

Connections 1

  • Connect ground pins 4, 5, 12 and 13 together
  • Connect control and enable pins, 1, 9 and 16 together

H-Bridge_connection1

Connections 2

  • Connect motor 1 out pins 3 and 6 to the first motor.
  • Connect motor 2 out pins 11 and 14 to the second motor.

H-Bridge_connection2

Connections 3

  • Connect battery negative terminal to any ground pin 4, 5, 12, 13 (they should be tied together now)
  • Connect Raspberry Pi pin 6 (ground) to any ground pin 4, 5, 12, 13 (they should be tied together now)
  • Connect battery positive terminal to pin 8
  • Connect Raspberry Pi pin 2 (+5 Volts) to pin 1 (or 9, or 16)

H-Bridge_connection3

Connections 4

  • Connect Raspberry Pi pin 11 to Motor 1 forward (pin 2)
  • Connect Raspberry Pi pin 12 to Motor 1 backward (pin 7)
  • Connect Raspberry Pi pin 15 to Motor 2 backward (pin 15)
  • Connect Raspberry Pi pin 16 to Motor 2 forward (pin 10)

H-Bridge_connection4

——-

Scratch

Variables:

  • Motor 11 – Right motor forward
  • Motor 12 – Right motor back
  • Motor 15 – Left motor forward
  • Motor 16 – Left motor back
  • speedForward – speed while moving forward (0 to 100)
  • speedBack – speed while moving in reverse (0 to 100)
  • forward – indicator if we are moving forward (1) or reverse (0)

 

hbridge