3

Short version of question: I bought one of these: http://imall.iteadstudio.com/im120606013.html and am trying to figure out how to get it going with the Raspi. I have some assumptions about how it should be connected, but I am not 100% sure, and I'm looking for confirmation.

There are three power pins: VIN, GND, and +5V. I think VIN should be connected to the positive terminal of my 12V battery, the +5V should be connected to a +5V pin on the Raspi, and the GND should be connected to both a GND on the Raspi and the negative battery terminal. Is that correct?

There are four input pins: IN1-4. I believe these can be connected straight to any GPIO pin. Then above those there are four pins, an ENA, +5V, +5V, ENB. There is a jumper between each EN and one of the +5Vs there.

Then the four output pins on the side would go to the two terminals of both motors.

Is this all correct?


The longer version of the question: I am going through the O'Reilly book Make A Raspberry Pi Controlled Robot. Googling for that, rather shockingly I could not find any forum threads where people were trying to follow the instructions in the book and discussing them. Frankly I think the book is a bit vague in places. I know some about electronics but am by no means a guru.

The book actually recommended getting this for the motor controller: https://www.sparkfun.com/products/9670 I think that what I bought is about the same as this (much cheaper) but I am not fully sure. I would have purchased that, but it was out of stock when I ordered what I did, so I had to search elsewhere. I am thinking it might contain extra protection circuitry but it is not clear how I would modify my own connections to use the one I bought rather than this.

Thank you!

2
  • 1
    I use this model. I've seen no evidence that spending more buys a better product.
    – joan
    Mar 7, 2015 at 21:59
  • you need a lot of amps use a pc power supply for testing ... not when spend days trying to fix code when just a fulty battery of is flat
    – user98216
    Jan 31, 2019 at 5:18

1 Answer 1

3

Pretty much correct.

Connect battery +ve to VIN, battery -ve to GND. Don't connect +5V to the Pi, leave it unconnected. Do connect GND also to a Pi ground.

Connect IN1/2/3/4 to four gpios of your choice. It won't do any harm to have a in-line 1k resistor for each if you are paranoid. Leave the ENA/ENB jumpered to 5V so each motor is enabled.

Set IN1/2 to 0/1 to drive motor A in one direction, to 1/0 to drive in the other. Similarly for IN3/4 to drive motor B.

3
  • Ok thanks. As for the +5V connection, the book does say to connect it to the Pi, but I saw some conflicting advice in on thread talking about the L298. Under what circumstances should that be connected? Also the book notes to wire another GPIO to each of ENA and ENB, but that seems unnecessary here with the hard wired jumper. I'll hold off accepting pending other possible answers and actually trying it, which might be a couple days. :) Mar 7, 2015 at 22:03
  • 1
    The 5V from the module is really intended to feed power into the Pi, where it will fight with the Pi's own 5V supply. There is normally a jumper on the module to derive 5V from the motor supply. Try it without. You can use ENA/ENB to control the motor speed using PWM. But you can do the same by applying PWM to IN1/2/3/4 instead (ENA/ENB PWM is arguably more efficient). For interest see my experiment at raspberrypi.org/forums/viewtopic.php?f=37&t=90243
    – joan
    Mar 7, 2015 at 22:13
  • Sorry for the long delay. Lots of things delayed getting back to this (including the fact that I suck at physical construction of stuff). I didn't actually get it to work with the intended motor - the heatsink got very hot and nothing else happened. But I did get it to work with a smaller motor, so I believe this answer is correct as far as the L298 connections go. Thanks! Oct 10, 2015 at 18:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.