5t0rm
Posts: 26
Joined: Mon Dec 09, 2013 1:50 am

Please help with first robotics project

Tue May 06, 2014 10:07 pm

I go my pi knowing it could do cool things and hoping that I could learn how to program from it, when I heard that the pi could be used to make robots I was so happy. I immediately started making a robot with my pi. So far I have a small tank frame with a live feed webcam to my phone, I have only been able to control one motor however because I was unable to find any tutorials on how to control two motors (although the tutorials I have used so far have claimed that it is possible) with the motor controler I am using (L298N). I can currently control the motor with a programmed set of instructions however my goal is to use my ps3 controler to drive the robot. I need help setting up my pi so it provides power to the motor when a specific button is pushed or joystick is moved on the ps3 controler. I also need help figuring out how to set up the second motor. If you have any suggestions for tutorials or want to post the solution to either of these problems as a reply I would really appreciate it. Thankyou

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Please help with first robotics project

Tue May 06, 2014 10:39 pm

5t0rm wrote:I go my pi knowing it could do cool things and hoping that I could learn how to program from it, when I heard that the pi could be used to make robots I was so happy. I immediately started making a robot with my pi. So far I have a small tank frame with a live feed webcam to my phone, I have only been able to control one motor however because I was unable to find any tutorials on how to control two motors (although the tutorials I have used so far have claimed that it is possible) with the motor controler I am using (L298N). I can currently control the motor with a programmed set of instructions however my goal is to use my ps3 controler to drive the robot. I need help setting up my pi so it provides power to the motor when a specific button is pushed or joystick is moved on the ps3 controler. I also need help figuring out how to set up the second motor. If you have any suggestions for tutorials or want to post the solution to either of these problems as a reply I would really appreciate it. Thankyou
First: don't trust the video of how to wire up the L298N, it contains some errors and can destroy your Pi.

2nd: search the forums for L298N and you'll find a lot of advice of how to wire them up.
Joan has a lot of good posts on the subject and a very useful annotated picture.
Doug.
Building Management Systems Engineer.

Tarcas
Posts: 741
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: Please help with first robotics project

Wed May 07, 2014 4:34 am

In short, the second motor works exactly the same as the first. One Enable pin (I recommend jumpering each of these to the nearby +5v pin) and two IN pins. IN1 and IN2 control motor A, and IN3 and IN4 control motor B.
to address RaspberryPiGuy's video error, it has to do with the Enable pins. He says that there are 4 of them. This is incorrect. There are 2, each of which is located below a 5v pin for convenience, meant to be connected to it by jumper. The actual enable pin is the one in line with the 4 IN pins, the one offset from this line is the +5v pin. Either jumper the two together, or connect the actual Enable pin(s) to the Pi and leave the 5v one empty. Never connect that second one to the Pi. Unless of course you like your Pi extra crispy. ;)
Besides this (fairly major) error, his tutorial is correct, and what he says about direction control of the motor he uses applies to the other motor the same way, only using the other two IN pins and ENB instead of ENA.

Make sense?

Return to “Automation, sensing and robotics”