Dawn Robotics Blog » News http://blog.dawnrobotics.co.uk Tutorials and updates from Dawn Robotics Fri, 26 Dec 2014 23:06:33 +0000 en-US hourly 1 http://wordpress.org/?v=3.7.5 Off to Pitch@Palace http://blog.dawnrobotics.co.uk/2014/11/pitchpalace/ http://blog.dawnrobotics.co.uk/2014/11/pitchpalace/#comments Sun, 02 Nov 2014 10:01:44 +0000 http://blog.dawnrobotics.co.uk/?p=714 Dawn Robotics is quite a young company (our store is just over a year and a half old now), and as we go through the process of bootstrapping ourselves, we’re lucky to have startup space in the Bristol Robotics Laboratory Technology Incubator. As part of our involvement with the Technology Incubator, we’re also fortunate enough […]

The post Off to Pitch@Palace appeared first on Dawn Robotics Blog.

]]>
Dawn Robotics is quite a young company (our store is just over a year and a half old now), and as we go through the process of bootstrapping ourselves, we’re lucky to have startup space in the Bristol Robotics Laboratory Technology Incubator.

As part of our involvement with the Technology Incubator, we’re also fortunate enough to have been invited to take part in Pitch@Palace, a platform for young British startups organised by HRH The Duke of York on 5th November at St. James’s Palace.

We’ll be heading along with 2 other tech startups from the BRL incubator, Reach Robotics, and OmniDynamics. This is a great opportunity for us to explain our vision for robotics in education and research to a wider audience (see the slightly rushed video pitch below…).

As part of the Pitch@Palace event, there’s a Pitch@Palace people’s choice award which is given to the company that gets the most votes from the public. So if you could find time to support us and cast a vote for us then that would be very much appreciated. :)

The post Off to Pitch@Palace appeared first on Dawn Robotics Blog.

]]>
http://blog.dawnrobotics.co.uk/2014/11/pitchpalace/feed/ 4
Improving the Battery Life of Your Raspberry Pi Robot with a UBEC http://blog.dawnrobotics.co.uk/2014/08/improving-battery-life-raspberry-pi-robot-ubec/ http://blog.dawnrobotics.co.uk/2014/08/improving-battery-life-raspberry-pi-robot-ubec/#comments Thu, 14 Aug 2014 16:55:54 +0000 http://blog.dawnrobotics.co.uk/?p=624 We recently started selling a USB powerbank which can be used to power the Raspberry Pi robot kit that we sell. Using the powerbank provides great battery life, but we’re still interested in making the robot run well from AA batteries, as this may be the cheaper option if you already have rechargeable batteries and […]

The post Improving the Battery Life of Your Raspberry Pi Robot with a UBEC appeared first on Dawn Robotics Blog.

]]>
A UBEC provides a nice efficient way to power your Pi from batteries

A UBEC provides a nice efficient way to power your Pi from batteries

We recently started selling a USB powerbank which can be used to power the Raspberry Pi robot kit that we sell. Using the powerbank provides great battery life, but we’re still interested in making the robot run well from AA batteries, as this may be the cheaper option if you already have rechargeable batteries and a charger lying around.

Testing battery life

Testing battery life

Therefore, we’re modifying the kit a bit to include a UBEC (Universal Battery Elimination Circuit). This is an efficient switching voltage regulator which takes the load off the linear voltage regulator of the Mini Driver and improves the running time of a robot being powered by AA batteries a lot. This post gives some details about why we’re making this change and also describes a battery testing script that we’ve written to determine what kind of run times can be expected for different methods of powering the Raspberry Pi robot.

The Dagu Arduino Mini Driver board used in the Raspberry Pi robot contains a L4941B 1A linear voltage regulator which can be used to run the robot from batteries. Linear voltage regulators are cheap, which helps keep the Mini Driver affordable, but they’re not very efficient, so a lot of battery power is wasted as heat. Also the Mini Driver, Raspberry Pi and a USB Wifi dongle use up quite a lot of the available 1A so there’s not much headroom for adding extra sensors to the robot.

By contrast, the UBEC we’re using is a switching voltage regulator which are a lot more efficient than linear regulators, wasting much less battery power. Also, the UBEC is able to provide up to 3A of current, so provided the batteries can keep up, this provides a lot more current to supply USB peripherals plugged into the Pi, and sensors plugged into the robot.

Wiring up the UBEC

Making use of the UBEC is very straightforward. If you’ve already wired up your robot to provide power to the Raspberry Pi from the Mini Driver, then first remove these wires. After that, connect the red input wire of the UBEC to the pin directly next to the on/off switch of the Mini Driver (this is connected to battery voltage), and then connect the black input wire of the UBEC to a GND pin on the Mini Driver. We’ve used the GND pin on the 3×2 programming header as this is unlikely to be used for anything else. Finally, plug the USB connector of the UBEC into the Pi and attach a set of 6xAA batteries to the +/- pins of the Mini Driver and you’re good to go. :)

Remove any power wires connecting the Mini Driver to the Pi.

Remove any power wires connecting the Mini Driver to the Pi.

 

Connect the UBEC to the Mini Driver and the Pi

Connect the UBEC to the Mini Driver and the Pi

Power the Robot using 6xAA batteries (preferably rechargeable)

Power the Robot using 6xAA batteries (preferably rechargeable)

Testing the Battery Life of the Robot

To help us test and compare different ways of powering our robot we’ve developed a little battery testing script using our py_websockets_bot control library (installation instructions here). This test script runs on a PC and connects to the robot over WiFi. It runs in a loop making the robot look in different directions, and then periodically making the robot spin either left or right. In this way we hope to simulate the conditions in which the robot might be used i.e. lots of stop/start motion. The Mini Driver has one of its ADC pins hard-wired to a voltage divider to measure its battery voltage, and so the test script periodically records this voltage. When the robot runs out of juice, it stops responding and the script can be ended, at this point the script saves the voltages out to a CSV file so we can plot how the voltage of the battery changes over time.

The graph below shows some of the tests we’ve run. All of the tests were run on our Raspberry Pi robot using a Model B, so we’d expect runtime improvements if using a Model B+, as this has lower power consumption. The voltage readings are quite noisy, but you still get the general discharge curve over time when running off batteries. The graph shows the advantage of using good rechargeable batteries (NiMH) instead of non-rechargeable (Alkaline) batteries. On rechargeable batteries (Duracell 2400mAh NiMH) the robot ran for approximately 3 hours, which was 3 times longer than when using Alkalines (Sainsbury’s Extra Long Life). The graph also shows the results of running the robot on the TeckNet iEP387 USB powerbank that we sell.

We’ll update this graph with more tests as we run them, i.e. we’re planning to run tests using the Model B+. Also, we’d be really interested to see the results of any battery tests that users run on their camera robots to see how they compare with our results.

battery_power

Results of running battery_test.py using different power supplies for the robot.

 

 

The post Improving the Battery Life of Your Raspberry Pi Robot with a UBEC appeared first on Dawn Robotics Blog.

]]>
http://blog.dawnrobotics.co.uk/2014/08/improving-battery-life-raspberry-pi-robot-ubec/feed/ 1
Robotics and the Raspberry Pi Model B+ http://blog.dawnrobotics.co.uk/2014/07/robotics-raspberry-pi-model-b/ http://blog.dawnrobotics.co.uk/2014/07/robotics-raspberry-pi-model-b/#comments Sat, 19 Jul 2014 16:54:07 +0000 http://blog.dawnrobotics.co.uk/?p=618 So, the big news this week (if you’re a Raspberry Pi fan) is that the Raspberry Pi foundation announced the release of an upgraded version of the Model B Pi, the Model B+. The Raspberry Pi Model B+ is a really nice incremental update of the Model B, and it’s especially good for people wanting […]

The post Robotics and the Raspberry Pi Model B+ appeared first on Dawn Robotics Blog.

]]>
The new Model B+

The new Model B+

So, the big news this week (if you’re a Raspberry Pi fan) is that the Raspberry Pi foundation announced the release of an upgraded version of the Model B Pi, the Model B+. The Raspberry Pi Model B+ is a really nice incremental update of the Model B, and it’s especially good for people wanting to use the Pi in robotic projects. This is because, alongside extra USB ports, it now uses switching voltage regulators which means that it consumes less power (between 0.5W to 1W less) and therefore it will last longer on batteries.

As soon as we got a Model B+ this week, we put it onto one of our Raspberry Pi Camera Robots, and it works great. :) The Model B+ has a different layout and mounting holes than the Model B so we’ve updated the assembly instructions for the robot to show how the Model B+ should be mounted.

We’ve also released a new version of the software for the robot, as the Model B+ needs different drivers for its USB and network ports. This new software has a few bugfixes, and also allows the robot to be driven at slower speeds than before. This new feature may not sound like much, but with the old software, the motors often couldn’t be made to go slower than about 33% speed before they stalled due to friction in the gearboxes. Now by driving the motors in a different way, we get the motors to turn with more torque at lower speeds to overcome this friction. This means that it’s easier to drive the robot whilst looking through the camera, and makes making precise turns easier.

The new SD card image can be downloaded here. Other options for getting the software are discussed here.

The post Robotics and the Raspberry Pi Model B+ appeared first on Dawn Robotics Blog.

]]>
http://blog.dawnrobotics.co.uk/2014/07/robotics-raspberry-pi-model-b/feed/ 0
New Product – A Power Bank for your Raspberry Pi Robot http://blog.dawnrobotics.co.uk/2014/06/new-product-power-bank-raspberry-pi-robot/ http://blog.dawnrobotics.co.uk/2014/06/new-product-power-bank-raspberry-pi-robot/#comments Wed, 18 Jun 2014 09:48:31 +0000 http://blog.dawnrobotics.co.uk/?p=588 One issue that has caught quite a few people out when they build our Raspberry Pi robot kit, is the issue of power. The kit comes with a 6xAA battery holder, but the trouble is, not all AA batteries are the same, which is easy to overlook when you’re grappling with all the other complexities […]

The post New Product – A Power Bank for your Raspberry Pi Robot appeared first on Dawn Robotics Blog.

]]>
One issue that has caught quite a few people out when they build our Raspberry Pi robot kit, is the issue of power. The kit comes with a 6xAA battery holder, but the trouble is, not all AA batteries are the same, which is easy to overlook when you’re grappling with all the other complexities of building a Raspberry Pi robot. :)

We recommend that the robot be powered with good quality, high capacity, rechargeable (NiMh or NiCd) batteries, such as Duracell 2400mAh NiMh . Non-rechargeable (Alkaline) batteries are not recommended as they will struggle to provide enough current to power both the Pi and the motors of the robot.

Good for Robots

Good for robots

Bad for Robots

Bad for robots

Good for Robots

Pretty (and also good for robots)

 

 

 

 

 

As an alternative to AA batteries, we’re now selling the  TeckNet iEP387 USB power bank which can be used to power the entire robot. The power bank is more expensive that the cost of 6 AA rechargeable batteries, but you get the advantage of increased runtime (approx 5 hours compared to 3hrs for the NiMh Duracells), and you don’t have to buy a battery charger.

In this blog post we show you how to use the power bank with the robot.

Connecting the Battery to the Robot

Please Note: If you are using a USB battery pack to power the Pi and mini driver, then you do not need to use the UBEC which we’ve started to supply with more recent versions of our Raspberry Pi robot.

Once you’ve built the robot following these instructions, Slide the iEP387 USB power bank into the chassis behind the wheels.

The iEP387 should come with 2 USB cables, a micro USB cable for powering the Pi, and a USB cable with 2.54mm connectors for connecting to the Mini Driver, and powering the motors. First plug the micro USB cable into the 5V 2.1A output of the iEP387 (the Pi needs this) and connect it to the power connector on the Pi (the extra cable can be wound around the Raspberry Pi mounting struts).

Secondly, use the USB power cable with red and black leads, and 2.54mm connectors to attach the 5V 1.0A output of the iEP387 to the battery pins of the Mini Driver (marked + and – next to the mini USB connector). The red wire should attach to the + pin and the black wire should attach to the – pin. Don’t worry if you get them the wrong way round though, as the Mini Driver has reverse bias protection.

Connecting the iEP387 USB Power Bank to the Robot

Connecting the iEP387 USB Power Bank to the Robot

Make sure that you leave a bit of slack in the cables so that you are able to slide the iEP387 sideways slightly and press the on/off button.

Turning on the iEP387 Power Bank

Turning on the iEP387 Power Bank

Turning on the Robot

To turn on the robot, first switch on the power switch on the Mini Driver. This is important in order to provide power to the motors. Then slide the iEP387 sideways, and press the power button. This should turn on the robot.

Turning off the Robot

To turn off the robot you need to unplug the micro USB connector from the Pi, and turn off the power switch on the Mini Driver. This is not as neat as we’d like it, but there’s not really an easy way (without adding more hardware, and therefore more cost) to stop the Pi from drawing power from the power bank.

Unplug the micro USB cable to turn off the Pi

Unplug the micro USB cable to turn off the Pi

Pulling the power from the Pi shouldn’t damage anything as the robot’s software doesn’t write anything to the SD card. However, it’s always nice to let the Pi shutdown cleanly if possible, and so to do that you can use the shutdown button on the robot’s web interface.

 Updated: Extra Photos to Show Installation of Battery

I’ve had a couple of people say that their battery pack touches the wheels so have posted the following pictures to try to clarify things. The pictures are not great quality, but hopefully I’ll have time to update them in the new year.

There should be a small (approx 2mm) gap between the battery pack and the wheels

There should be a small (approx 2mm) gap between the battery pack and the wheels

 

The battery pack should be held back by the plastic motor tabs.

The battery pack should be held back by the plastic motor tabs.

As an alternative to inserting the battery pack in from the side, it’s also possible to remove the central support and slide the battery pack in from the front. This is a snug fit, but again there should be a few millimetres between the battery pack and the wheels. This gap can be increased by sliding the wheels slightly along the motor axles.

If the central support is removed, the battery pack can be slid in from the front.

If the central support is removed, the battery pack can be slid in from the front.

There should be a few millimetres of clearance between the battery pack and the wheels.

There should be a few millimetres of clearance between the battery pack and the wheels.

 

 

The post New Product – A Power Bank for your Raspberry Pi Robot appeared first on Dawn Robotics Blog.

]]>
http://blog.dawnrobotics.co.uk/2014/06/new-product-power-bank-raspberry-pi-robot/feed/ 28
New Software For Our Raspberry Pi Camera Robot http://blog.dawnrobotics.co.uk/2014/05/new-software-raspberry-pi-camera-robot/ http://blog.dawnrobotics.co.uk/2014/05/new-software-raspberry-pi-camera-robot/#comments Wed, 07 May 2014 14:27:03 +0000 http://blog.dawnrobotics.co.uk/?p=547 We had a great response to a recent blog post we wrote, describing how to build a Raspberry Pi robot that you can drive around using a tablet, smartphone or PC. Therefore we’ve carried on developing the software for it, and are pleased to announce the update today. The changes that we’ve made to the […]

The post New Software For Our Raspberry Pi Camera Robot appeared first on Dawn Robotics Blog.

]]>
We had a great response to a recent blog post we wrote, describing how to build a Raspberry Pi robot that you can drive around using a tablet, smartphone or PC. Therefore we’ve carried on developing the software for it, and are pleased to announce the update today. The changes that we’ve made to the software have largely been to support cool things that we want to do with the robot in the future, but features that users of the robot will notice are

  • much faster camera streaming. Initially the camera was streaming images at about 4-5 frames per second using raspistill and mjpg-streamer, but we’ve now written our own camera streamer, and got it streaming at 15fps which is much smoother, and makes driving the robot around a lot easier.
  • support for more WiFi dongles when working as an access point. Our previous software release mainly worked with WiFi dongles that used the same chipset as the Edimax EW-7811Un (the hostapd rtl871xdrv driver). It was possible to get it to work with other WiFi dongles that used the hostapd nl80211 driver, but it required a fairly technical user. Now our software should work with a much wider range of WiFi dongles with no change required.
  • we’ve added a shutdown button. Previously the robot was turned off by just cutting off the power. This was very unlikely to corrupt the SD card as nothing was written to it, but a lot of users felt uncomfortable with not doing a proper shutdown. Now a shutdown button in the web interface provides peace of mind.
  • more configuration options. The configuration webpage of the robot has been expanded to offer more options to control the movement of the robot.

As before, there are multiple options for getting hold of this software. If you already have an SD card then you can download an SD card image with all of the software installed here (go for the most recent version). Update: If you use our SD card image, please remember to expand it after installation by running

sudo raspi-config

and choose the ‘Expand Filesystem’ option.

Alternatively, we sell SD cards with the image preloaded in our store. Finally, for those who want to set up the software from scratch, or who want to modify it for their own robotic projects, we give full details for building the SD card, and installing all the software, here.

We believe that the Raspberry Pi is a great platform for robotics, and have got a number of tutorials for our Raspberry Pi Camera bot lined up for the coming months. If there’s anything in particular you’d like to see, please let us know.

 

The post New Software For Our Raspberry Pi Camera Robot appeared first on Dawn Robotics Blog.

]]>
http://blog.dawnrobotics.co.uk/2014/05/new-software-raspberry-pi-camera-robot/feed/ 5
Attending the Linux User Pi Jam http://blog.dawnrobotics.co.uk/2014/04/attending-linux-user-pi-jam/ http://blog.dawnrobotics.co.uk/2014/04/attending-linux-user-pi-jam/#comments Mon, 07 Apr 2014 19:00:29 +0000 http://blog.dawnrobotics.co.uk/?p=538 Last Saturday we attended the Linux User Pi Jam, in Poole, and had an absolute blast. The Jam was held at the RNLI college, which is a great location for an event, and we met some very interesting people at the Jam. We’re glad to see that robotics is rising in popularity as something to […]

The post Attending the Linux User Pi Jam appeared first on Dawn Robotics Blog.

]]>
linux_user_jam33565-RNLI-CollegeLast Saturday we attended the Linux User Pi Jam, in Poole, and had an absolute blast. The Jam was held at the RNLI college, which is a great location for an event, and we met some very interesting people at the Jam.

We’re glad to see that robotics is rising in popularity as something to do with your Pi. :) We ran a store at the Jam, and other robotics vendors there included The Little British Robot Company and PiBorg (with their very cool DoodleBorg tank). Ben from Phenoptix was also there with a neat little laser cut robot arm. We saw some cool Raspberry Pi robot projects from Leo White, and had a nice chat with Ian Renton, the guy behind the Raspberry Pi tank.

In the afternoon we gave a talk on combining the power of Arduino with the Pi to build Raspberry Pi robots as we have with our Camera Bot. For anybody interested the slides can be found here.

Pi Jams are a great way to meet interesting people, and get ideas for your next Pi project, if you haven’t been to one yet then we recommend that you keep an eye out for one in your area and head along. :)

The post Attending the Linux User Pi Jam appeared first on Dawn Robotics Blog.

]]>
http://blog.dawnrobotics.co.uk/2014/04/attending-linux-user-pi-jam/feed/ 1
Building a Raspberry Pi Robot – CamJam Video and Slides http://blog.dawnrobotics.co.uk/2014/04/building-raspberry-pi-robot-camjam-video-slides/ http://blog.dawnrobotics.co.uk/2014/04/building-raspberry-pi-robot-camjam-video-slides/#comments Thu, 03 Apr 2014 15:34:10 +0000 http://blog.dawnrobotics.co.uk/?p=526 A couple of months ago, Dawn Robotics went to the fantastic Cambridge Pi Jam organised by Michael Horne and Tim Richardson. Whilst there, I gave a talk on building a mobile robot with the Raspberry Pi (such as the camera robot we talk about in this blog post). The talk was aimed at quite a […]

The post Building a Raspberry Pi Robot – CamJam Video and Slides appeared first on Dawn Robotics Blog.

]]>
A couple of months ago, Dawn Robotics went to the fantastic Cambridge Pi Jam organised by Michael Horne and Tim Richardson. Whilst there, I gave a talk on building a mobile robot with the Raspberry Pi (such as the camera robot we talk about in this blog post). The talk was aimed at quite a high level, and looked at 7 key areas you should think about when building a mobile robot.

Well, I recently found out that there was a video of the talk online (along with videos of all the other talks at the Jam). Therefore I thought that I’d link to it here, along with the slides for the talk. The sound quality is not too great, and I need to work on my presenting style, but hopefully it’ll be useful to people thinking of building their own robot. If you’ve got any questions, or would like more information on any of the areas talked about in the video, please post on our forums.

Also, for those that are in the area, we’ll also be giving a talk at the Linux User Raspberry Pi Jam being held in Poole this Saturday (5th April 2014). A small number of tickets for the Jam are still available here. This talk will mainly be about using the Pi with an Arduino, but we’ll still try to squeeze in some robots. :)

The post Building a Raspberry Pi Robot – CamJam Video and Slides appeared first on Dawn Robotics Blog.

]]>
http://blog.dawnrobotics.co.uk/2014/04/building-raspberry-pi-robot-camjam-video-slides/feed/ 0
Using the Pi Co-op as a General Purpose I/O Board for the Raspberry Pi http://blog.dawnrobotics.co.uk/2014/03/using-pi-co-op-general-purpose-io-board-raspberry-pi/ http://blog.dawnrobotics.co.uk/2014/03/using-pi-co-op-general-purpose-io-board-raspberry-pi/#comments Sat, 15 Mar 2014 08:04:02 +0000 http://blog.dawnrobotics.co.uk/?p=496 We released the Pi Co-op, an Arduino add-on board for the Raspberry Pi back in the middle of January. But for various reasons, we haven’t had the time to do much promotional work, and explain to people why it’s so cool, and why you’d actually want to add an Arduino to your Pi. To fix […]

The post Using the Pi Co-op as a General Purpose I/O Board for the Raspberry Pi appeared first on Dawn Robotics Blog.

]]>
We released the Pi pi_co-opCo-op, an Arduino add-on board for the Raspberry Pi back in the middle of January. But for various reasons, we haven’t had the time to do much promotional work, and explain to people why it’s so cool, and why you’d actually want to add an Arduino to your Pi.

To fix that, we’ve created a video, because reading text can be really boring :) , and then, we’ve written this blog post to show you one of the really useful things you can do with the Pi Co-op. We show you how you can use your Pi Co-op as a general purpose I/O board for the Pi.

So now, instead of having to buy loads of different add-on boards for your Pi, you can just buy the Pi Co-op here. :) You can use it as an Analog to Digital Converter (ADC), you can use it to connect to 5V devices, you can use it to generate PWM signals, and you can use it for I2C. To top it all off, you can also control all of this functionality from a high level language such as Python.

Getting Started

It’s very easy to set up your Raspberry Pi to work with the Pi Co-op. Full details are provided in the manual, but as a quick recap, these are the steps you need to follow in Raspbian.

Open up a terminal window and run the following commands

sudo apt-get update
sudo apt-get install arduino git

This will install the Arduino IDE and some supporting Python libraries. Now run the following commands

git clone https://bitbucket.org/DawnRobotics/pi_co-op.git
cd pi_co-op
sudo python setup_pi_co-op.py install

This will alter configuration files to allow us to use the serial port on the GPIO pins of the Pi. Finish the configuration by restarting the Raspberry Pi

sudo reboot

If everything goes well, then you will now be ready to start programming the Pi Co-op.

Installing PyMata

To use the Pi Co-op as a general purpose I/O board we make use of a project called Firmata. Firmata is a program for an Arduino (the Pi Co-op is compatible with an Arduino Uno) that allows you to control all of its functionality using serial communication. The reason for doing this is, if you have a library that speaks the correct serial protocol with Firmata, then you can control the Pi Co-op with any language you want, and you don’t have to program it directly!

The Firmata Github page contains links to client libraries for most languages. For example there are libraries for Python, Javascript, Ruby and the .NET Framework, to name but a few. To show how this works, for this post we’re going to use Python and a library called PyMata. PyMata is an open source library that was written by Alan Yorinks. We’ve extended PyMata slightly so that it can also use a tool called Ino to automatically program the Pi Co-op with Firmata, if needed.

To get started with the installation. Open up a terminal window and enter the following

sudo apt-get update
sudo apt-get install python-pip python-dev python-serial
sudo pip install tornado ino

Now install PyMata by entering

git clone https://github.com/DawnRobotics/PyMata.git
cd PyMata
sudo python setup.py install

Blinking an LED with PyMata

The classic ‘Hello World!’ program to run on an Arduino is to blink an LED. The Pi Co-op has an LED so you can get it to start blinking by executing the following Python code on the Pi.

import time

from PyMata.pymata import PyMata

# Pin 13 has an LED connected on most Arduino boards.
# give it a name:
LED = 13

# Create an instance of PyMata.
SERIAL_PORT = "/dev/ttyS0"
firmata = PyMata( SERIAL_PORT, max_wait_time=5 )

# initialize the digital pin as an output.
firmata.set_pin_mode( LED, firmata.OUTPUT, firmata.DIGITAL )

try:
    # run in a loop over and over again forever:
    while True:

        firmata.digital_write( LED, firmata.HIGH ) # turn the LED on (HIGH is the voltage level)
        time.sleep( 1.0 ) # wait for a second
        firmata.digital_write( LED, firmata.LOW ) # turn the LED off by making the voltage LOW
        time.sleep( 1.0 ) # wait for a second

except KeyboardInterrupt:

    # Catch exception raised by using Ctrl+C to quit
    pass

# close the interface down cleanly
firmata.close()

When you run this program, if Firmata is already installed on your Pi Co-op then you should just see a short bit of connection text and the LED on your Pi Co-op should start blinking.

If Firmata isn’t installed on your Pi Co-op then you will see lots of text scroll past as PyMata compiles the Firmata code and uploads it to the Pi Co-op. This does take a little bit of time, but don’t worry, the next time you run the script, the connection process will be a lot quicker. Also, the compiled Firmata is cached, so that if you upload a different Arduino sketch to your Pi Co-op, then the next time you use PyMata it will just upload the already compiled version.

Code Explanation

Hopefully, if you’re familiar with the Arduino Blink sketch then the PyMata LED blink code should be fairly self explanatory. The important bits are

# Create an instance of PyMata.
SERIAL_PORT = "/dev/ttyS0"
firmata = PyMata( SERIAL_PORT, max_wait_time=5 )

This creates an instance of the PyMata class to connect to Firmata on the given serial port. The parameter max_wait_time specifies the time to wait in seconds when trying to connect to Firmata, before giving up and starting the upload process.

# initialize the digital pin as an output.
firmata.set_pin_mode( LED, firmata.OUTPUT, firmata.DIGITAL )

This line sets the LED pin as a digital output

        firmata.digital_write( LED, firmata.HIGH ) # turn the LED on (HIGH is the voltage level)
        time.sleep( 1.0 ) # wait for a second
        firmata.digital_write( LED, firmata.LOW ) # turn the LED off by making the voltage LOW
        time.sleep( 1.0 ) # wait for a second

Finally, these lines which form the body of the while loop, cause the LED pin to be written HIGH and then LOW in order to flash the LED pin.

Running the Other Examples

We’ve written a number of example scripts for using the Pi Co-op with PyMata, and put them in the examples folder of the Pi Co-op repository. The example we’ve just discussed is called pymata_blink.py, and there are also examples for reading from the ADC (pymata_analog_read.py) and controlling a servo (pymata_servo_sweep.py).

To make sure you’ve got the latest code, and then to run one of the examples, you can use the following commands

cd pi_co-op
git pull
./examples/pymata_blink.py

Taking Things Further

Using Firmata can give you a lot of flexibility when it comes to deciding how to use your Pi Co-op. If you stick with Python, then you can learn more about the functionality offered by PyMata by looking at the documentation here. Alternatively, you might decide that you want to use another language to control the Pi Co-op. There are lots of libraries to choose from, including the excellent Johnny-Five for javascript.

Also, if you’ve got any questions in general about the Pi Co-op, and how you can use it with your Raspberry Pi, then please head over to our forums, as we’re always happy to help. :)

The post Using the Pi Co-op as a General Purpose I/O Board for the Raspberry Pi appeared first on Dawn Robotics Blog.

]]>
http://blog.dawnrobotics.co.uk/2014/03/using-pi-co-op-general-purpose-io-board-raspberry-pi/feed/ 4
New Products in Stock http://blog.dawnrobotics.co.uk/2013/12/new-products-in-stock/ http://blog.dawnrobotics.co.uk/2013/12/new-products-in-stock/#comments Mon, 02 Dec 2013 15:27:54 +0000 http://blog.dawnrobotics.co.uk/?p=415 We’re now stocking some Integrated Circuits (ICs) in our store for your robotics projects. The L293D is a stalwart of many robotic projects. The are lots of newer motor drivers on the market, but the L293D’s DIP packaging and rugged design make it a great option for quickly breadboarding up some motor control for your […]

The post New Products in Stock appeared first on Dawn Robotics Blog.

]]>
L293D Motor Driver

L293D Motor Driver

We’re now stocking some Integrated Circuits (ICs) in our store for your robotics projects.

MCP3008 Analog to Digital Converter

MCP3008 Analog to Digital Converter

The L293D is a stalwart of many robotic projects. The are lots of newer motor drivers on the market, but the L293D’s DIP packaging and rugged design make it a great option for quickly breadboarding up some motor control for your project.

The MCP3008 is an 8 channel, 10bit Analog to Digital Converter (ADC) that is a very popular option for projects that need to monitor analog signals. The MCP3008 is an especially good match for the Raspberry Pi which doesn’t have an ADC built in, but which can talk to the MCP3008 using its SPI interface.

The post New Products in Stock appeared first on Dawn Robotics Blog.

]]>
http://blog.dawnrobotics.co.uk/2013/12/new-products-in-stock/feed/ 0
New Digs http://blog.dawnrobotics.co.uk/2013/10/new-digs/ http://blog.dawnrobotics.co.uk/2013/10/new-digs/#comments Thu, 31 Oct 2013 15:34:07 +0000 http://blog.dawnrobotics.co.uk/?p=317 It’s been really hectic here over the last few days, as we’ve been busy moving into our new offices, but we’re finally in, and can now get back on with making robots. We’ve been lucky enough to secure a place in the new Technology Incubator that recently opened at the Bristol Robotics Laboratory. The Bristol […]

The post New Digs appeared first on Dawn Robotics Blog.

]]>
It’s been really hectic here over the last few days, as we’ve been busy moving into our new offices, but we’re finally in, and can now get back on with making robots. :)

incubator_sign

Incubator sign

We’ve been lucky enough to secure a place in the new Technology Incubator that recently opened at the Bristol Robotics Laboratory. The Bristol Robotics Laboratory is one of the biggest and best robotics laboratories in Europe, and this move gives us much more space, and a much better environment for developing our new products.

dawn_robotics

The new office space

 

The post New Digs appeared first on Dawn Robotics Blog.

]]>
http://blog.dawnrobotics.co.uk/2013/10/new-digs/feed/ 0