Hi,
I really want to be able to create a remote control vehicle with my Pi! For a project, I would love to be able to press the up arrow on my keyboard to make an RC car go forward. The problem is, I don't know where to start.
Would I use infrared or PWM to control my RC vehicle? What would I need and where would I begin?
Thanks in advance
Matt
Remote Control Vehicle
5 posts
- Posts: 128
- Joined: Fri Dec 28, 2012 9:49 am
To control an rc car with a raspberry pi you need:
How do you put it all together?
Well, your car will likely have 2 motors, they must be connected to an H Bridge, which has two functions. First of all an H Bridge makes it possible to "run" each motor in both directions, and it also takes power from an external battery pack and feeds it to the motors. The raspberry pi cannot generally power the motors directly (depending on their size) because it can't supply enough current.
Once the H Bridge is connected to the motors and to the raspberry pi you can already start experimenting moving the motors.
One example of Motor Driver Controller (with the h-bridge) is this one: http://www.ebay.co.uk/itm/L298N-DC-Step ... 0973372764
There are several posts in this forum about this motor driver.
- a raspberry (eheh)
- a base car/robot (3-wheeled robots are the best to start with)
- an H Bridge
- jumper cables
- a battery pack for the motors
- a wifi dongle
- a battery pack to power the raspberry
How do you put it all together?
Well, your car will likely have 2 motors, they must be connected to an H Bridge, which has two functions. First of all an H Bridge makes it possible to "run" each motor in both directions, and it also takes power from an external battery pack and feeds it to the motors. The raspberry pi cannot generally power the motors directly (depending on their size) because it can't supply enough current.
Once the H Bridge is connected to the motors and to the raspberry pi you can already start experimenting moving the motors.
One example of Motor Driver Controller (with the h-bridge) is this one: http://www.ebay.co.uk/itm/L298N-DC-Step ... 0973372764
There are several posts in this forum about this motor driver.
- Posts: 34
- Joined: Sun Dec 16, 2012 7:44 pm
The way I'm trying to do it is a tracked vehicle using a Wii remote/nunchuk which communicates via Bluetooth. There is no need for a wireless/internet connection (see option below)
Headless operation requires autologin to the RPi and autolaunch of LXDE and Scratch to start automatically using the 'ControllingTwoMotorsForRasPi' image by Kahuziro Abee and a simple scratch project.
Lego WeDo USB hub and 2 Lego WeDo motors
Nintendo Wii controller/nunchuk and Bluetooth dongle Martin Bateman http://www.star.uclan.ac.uk/~mb/rpjam3sept2012.html
Matt Hawkins,
RaspberryPi-Spy, http://www.raspberrypi-spy.co.uk/2013/0 ... pberry-pi/
Raspi.tv, http://www.raspberrypi.org/archives/3298
Battery: Anker for example
Options:
WiFi dongle, (tight ?)VNC Server at boot, smartphone operating as a WiFi hotspot. This way if things do go wrong at least you can log in to the RPi to try to resolve them. Possibly need to look at security issues here
Bluetooth speaker for sound effects.
replace WeDo motors with motors driven via GPUO/add-on boards
Headless operation requires autologin to the RPi and autolaunch of LXDE and Scratch to start automatically using the 'ControllingTwoMotorsForRasPi' image by Kahuziro Abee and a simple scratch project.
Lego WeDo USB hub and 2 Lego WeDo motors
Nintendo Wii controller/nunchuk and Bluetooth dongle Martin Bateman http://www.star.uclan.ac.uk/~mb/rpjam3sept2012.html
Matt Hawkins,
RaspberryPi-Spy, http://www.raspberrypi-spy.co.uk/2013/0 ... pberry-pi/
Raspi.tv, http://www.raspberrypi.org/archives/3298
Battery: Anker for example
Options:
WiFi dongle, (tight ?)VNC Server at boot, smartphone operating as a WiFi hotspot. This way if things do go wrong at least you can log in to the RPi to try to resolve them. Possibly need to look at security issues here
Bluetooth speaker for sound effects.
replace WeDo motors with motors driven via GPUO/add-on boards
- Posts: 28
- Joined: Mon May 28, 2012 12:18 pm
Hey there,
Like yourself I have dived in at the deep end and looking to learn Python with a motorised project! Like the MagPi project I am using a Big Trak base, but as a skid drive it is the same controls as your tracked vehicle.
Hardware includes:
RPi
PiFace interface board
4 relay board
IOGEAR high capacity USB battery pack
Instead of the H-Bridge I have opted to use a 4 relay board, each relay has two positions, Normally Open (NO) and Normally Closed(NC). The relays can handle over 240V so they give me opportunity to migrate all this into something with bigger motors
The NO position has the positive voltage, the NC has the negative and the contact is attached to a motor terminal.
If relay A is energised motor terminal A has 5v, relay B has 0v the motor turns in direction 1, if relay B is energised the motor terminal B has 5v, relay A has 0v motor turns in direction 2. Here we have the basics for a skid drive!
Now to make a program that relates a Key press to a relay. In order to go forward the left motor needs to go anti clockwise, while the one on the right needs to go clockwise.
This code lets the rover go forward, reverse, rotate left and right.
Its all about baby steps, once you get the basics working you can think about getting the controller working.
Good luck and keep us posted
Like yourself I have dived in at the deep end and looking to learn Python with a motorised project! Like the MagPi project I am using a Big Trak base, but as a skid drive it is the same controls as your tracked vehicle.
Hardware includes:
RPi
PiFace interface board
4 relay board
IOGEAR high capacity USB battery pack
Instead of the H-Bridge I have opted to use a 4 relay board, each relay has two positions, Normally Open (NO) and Normally Closed(NC). The relays can handle over 240V so they give me opportunity to migrate all this into something with bigger motors
The NO position has the positive voltage, the NC has the negative and the contact is attached to a motor terminal.
If relay A is energised motor terminal A has 5v, relay B has 0v the motor turns in direction 1, if relay B is energised the motor terminal B has 5v, relay A has 0v motor turns in direction 2. Here we have the basics for a skid drive!
Now to make a program that relates a Key press to a relay. In order to go forward the left motor needs to go anti clockwise, while the one on the right needs to go clockwise.
- Code: Select all
import piface.pfio as pfio
import pygame
from pygame.locals import *
pfio.init()
pygame.init()
screen = pygame.display.set_mode((640, 480))
pygame.display.set_caption('pygame Caption')
pygame.mouse.set_visible(0)
done = False
while not done:
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == (K_UP):
pfio.LED(4).turn_on()
pfio.LED(7).turn_on()
if event.key == (K_DOWN):
pfio.LED(5).turn_on()
pfio.LED(6).turn_on()
if event.key == (K_LEFT):
pfio.LED(5).turn_on()
pfio.LED(7).turn_on()
if event.key == (K_RIGHT):
pfio.LED(4).turn_on()
pfio.LED(6).turn_on()
if event.type == KEYUP:
if event.key == (K_UP):
pfio.LED(4).turn_off()
pfio.LED(7).turn_off()
if event.key == (K_DOWN):
pfio.LED(5).turn_off()
pfio.LED(6).turn_off()
if event.key == (K_LEFT):
pfio.LED(5).turn_off()
pfio.LED(7).turn_off()
if event.key == (K_RIGHT):
pfio.LED(4).turn_off()
pfio.LED(6).turn_off()
if (event.key == K_ESCAPE):
done = True
This code lets the rover go forward, reverse, rotate left and right.
Its all about baby steps, once you get the basics working you can think about getting the controller working.
Good luck and keep us posted
New but willing to learn
Pete
Pete
- Posts: 17
- Joined: Wed Nov 21, 2012 10:01 am
Here was my effort to build something from the ground up:
http://subgroup-ash.blogspot.de/2013/02 ... mega8.html
Uses keyboard or voice control input + web cam and wifi.
http://subgroup-ash.blogspot.de/2013/02 ... mega8.html
Uses keyboard or voice control input + web cam and wifi.
- Posts: 18
- Joined: Wed Nov 14, 2012 9:18 am