c.cc

Parallel programming for the rest of us.




Download the tools you need to try doing two things at the same time on your Arduino.

We've got videos, tutorials, and books designed for the beginner. Give it a go!

Dino Disco!



Occam Pi Basics


So, today we started with the basics of Occam-pi - the parallel processing language that we will be using to automate our “Flying Mountaineer.” We first downloaded the IDE and uploaded the “Transterpreter” to enables us to run Occam-pi on the Arduino. The Transterpreter actually just provides an illusion of parallel processing, since the Arduino only has a single processor. This illusion is called “concurrency” (hint: the name of the blog :D).

Trying Occam-pi

We decided to try by making three LEDs blink in parallel (concurrently to be more accurate). This is a trivial task that does not really test our programming skills, but more our abilities in circuitry. It was a nice refresher of how to build parallel and series circuits.

See this cool video below.

Did You Know

The onboard LED is actually the same as pin 13. We found this out when we were blinking our LED on pin 13, and realized the onboard LED was also blinking, and we were not sure why, since we did not intend for it to. So, if you are wondering why you onboard LED blinks when you did not want it to, this is probably the reason.


Contemplating Flying


So, after being presented with the idea of taking an Advanced Robotics, we decided to accept the challenge and see what innovations we could make to Dr. Jadud’s and his previous students “Flying Gator” project. We are going to be branching off this project and now code naming it the “Flying Mountaineer”, how original.

We have read the paper on the past work, and we have a good understanding of what was done with the project, and where we plan to take it by semesters end.

Past Work

Dr.Jadud and his students managed to get a plane in the air, controlling linear flight by reading sensors. The plane was able to maintain flight, which is a huge step in the progress, but what they didn’t have time to do was enable GPS waypoint navigation and ground radio communication. These are the two features that we plan to concentrate on throughout the semester.

Reading into the way that they made the plane fly, we learned the about the type of hardware they were using, an ATmega1280, and software written in occam-pi. They used a series of loops rather than the single loop in the open source program ArduPilot control system, which enabled them to have many process running at the same time.

This method of control allowed them to keep the plane leveled by reading in sensor data at the same controlling motor speed during turns. Sensor data that was important to the flight of the plane was from the Gyroscope as well as the Accelerometer. They combined the data from the two sensors to maintain a level flight. Past Work

First Steps

We plan on learning how to interact with the Arduino micro-controller before moving forward with the project. We need to have an understanding of the hardware and its limitations so we can devise a well planned design and approach to planned innovations.

Did You Know

In our first session of Arduino Learning, we managed to alter the “Fade” demo, to include a blink to the LED. Once the light would fade on, we would blink off, blink on, then fade out. Although this is simple, we had trouble figuring out where to place the code as we aren’t used to programming in a loop type structure that the Arduino uses.

Here is a code snippet of how we got it to work.

/*
Fade

 This example shows how to fade an LED on pin 9
using the analogWrite() function.

 This example code is in the public domain.
*/

int led = 9;           // the pin that the LED is attached to
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup()  { 
  // declare pin 9 to be an output:
  pinMode(led, OUTPUT);
} 

// the loop routine runs over and over again forever:
void loop()  { 
  // set the brightness of pin 9:
  analogWrite(led, brightness);    

  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;
  
  if (brightness == 255){
    analogWrite(led, LOW);
    delay(500);
    analogWrite(led, HIGH);
  }
  
  // reverse the direction of the fading at the ends of the fade: 
  if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount ; 
  }     
  // wait for 30 milliseconds to see the dimming effect    
  delay(30);  
}

CCC Hackathon: occam-pi on the Raspberry Pi


So, after a long time with nothing here goes…

It seemed inevitable to us after reading about the Raspberry Pi that it and occam-pi had to be brought together, and as fate would have it several of us were able to get together in London and hack for a few days on the project in general, and the Raspberry Pi in particular during the Jubilee 4 day weekend.

Website

After a long hiatus in posting to or updating the website, we’ve finally made the move to Github Pages. We’re really excited about this, as it means we’ll eventually have a single, straightforward way to contribute either code or documentation to the project (more on this below). This also means that the code is open to all – see the project page for the gory details. Stay tuned for more website and documentation updates - pull requests welcome!

Git Repository

Another less glamorous activity which received attention at the hackathon is a move of the KRoC repository to Git to facilitate a move of the project sources to Github. We’re keen to reduce any barriers to entry for new contributors, and Github has built up a fantastic set of infrastructure and processes to aid projects. Unfortunately, there are some difficulties in conversion particular to the KRoC repositories, which have absorbed a lot of effort so far (gory details follow below).

The KRoC Subversion repository started out containing sub-projects for each of the individual components (such as occ21, ilibr, etc; as can be seen in early revisions of the repository), and at some point in the history these were (almost) all moved in under one project (as can be seen in the current trunk).

A simple svn2git import fails to keep the history before the different sub-projects were consolidated into the kroc project. There are some recipes for importing complex repositories available (Simeon Pilgrim and Graham Knop have both written some lengthy blog posts on the subject) but it looks like it could be a pretty time consuming activity to ensure that the full history of the KRoC repository is available. Once we figure out whether it is worth trying to keep the full history or leave the sub-projects history out (and refer to the original Subversion repository) then the repository will appear on Github as one of the Concurrency organisation’s repositories and will be available for general cloning.

Raspberry Pi

The Raspberry Pi is a Linux computer (just a very small one) so compiling the tools was a reasonably straightforward task. We left it compiling for some time while we sampled a few different beers and when we got back we had a full toolchain built and ready for use. Unlike some platforms (like Arduino), our port to the Raspberry Pi is ‘self-hosted’, in other words, we can compile and run occam-pi code on the Raspberry Pi directly (in fact, this has been our preferred way of working with it so far, over SSH)

Being an embedded platform, interfacing with hardware peripherals on the board is quite important. There are abstractions we can use, such as the GPIO modules contained in the kernel (that we use for the current version of the digital.module) but having a unified way of setting up/using these peripherals seems like a better way in the long run so we will look into ways we can remove some of these abstractions and do things directly from within the occam-pi modules. This is very much a work in progress though, so keep an eye out for latest updates.

Here are some obligatory concurrent blinkenlights for your viewing pleasure:

We don’t actually have stuff where they should be with the impending repository move on the horizon so drop an email to our developers’ list if you’d like to learn more.

It’s something of a tradition to run a simple occam-pi program called commstime.occ on any new port, which does nothing particularly useful other than calculate context switch times. For posterity, we’ll report those numbers here:

Sequential delta? yes
Last value received = 1000015
Time = 10686591 microsecs
Time per loop = 10686 nanosecs
Context switch = 2671 nanosecs

In conclusion the hackathon has been a great success – much (awesome) beer drunk, port completed, website ported and blinkenlights err… blinked. If you’re interested in getting involved at the (inevitable) next one, or with the project in general the best place to start is sending a mail to developers list and introducing yourself.


Arduino Uno Support!!!


After having had an [Arduino Uno][uno] sitting on my desk happily accepting programs from my development build of the Transterpreter, I thought it was finally time to get the binaries with Arduino Uno released into the wild.

Knight Rider on the Arduino Uno - concurrency.cc from clj on Vimeo.

Quick demo showing a concurrent program running on the Arduino Uno doin’ Knight Rider like awesomeness…

The reason that getting the binaries out took so long is that various other bits have gotten in the way. Changes were required to be able to build 32 bit versions of the tools on Snow Leopard; the website has moved to a new host; the Sparkle feed infrastructure (for the Mac) has been updated to include a changelog; and building software on Windows is just never fun.

But now the Arduino Uno support is finally here. Mac OS X and Windows versions should update themselves, otherwise you can download the packages from the download page. The Ubuntu packages have not yet been updated, but this should happen at some point in the future (pester Matt about this). Any problems with the packages should be reported on one of the mailing lists.

Arduino Uno support is available starting with these versions of the Transterpreter:

  • Mac OS X 20101103.1423 (dev)
  • Windows 20101104.0001 (dev) [uno]: http://arduino.cc/en/Main/ArduinoBoardUno

Ubuntu packages ready for testing


I can’t say that they’re perfect, nor can I say that they would make it into the Ubuntu repository. I made these packages, and by “made” I mean “hammered them out of a block of granite until they were so many tiny little shards of granite all over the place.” They are not art, they are not to be admired.

But, they do seem to work on the one virtual machine that I have tested them on over and over. And, so far, I haven’t removed anything from my system or left it in an inoperable state. Yet.

To use this thing of beauty

Under Ubuntu, you should be able to install our package and have all requirements automatically installed. Java, some tools for Arduino programming, and a number of other packages end up being installed. To get started, you need to add our dev repository to your apt sources:

sudo vim /etc/apt/sources.list

(Feel free to use your editor of choice.) Next, you need to add our repository. This depends on your version of Ubuntu; you can find out what to use by running the following:

uname -a

  • Lucid Lynx (10.04), amd64
    This is a 64-bit version of the most recent Ubuntu. Add this line:

    deb http://download.transterpreter.org/files/dev/ubuntu/lucid/amd64 binary/

    64-bit packages will be updated after OSCON.

  • Lucid Lynx (10.04), i386/686
    This is a 32-bit version of the most recent Ubuntu. Add this line:

    deb http://download.transterpreter.org/files/dev/ubuntu/lucid/i386 binary/

  • Jaunty Jackalope (9.04), i386/686
    This is a 32-bit version of the last version of Ubuntu. Add this line:

    deb http://download.transterpreter.org/files/dev/ubuntu/jaunty/i386 binary/

After you add that to your sources.list, you should be able to run:

sudo apt-get update

You can install our meta-package, which will pull in several more:

sudo apt-get install occam-pi

This pulls in packages for a native version of occam-pi, a version running on our virtual machine (called the Transterpreter), a version for the Arduino, and a plug-in for jEdit that we call occPlug. they are all prefixed with the name occam-pi, so they are easy to find if you want to get rid of them.

Note: We will, someday, be updating these packages, or even (hopefully) getting source packages into the Ubuntu repositories. When that happens, the repository you just added will need to be removed. But, we don’t expect that to happen before the new year, so rest easy.

Using occam-pi

On the command-line, type:

jedit

Now, go to the Plugins menu, find occPlug, and say Start occPlug. After it opens up, close jEdit.

After you have started the occPlug, and closed jEdit, go ahead and open it again and continue. (The first time you run the occPlug, it does some configuration that we shouldn’t do in the package.)

At this point, you can start exploring the book… but, note, it needs some updating. That’s next on the list as we finish getting ready for OSCON. In the meantime, you can look at the examples in our OSCON examples directory, which all work against the newest versions of Plumbing.

Let us know how you get on on the users mailing list; your feedback is very welcome.


⇐ Previous Page Page 4 of 7 Next Page ⇒