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/
]Raspberry Pi + L298N H-Bridge + HC-SR04
Last edited by hades1989 on Mon May 05, 2014 3:48 pm, edited 1 time in total.
Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04
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.
Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04
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 Bjoan 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.
http://postimg.org/image/8ylajej0v/
Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04
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.
Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04
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.
Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04
Does the board look like this?
Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04
Yup correct, exactly look like thisjoan wrote:Does the board look like this?
Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04
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.
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.
Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04
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?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.
Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04
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).
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).
Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04
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.
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 (47.59 KiB) Viewed 5743 times
Electronics... It's what I do!
Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04
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?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).
http://60.76.my/public/uploads/deal/dua ... 000mAh.jpg
Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04
Hi thanks for ur sharing, it is definitely useful for me..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.


Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04
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.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
In your situation connect P1-2 or P1-4 (the 5V pins) to the motor supply terminal block.
Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04
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).joan wrote: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.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
In your situation connect P1-2 or P1-4 (the 5V pins) to the motor supply terminal block.
Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04
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'!
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!
-
- Posts: 20
- Joined: Wed Jan 07, 2015 11:53 am
Re: ]Raspberry Pi + L298N H-Bridge + HC-SR04
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