May 22, 2012

A Quick Prototype

I built the robot outlined below, but ran into issues with CPU scheduling and motor response.  There are a number of steps that can be taken to mitigate this (such as prioritization or using a real-time kernel), but I decided that for my application, I'd like have more functionality in the motor controller software.  I'm currently working on a new voltage regulator / motor controller board and will be implementing my control software on it.  The SparkFun controller is very easy to use and this configuration may work for someone else, so here are my notes from the build.

The robot consists of the following parts:
  1. BeagleBone
  2. Magician Chassis
  3. Serial Controlled Motor Driver
  4. Logic Level Converter
  5. 7905 5v regulator, 0.33pf and 0.1pf capacitors
  6. 6 AA batteries in a battery holder
  7. breadboard
  8. lots of wire

The assembly is relatively straightforward, although getting the level converter and serial port working took a bit of research.  Thankfully these subjects are thoroughly covered on GigaMegaBlog.

Here is a wiring diagram.  (Fritzing didn't have the serial motor controller, but the part I substituted has a similar layout):

You can download my Fritzing file from here if you want to take a closer look.

Once the robot is assembled and wired, we can power it up and begin testing.  One important point covered on GigaMegaBlog is that the default software configuration for the serial pins will need to be changed.  You can do this by running the following commands as root:

echo 20 > /sys/kernel/debug/omap_mux/uart1_rxd
echo 0 > /sys/kernel/debug/omap_mux/uart1_txd

Another important point is that serial port 1 is located at /dev/ttyO1 (that's capital 'O', not zero).  For testing, I fired up minicom for the first time in at least 10 years, and configured it to use the correct tty without hardware flow control.  Now you can simply enter the motor controller commands listed in here, i.e.


and press enter.  You should now have motor one spinning in the forward direction at half throttle... somewhat like this (please pardon the ethernet tether):

May 3, 2012

BeagleBone Disk Performance

The microSD card that came with my BeagleBone was a Kingston 4GB, and it has stood up well to frequent re-imaging and on-device development.  When I decided to get a second card, I did a little research and chose the SanDisk 4GB microSDHC (model SDSDQY-004G-A11A).  I also picked up a Team 16G USB flash drive (model TG016GF108N3), which I use for build directories.

Here are the results from running Bonnie++ on the BeagleBone:

While the huge performance increase of the usb drive dominates the graph, system performance during normal usage (loading applications and and saving files) feels dramatically better with the new microSD.

April 28, 2012

Remote BeagleBone GUI with Squeak and VNC

In my last post, I gave a brief demonstration of installing and using Squeak smalltalk on the BeagleBone.  In this post, I'd like to show you how to install VNC and configure the BeagleBone to automatically start Squeak on boot.  Squeak has a native smalltalk VNC client and server available, which gives you the ability to leave your graphical environment running after disconnecting from the BeagleBone.  By adding Squeak to the boot process, the programs we write will be automatically started and our development environment will always be available.

* If you don't have a working X11 desktop or just want to try the example from the previous demo using VNC, you can download a VNC enabled Squeak image here and skip the first step.  The default password is "beagle" (without the quotes).

Step 1: Install VNC in Squeak

Login to your BeagleBone using ssh and start Squeak as demonstrated in my previous post.  Once Squeak is running you can follow along with this video:


Step 2: Configure Squeak as a service

Now that the Squeak image has been prepared for VNC access, we can add it to Systemd so it will be started as a service.  Run the following commands from the BeagleBone CLI as root:

cd /lib/systemd/system

Next we will configure the Squeak service to automatically start at boot time:

systemctl enable squeak.service

We can also start it on our currently running system:

systemctl start squeak.service

Step 3: Connect with a VNC client

The Squeak VNC server will now be running on your BeagleBone and you can connect with a VNC client.  I normally use the 2.0 release of cotvnc on OS X, but for this next demo I'll use Vinagre, which is installed by default on Ubuntu Linux:

VNC doesn't allow us to resize the remote GUI, but we can use the following procedure to resize with X11:
  1. save and quit from the VNC session
  2. login to the BeagleBone via ssh with X11 forwarding
  3. start Squeak as demonstrated in my previous post
  4. resize the GUI to the preferred dimensions
  5. save and quit
  6. run "systemctl start squeak.service" from the CLI to restart Squeak as a service

April 20, 2012

Smalltalk on the BeagleBone

If you've ever struggled with (or simply tired of) the tedious code-compile-upload-boot-test-debug-code-compile... cycle of creation on the arduino, this may be the platform you were looking for.  Running Squeak smalltalk on the BeagleBone allows you to create your software and interact with your hardware while it is running.

Smalltalk is an easy to use programming environment that also happens to be very powerful.  It is used for everything from embedded devices, educational programming, and 3D Online Worlds to semiconductor manufacturingstock trading, and international shipping.

For this quick introduction, I'm going to show how to connect a photoresistor to the BeagleBone and display it's value in a real-time graph, in 11 lines of code.  To follow along you will need to have:
  •  BeagleBone
  •  breadboard
  •  photocell and 10kΩ resistor
  •  desktop or laptop computer with a network connection to the BeagleBone

Since the BeagleBone doesn't have a video output and we're going to be working in a graphical environment, we need to use an alternative. Here are a few options:
  1. Buy a DVI or LCD expansion board.
  2. Use VNC to remotely display the smalltalk environment.
  3. Use X11 to remotely display the smalltalk environment.
I'm going to use option 3 for this demo, since is easy and can be done without modification to any of the software we are using.  X11 is pre-installed on Mac OSX and Linux.  You can get X11 for Windows, but it tends to be difficult to get running and you will probably be happier with VNC. VNC adds some very useful functionality and is what I use for most of my BeagleBone development.  I'll cover VNC in my next post.

Step 1: Build the circuit

The electronics components needed for this demo consist of a photoresistor (aka photocell) and a 10kΩ resistor that I picked up from my local Radio Shack.  Of course you will also need some bits of wire ( I'm using jumper wires, which aren't a bad investment).  Using these components, we'll build a pull-down circuit.  Here is a breadboard view from Fritzing:

The BeagleBone pin connections are as follows:
  1. Header P9 Pin 32 to one end of our photocell
  2. Header P9 Pin 39 to the other side of the photocell along with one end of our resistor,
  3. Header P9 Pin 34 to the other end of the resistor.

Step 2: Configure the BeagleBone

I am using a 5V wall adapter and an ethernet cable connected directly to my Mac for this demo.  I've enabled Internet Sharing which has assigned the IP address to my BeagleBone. To use X11 forwarding on the BeagleBone we need to add the xauth package.  First, login to your BeagleBone with ssh from a terminal window:

ssh root@

Now that you have a root shell, run the following:

opkg update
opkg install xauth

Next we can install Squeak:

mkdir /opt
cd /opt
tar xvzf squeak4.2-beaglebone.tgz

Now you are ready to follow along with the video.

Step 3: Play

Here is the smalltalk code I used for this demo:

graph1 := GraphMorph new.
graph1 openInWorld.
graph1 extent: 700@500.
graph1 clear.

analog1 := FileStream readOnlyFileNamed: '/sys/devices/platform/tsc/ain1'.

[1000 timesRepeat: [
 | lightValue |
 lightValue := (analog1 contents) asInteger.
 graph1 appendValue: lightValue.
 (Delay forMilliseconds:50) wait.
]] fork.