hades1989
Posts: 16
Joined: Wed Mar 12, 2014 2:28 am

]Raspberry Pi + L298N H-Bridge + HC-SR04

Mon May 05, 2014 3:42 pm

Hi, I tried to connect Raspberry Pi + L298N H-Bridge + HC-SR04 ultrasonic sensor together, when the sensor sense obstacle the car will stop moving and turn around.

The problem is, there is something wrong with the motor, when i set it to move forward, one of the motor like wont move, unless i use my hand to turn it, then it starts moving, and im not sure my design of the entire circuit is correct or not, so im posting up the design here to discuss

In the picture, those numbers besides those connectors are GPIO.BOARD numbering, i did not draw out the cables for all because it will be very messy, instead i wrote the pin number connected beside, and instead of using battery pack to power the robot, i used 5v PowerBank to provide power from the micro usb in raspberry pi for the entire circuit.

Thanks

http://postimg.org/image/ox4rl2bep/
Last edited by hades1989 on Mon May 05, 2014 3:48 pm, edited 1 time in total.

User avatar
joan
Posts: 14998
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04

Mon May 05, 2014 3:47 pm

There are only 2 enable pins on an L298N. You seem to have four gpios connected. Best to switch it off and post a photo of your motor driver board.

hades1989
Posts: 16
Joined: Wed Mar 12, 2014 2:28 am

Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04

Mon May 05, 2014 3:57 pm

joan wrote:There are only 2 enable pins on an L298N. You seem to have four gpios connected. Best to switch it off and post a photo of your motor driver board.
oh? because i watched from this video [Mod Removed link - video wrong] to learn how to connect my pi to L298N (but i didnt connect the powerpack like him), and there is 2 pins in ENA A and another 2 pins in ENA B

http://postimg.org/image/8ylajej0v/

User avatar
joan
Posts: 14998
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04

Mon May 05, 2014 4:04 pm

There are two enable pins (in the same row as IN1/2/3/4). The offset pins are jumper pins so you can jumper the enable lines high. Get a meter and check the voltage on the jumpers. It's only safe to connect 3.3V or less to the Pi.

hades1989
Posts: 16
Joined: Wed Mar 12, 2014 2:28 am

Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04

Mon May 05, 2014 4:17 pm

joan wrote:There are two enable pins (in the same row as IN1/2/3/4). The offset pins are jumper pins so you can jumper the enable lines high. Get a meter and check the voltage on the jumpers. It's only safe to connect 3.3V or less to the Pi.

Hi, i checked the voltage on the jumpers with meter (the 2 pins below the enabled pins), but that is weird, because it shows 0 v ( i already powered it on), by the way, i already remove the cable from the jumpers, and the robot is still working.

User avatar
joan
Posts: 14998
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04

Mon May 05, 2014 4:24 pm

Does the board look like this?
mdb-a.gif
mdb-a.gif (48.92 KiB) Viewed 4928 times

hades1989
Posts: 16
Joined: Wed Mar 12, 2014 2:28 am

Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04

Mon May 05, 2014 4:28 pm

joan wrote:Does the board look like this?
mdb-a.gif
Yup correct, exactly look like this

User avatar
joan
Posts: 14998
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04

Mon May 05, 2014 4:36 pm

The pins circled in red should never be connected to the Pi.

If there is a jumper fitted in the pink position do not connect the Pi's 5V pin to the motor driver board's logic supply.

hades1989
Posts: 16
Joined: Wed Mar 12, 2014 2:28 am

Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04

Mon May 05, 2014 4:47 pm

joan wrote:The pins circled in red should never be connected to the Pi.

If there is a jumper fitted in the pink position do not connect the Pi's 5V pin to the motor driver board's logic supply.
i already removed the cables from Pi to the pins circled in red, i didnt connect any cables from Pi to the pink position (logic power jumper), i just left it there. So should i remove the connection (cable from 5v pin in Pi toLogic Supply 5v in motor driver board)? After i remove it how should the Pi power the motor driver board?

User avatar
joan
Posts: 14998
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04

Mon May 05, 2014 4:56 pm

Never connect anything between the Pi and the pink position. The jumper either is present (connecting the motor supply to the logic supply) or absent.

Normally leave the jumper in the pink position and do NOT connect anything to the logic supply terminal (rightmost of screw terminal block).

Connect the positive of your battery to the power supply terminal (leftmost of screw terminal block). Connect the battery negative and a Pi ground to the ground terminal (centre of screw terminal block).

User avatar
SavagePi
Posts: 42
Joined: Mon Mar 31, 2014 7:34 pm
Location: Staffordshire, England

Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04

Mon May 05, 2014 4:58 pm

I'm using the very same L298N PCB.

Here's a photo of my connections.

I've removed the two links (En1 & En2) that normally enable the motors because I control those myself.

Apart from the 6 control signals, you'll notice I've linked the 0V connection back to the Pi (this is the most essential connection, without it, you'll get the most erratic results).

Hope this helps.
Attachments
L298N connections.JPG
L298N connections.JPG (47.59 KiB) Viewed 4883 times
Electronics... It's what I do!

hades1989
Posts: 16
Joined: Wed Mar 12, 2014 2:28 am

Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04

Mon May 05, 2014 5:07 pm

joan wrote:Never connect anything between the Pi and the pink position. The jumper either is present (connecting the motor supply to the logic supply) or absent.

Normally leave the jumper in the pink position and do NOT connect anything to the logic supply terminal (rightmost of screw terminal block).

Connect the positive of your battery to the power supply terminal (leftmost of screw terminal block). Connect the battery negative and a Pi ground to the ground terminal (centre of screw terminal block).
Hi, but i didnt use any battery pack to power my Pi, i use these types of power bank to power my robot from the Pi itself, if this is the case how should i connect?
http://60.76.my/public/uploads/deal/dua ... 000mAh.jpg

hades1989
Posts: 16
Joined: Wed Mar 12, 2014 2:28 am

Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04

Mon May 05, 2014 5:08 pm

SavagePi wrote:I'm using the very same L298N PCB.

Here's a photo of my connections.

I've removed the two links (En1 & En2) that normally enable the motors because I control those myself.

Apart from the 6 control signals, you'll notice I've linked the 0V connection back to the Pi (this is the most essential connection, without it, you'll get the most erratic results).

Hope this helps.
Hi thanks for ur sharing, it is definitely useful for me.. :D :D

User avatar
joan
Posts: 14998
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04

Mon May 05, 2014 5:18 pm

hades1989 wrote: ...
Hi, but i didnt use any battery pack to power my Pi, i use these types of power bank to power my robot from the Pi itself, if this is the case how should i connect?
http://60.76.my/public/uploads/deal/dua ... 000mAh.jpg
The problem with that method is that the 5V supply goes through the 1.1 amp polyfuse. After the Pi takes its share there won't be much left to power motors.

In your situation connect P1-2 or P1-4 (the 5V pins) to the motor supply terminal block.

hades1989
Posts: 16
Joined: Wed Mar 12, 2014 2:28 am

Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04

Mon May 05, 2014 5:22 pm

joan wrote:
hades1989 wrote: ...
Hi, but i didnt use any battery pack to power my Pi, i use these types of power bank to power my robot from the Pi itself, if this is the case how should i connect?
http://60.76.my/public/uploads/deal/dua ... 000mAh.jpg
The problem with that method is that the 5V supply goes through the 1.1 amp polyfuse. After the Pi takes its share there won't be much left to power motors.

In your situation connect P1-2 or P1-4 (the 5V pins) to the motor supply terminal block.
Thanks for ur help, really appreciate it, last time i power the whole thing using the battery pack, like u mentioned, positive to the motor supply block, negative and ground to the ground block, but i dont know why it dont power the Pi, i used 4 X AA battery pack (sorry im really new here).

User avatar
SavagePi
Posts: 42
Joined: Mon Mar 31, 2014 7:34 pm
Location: Staffordshire, England

Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04

Mon May 05, 2014 6:46 pm

To me, this sounds like a simple matter power supply (current) lag.

It's nothing to do with your motor controller, since this won't use any current until the motors actually start turning.

The Pi needs enough surge current at startup to get it up and running (initially about 2Amps for 100mS). After that, it'll run quite happily on about 700mA or less. But, if this surge current isn't available at startup (ie; by using cheap batteries), then the Pi will just 'fizzle out' and not bother starting up at all.

I had the same problem even when I tried using a 2600mA (2.6A) 'cheapo' battery supply. I though this would be more than enough to power up my Pi. But no. It was crap. And my Pi just kept flashing a single LED at me, as if to say 'there's no way I'm powering up from this feeble thing'!
Electronics... It's what I do!

SteveRobey
Posts: 20
Joined: Wed Jan 07, 2015 11:53 am

Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04

Tue Mar 24, 2015 11:22 am

This is the guide I followed to get my Pi running two motors on a robot chassis using an L293D that I picked up for a couple dollars. http://computers.tutsplus.com/tutorials ... -cms-20051 I will also note that I'm powering my Pi on a separate battery power source so It's not running on four AAs. Seems to work fine like this. If you want to get fancy there's instructions out there on throwing some capacitors and a voltage regulator in and powering your Pi and the motors from the one battery source. If you're going to go that route, though, you'll want five or six batteries. I'm sure these pre-made H-bridge setups are great but I like building things myself. There's also some youtube videos, I believe theres 13 or 14 in the series where this guy walks you through step by step building a robot with a Pi and one of those pre-fab H-bridges which I found useful as well --> https://www.youtube.com/watch?v=LlFkybEQFFA

Return to “Automation, sensing and robotics”