Pages

Tuesday, August 19, 2014

RFduino and Bluegiga’s BLED112

DSCF7953

Last December I found that my local MicroCenter had the RFduino in stock and as I am interested in low energy wireless I purchased one.  Using a Sparkfun FTDI 3.3V and a customer cable I built I was able to download sketches to it.  This work is documented in my Worked For Me – RFduino post.

After setting up the Arduino IDE as described on the RFduino website I was able to successfully compile and download the AdvertisementContinous example and scan for the results on my Nexus 7 table using the BLE Explorer Scan application.

After this success the next step was to develop a simple program to receive data from the RFduino via BLA.  As I am much more comfortable with C rather than Java I decided to get a simple C program up and running before I tackled Android.

This started me down what turned into a multi-month side trip.  As Windows 7 doesn’t support bluetooth low energy with the regular bluetooth driver I decided to use Linux.  Unfortunately while Linux does support BLE getting it to work was rather involved.  After several false starts I was able to make some progress with gatttool which maybe some day I will post.

I had come across Bluegiga’s BLED112 Bluetooth USB dongle which at a high-level conceptual level is a BLE device that connects via USB with a COM port interface.  Bluegiga supplies a simple SDK, BGLIB, in C that allows you to interface via the COM port to the BLE device.  Given the progress I wasn’t making I decided to purchase one from Mouser to see if I could make faster progress.

After two weeks I can say I am very happy with what I have been able to achieve.  I have successfully been able to send information from the RFduino to my Windows 7 PC using BGLIB via BLE from a C program compiled with MINGW32 included in Code::Blocks 12.11.  I am using the 1.2.2-100 version of the SDK with some minor changes due to the way MINGW32 handles packed data on Windows.

I plan to post some detailed examples in the next couple of weeks.

Wednesday, August 6, 2014

Quick Note - Raspberry Pi - Bare Metal Programming

For a while I have wanted to give bate metal programming a go on on of the development boards I have.  Back in college one of my favorite courses was assembler.  Back then I was programming on a PDP 11/34 that supported multiple users with fewer resources than a Raspberry Pi.  Over the past weekend the weather and my todo list cooperated and I decided to give it a try.

Thanks to the wonderful Raspberry Pi community there is no shortage of resources to get you started.

These include:

An excellent complete online course called Baking Pi – Operating Systems Development on the University of Cambridge’s website.  This course walks you through 11 exercises with very good explanation and full examples.  The code is in assembler and uses the GNU Toolchain.

A series of three articles on www.valvers.com website that walk you through bare metal programming in C.  Again the content is excellent with step by step instructions and examples.

A wiki page on OSDev.org titled ARM Raspberry Pi Tutorial C gives more involved example in C that produces text output on the console port.

Another resource I found useful was Embedded Programming with the GNU Toolchain  This document is more general in nature but also helps to drive home a number of salient points including detail on the C startup and memory initialization process.

I was successfully able to download and install the GNU toolchain from launchpad.net on to my Windows 7 Pro desktop, successfully compile the examples in the www.valvers.com set of articles and the OSDev.org wiki page and copy them to an SD card where I had rename kernel.img to kernel.old and substituted my program.  When I inserted the sd card into my Raspberry Pi and turned the power on all the programs successfully ran.

For the OSDev.org wiki example I used a USB BUB connected to pins 13 – 15 on the Raspberry PI GPIO connector and putty running on my desktop to display the output

Time Flies - March - July 2014

It has been rather quiet around here.

I have been working on a bunch of stuff but nothing that has gotten far enough along to write a post about.  One big area I spent a lot of time on was Bluetooth Low Energy both from Linux on the pcDuino running Arch Linux and from Android on the Nexus 7.

I also started having PC problems and ended up building a new desktop computer.  The new computer is built with an AS Rock Z87M Extreme4 motherboard and an Intel i5-4670K processor.  The rest of the parts were scavenged from equipment at hand.

The PC has worked mostly OK for the last three month.  I had some fits with getting USB 3.0 to work on the motherboard which turned out to be a driver issue and the stock fan that comes with the processor isn’t able to keep the processor cool enough running under extreme load but that fortunately doesn’t happen with normal usage.  I have also had problems with finding a reasonably priced power supply with a quiet fan that stays quiet.

More to come soon, hopefully.

Sunday, March 2, 2014

Bicycle Trainer - Take 2

Back in June of 2010 I posted of my work done during winter 2009/2010 to create an interactive bicycle trainer.  Four years later here is an update of where I have gotten.  The work below was done during the winter 2012/2013 and winter 2013/2014.

After two winters of occasional work I now have a truly interactive experience for riding when it gets dark early to make riding during the week dangerous.  The setup measures the speed of the rear wheel and the direction the front wheel is pointing in to display a virtual rider on the screen in front of the bike.

StartScreen

The rig for the bicycle consists of an old mountain bike mounted in a rear wheel trainer.  The front wheel is lifted off the ground using a 2 x 4 “saw horse” which supports the frame just behind the handle bars.  This allows the front wheel to be able to be turned from side to side.

DSCF5929DSCF5931

 

 

 

 

 


The electronics consists of the following:

  1. Right and left buttons for controlling the program.
  2. A Triple Axis Magnetometer to determine the direction the front wheel is pointing in.
  3. Sparkfun Bluetooth Mate Silver to transmit data from the sensors to the computer that drives the display.
  4. Sparkfun Nordic USB ANT Stick for heart rate monitor.
  5. ATmega328p

Layout

The virtual bike rider is positioned on a road.  As the pedals are turned the road moves backwards like a conveyor belt to make it appear that the rider is moving forward.  The speed is determined by how fast the pedals are turned.  If the handle bars are turned to the right the rider drifts to the right side of the road.  When they are turned to the left the rider drifts left.

The rider gains points for the more distance travelled.  The score along with the speed, miles, heart rate and time are displayed on the screen.  (I wasn’t dead when the screen shot was taken I was just riding with out the heart rate monitor.)

To make the game interesting pot holes show up on the road surface.  If the rider doesn’t steer the bike around them then they crash and lose points. 

PreCrashScreen

CrashScreen

There is an interval timer that ends the ride and displays the riders miles, time and score. The number of pot holes is configurable as is the interval timer.

EndScreen

The code for the ATmega was written using the Arduino IDE and the interactive display is driven using openFrameworks.

Below is a short clip of a two minute ride. It isn't too interesting but it does show the display in action.

Saturday, February 22, 2014

openFrameworks / sunxi MFB Update 3 (was pcDuino MFB)

These instructions are for installing the latest copy of openFrameworks for sunxi using the mali framebuffer and rather than X-windows. I used to call this pcDuino MFB but it was suggested to me that as it should run on any of the Allwinner SoCs that I change it to sunxi.

The instructions assume you are running Ubuntu and are in an ssh session and not on the console.

Make sure to read the post about changing debug levels for the mali and ump drivers or you will not get very good performance.

Install git

sudo apt-get install git

Setup your sunxi SoC system to use the Mali Framebuffer

git clone https://github.com/digitalhack/sunxi-mali.git
cd sunxi-mali
git submodule init
git submodule update
make config VERSION=r3p0 ABI=armhf EGL_TYPE=framebuffer
make
sudo make install
make test
sudo stop lightdm
sudo ./test/test


At this point you should see something that looks like this:

clip_image002

Setup openFrameworks

git clone https://github.com/digitalhack/openFrameworks.git
cd openFrameworks


Install Dependencies

sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libraw1394-dev libudev-dev gstreamer0.10-ffmpeg libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libgtk2.0-dev python-lxml python-argparse libfreetype6-dev portaudio19-dev libssl-dev libpulse-dev

Install Codecs

sudo apt-get install libmpg123-dev gstreamer0.10-plugins-ugly

Compile and run the pcDuino Hello World Program

cd ./apps/devApps/pcDuino_hello_world_gles2/
make PLATFORM_VARIANT=sunximfb
sudo ./bin/pcDuino_hello_world_gles2

At this point you should see a spinning pcDuino board on a yellow background.

clip_image004
If you have any questions or something doesn't work please leave a comment.

Sunday, December 22, 2013

It Worked For Me - RFduino

This past fall well after its KickStarter campaign had successfully completed I stumbled across the RFduino.  At the time I was looking for a Bluetooth Low Energy solution to pair with my new Nexus 7 tablet.  I very much liked what I saw.  As I had missed the opportunity to support the KickStarter campaign and had several other projects in the works I figured I would wait to hear what people had to say once it started shipping.

I kept an eye on www.rfduino.com checking on how things were going.  As the fall progressed things appeared to be moving along.  In December orders were complete to all the KickStarter backers and they were moving forward on the Pre-order shipments.  I decided that once the backlog cleared I would place my order.

Imagine my surprise when last week while searching the hobby electronics section of the MIcroCenter website I found that MicoCenter was stocking the RFduino and my local store had several in stock.  They had both the RF Digital RF Duino Teaser Kit which comes with a RFduino and an RF Digital USB Shield Accessory Board and single RFduino units.  While the RFduino Teaser Kit was priced below what buying the two modules separately would cost I determined that it looked like the RFduino could be programmed with an Sparkfun FTDI 3.3V board that I already had.

I placed a web order and picked up the unit at the store.

RFduino

Getting an initial application up and running was extremely easy. I followed the instructions in the RFduino Quick Start Guide and using the schematic of the RFduino USB Shield I was able to download a program from the Arduino IDE running on my Windows 7 computer.  I started with a simple application that just printed “Hello World” to the serial port.  When I ran the serial monitor in the IDE I got back “Hello World” from the RFduino.

The pinout between the RFduino and the FTDI board looks like this.  A .01UF capacitor is needed between DTR on the FTDI board and Reset on the RFDuino.

image

Next using the AdvertisementContinous example I setup the RFduino to let the world know it existed.  I was able to see the RFduino using the BLE Explorer Scan application available from Google Play on my Nexus 7 tablet.

I was also able to use an IOGEAR GBU521 Bluetooth 4.0 USB Micro Adapter to see the RFduino under linux using the hcitool lescan and on Windows 7 using the IOGEAR drivers and not the Windows drivers that automatically get loaded when you just plug in the adapter.  Make sure to install the drivers from IOGEAR before plugging in the adapter or you will get a set of Windows drivers that don’t work.

Over the next couple of weeks I hope to develop an application or two that makes use of the RFduino.

It Worked for Me - Nexus 7 2013

Back in July my Acer Iconia Tab A100 died.  I was rather disappointed as I had only bought it a little over a year ago.  However, it gave me an opportunity to see what had developed over the last year in the tablet space and buying something new.

After thinking about it for a while I decided that I would go with same form factor and therefore started looking at 7 inch tables.  Shortly after starting my search I started hearing that Google was going to be releasing a new version of the Nexus 7.  After looking at what else was out there I decided that the new Google Nexus 7 look like the way to go.

I decided to hold off buying one right away and then held off even longer after hearing that there were problems with the GPS.  By September it looked like the GPS bugs had been resolved and I purchased one.

Nexus-7-2013

Fast forward four months…

I have been very pleased with my purchase.  I have mostly used it for portable web browsing and email.  I have found the batter life much better than the Acer and the high-def screen is very nice.  I have fewer problems with the touch screen but I am not sure if that is that I am more accustom to using it or if it works better.

I look forward to using it in some projects.