Showing posts with label RaspberryPi. Show all posts
Showing posts with label RaspberryPi. Show all posts

Saturday, 15 June 2013

Update

Firstly, apologies for not updating this blog for a while. It dropped down in my priorities.

So, I'll update on what has be going on for the last few months.

New Projects..

I've started researching/working on a new project, which is very ambitious. I won't go into details just yet, but it'll involve various ARM Boards, cameras and servos. I'm currently busy acquiring parts and learning about them and various software libraries. Some parts are kickstarter projects which have been delayed.
One of the parts that'll be in the project will be the BeagleBone Black, hopefully this will be better than the Raspberry Pi for some number crunching.
(c) BeagleBoard.org

I'll try to add some posts about parts of this project, like my experiences and differences of the Raspberry Pi and BeagleBone Black. After a while you'll probably guess what the project is :)

Making Parts..

One of my latest acquisitions has been a Replicator 2 :) A Desktop 3D printer. This will be perfect for creating parts on all of my projects in the future. It has already proved useful for fixing things around the house.

The Replicator 2 is a great 3D printer, which was up and running in within minutes of its arrival. Although I've spent some time trying to fine tune it, and learning what it is good at and not so good at.
First thing I printed was this gear cube (dowloaded design from thingieverse)..

I'll try to add some posts of my 3D Printing experiences and stuff I've designed/printed.

Old Projects..

My older projects are effectively on hold/ended. All my available time is going into research for the new project.

Monday, 17 December 2012

Mobile Pi - Part 2 Simple Motor Control

Ok, so I have my platform and I have a Raspberry Pi running remotely..Now to put them together :)
To do this I need to create a motor controller, so I can firstly protect the Pi from high currents by running the motors off their own power supply and also have some control on direction.

As I'm still waiting on a part which I'll need to be able to have speed control, I'm first gonna create a simple motor controller which uses 4 GPIO pins (2 per motor). One pin for the 'Drive' and one pin for the 'Direction'. Also, I'm not re-inventing the wheel here, I've based the circuit on one found on www.societyofrobots.com. With the only difference being I'm using an SN754410 instead of an L293D, and I'm not using PWM (for now).

Simple Motor Controller Schematic
By the way, for the schematics I'm using an application called Fritzing. It is simple, but useful especially going from breadboard to schematic to circuit board.

So that's the controller decided upon, next step.. put it together. I'm using a breadboard for this for now. I'll create a seperate board for it later. And I can use the Pi Dish which actually fits nicely to the platform. The battery for the Pi I'll just tape to the mid section.. connect the other batters for the motors and . hey presto..

Note, I'm using the new T-Cobbler from Adafruit, another great resource for these things, in tutorials and parts. Also, there are 4 motors, but the controller only works with 2, I hear you say.. well I just wire together both motors on the left, and both on the right :)


So with everything connected, time for the software. For now I'm still sticking the the same library I used for the traffic lights. Although for the next stages it won't be enough as I'll need to use I2C bus.

Anyways, I'm not going to post the whole code here, if you really want it let me know and I'll send it to you. But it is not very interesting code. All the code does is listens to the keyboard, if 'z' is pressed turn both motors on going forward, if 'q' is pressed turn both motors on left going backwards right going forwards.. etc..etc you get the idea. (Oh yeah, if you think the keys are a strange choice, I'm using a belgian keyboard). So running the program using SSH I can control the Raspberry Pi using the keyboard on my laptop. I also was able to control it using my Samsung S2 using a SSH terminal on it :)

And the final result of this is...

That will probably be it until the new year.. I'll add the speed control.. and then maybe add some sensors to auto-stop before hitting anything.. And make the software more interesting :)

Merry Xmas everyone!





Sunday, 16 December 2012

Mobile Pi - Part 1 The Platform

Ok, I have my Raspberry Pi running remotely without the need for wires. So next step, make it mobile!
This will take a bit more work than the traffic lights, so I'm breaking it up into parts, first is the platform. My long term goal is to create a bi-pedal walking robot, but for now I'm just use some wheels.
There are many platform kits around, from 2-wheel to x-wheels, I found a nice platform from a French supplier (http://www.alpha-crucis.com) which have all sorts of goodies for robotics, and although their prices are higher than say our american cousins, cost is saved on delivery (which is also much faster).

So What did I get? I got the 4WD Mobile Platform by DFROBOT...
DFROBOT 4WD Mobile Platform in its box
This platform is designed for the Arduino, but looked open enough to add anything.
Platform unpacked
As you can see above, it comes in kit form. I always worry about missing nuts & bolts in this type of kit, but I'm please to report that nothing was missing, in fact a few spare nuts/screws/washers etc. The instructions, although in Chinglish, were clear and easy to follow. Some pieces were a bit tight to fit. But assembly went well, no problems. I didn't bother attaching everything, as I don't see any reason to, yet.



















And here is the assembled platform.

Next, will be sorting out a controller for the motors, currently waiting for some components for this. So watch out for part 2 soon.

Tuesday, 4 December 2012

Rasberry PI Traffic lights

It has been too many years since I done any real electronics (I originally trained as an electronics apprentice for GEC-Marconi Avionics). So, I decided to start on a very simple little project with my new Raspberry PI.

I remembered during my apprenticeship, we were given the task of creating a traffic lights system, but back then we were only allowed to use a breadboard, some LEDs, a few wires, a 555 timer and a few logic gates. No programming required. So using a Raspberry PI for this is overkill to say the least :)

But anyway, I first set-up my raspberry Pi for remote operation (I plan to use it for robotics in the future so don't want to tie it to cables). This was very simple to do. 1st get a battery pack capable of running the Pi off, I'm using a battery from ANKER, which was designed to charge phones and tablets, so it came with a nice micro-USB plug that fits nicely into the PI. It is also capable of providing upto 2A. Although, I found the voltage dropped to 4.4V (below recommended) but I have had no problems with the PI running. Then I installed a USB wifi dongle, I won't go into details here, there are plenty of other blogs/sites/books with details on how to do this.

With the wifi dongle installed, I then only access the raspberry pi via SSH. (I have run vnc server on it, and connected to it that way, but I don't really need it so I don't have it running)

I also got a PI Dish, just to make life easier for playing around with projects like this.

Once that was done, it was then down to adding the traffic light LEDs to the breadboard of the PI dish. Having one set of lights is rather meaningless, so I added 2 sets. I won't go into how to wire an LED to a GPIO pin (it's simple and well plenty of resources around for that). However, here is how I connected the LEDs..

Traffic Lights set A
Red LED to Pin 11
Yellow LED to pin 12
Green LED to pin 13
Traffic Lights set B
Red LED to pin 15
Yellow LED to pin 16
Green LED to pin 18.
And here's the schematic..


So that's the hardware side sorted, with the final result looking like below..

The Raspberry PI Traffic Lights set-up
So next came the programming. I decided to use Python, because 1. it is pre-installed in the Raspian distro I'm using, 2. I was able to install a simple library for accessing the GPIO.
I hadn't really done anything before in python, but it is very simple to use. Below is the code I wrote to create the traffic light sequence:


import RPi.GPIO as GPIO
import time

RED_LIGHT_A = 11
YELLOW_LIGHT_A = 12
GREEN_LIGHT_A = 13
RED_LIGHT_B = 15
YELLOW_LIGHT_B = 16
GREEN_LIGHT_B = 18

ON = GPIO.HIGH
OFF = GPIO.LOW

GPIO.setmode(GPIO.BOARD)
GPIO.setup(RED_LIGHT_A, GPIO.OUT)
GPIO.setup(YELLOW_LIGHT_A, GPIO.OUT)
GPIO.setup(GREEN_LIGHT_A, GPIO.OUT)
GPIO.setup(RED_LIGHT_B, GPIO.OUT)
GPIO.setup(YELLOW_LIGHT_B, GPIO.OUT)
GPIO.setup(GREEN_LIGHT_B, GPIO.OUT)

def setLights_A(red, yellow, green):
    GPIO.output(RED_LIGHT_A, red)
    GPIO.output(YELLOW_LIGHT_A, yellow)
    GPIO.output(GREEN_LIGHT_A, green)

def setLights_B(red, yellow, green):
    GPIO.output(RED_LIGHT_B, red)
    GPIO.output(YELLOW_LIGHT_B, yellow)
    GPIO.output(GREEN_LIGHT_B, green)

while True:

    setLights_A(ON, OFF, OFF)
    setLights_B(OFF, OFF, ON)
    time.sleep(3)
    setLights_B(OFF, ON, OFF)
    time.sleep(1)
    setLights_B(ON, OFF, OFF)
    time.sleep(1)
    setLights_A(ON, ON, OFF)
    time.sleep(1)
    setLights_A(OFF,OFF,ON)
    time.sleep(3)
    setLights_A(OFF, ON, OFF)
    time.sleep(1)
    setLights_A(ON, OFF, OFF)
    time.sleep(1)
    setLights_B(ON, ON, OFF)
    time.sleep(1)

As you can see, the code is very simple.

So the final result of this simple little project..