Wednesday, December 28, 2011

aBot – Wheel Encoder Mystery Solved Again

Short story:

I was wrong.  The waves formed by the sets of peaks and valleys was not due to the wheel being untrue.  It appears to have been a combination of:

  1. The reflectance sensor being too far away from the encoding disk.  Needs to be 1mm to 2mm away from the encoder disk.
  2. The width of the white and black stripes on the disk being too narrow.  I believe this causes a higher low reflectance as the sensor gets reflection from a mix of white and black and not just black.

Long story:

On Thursday, December 22 my parts for the new wheel encoder came in.  Given it was 3 days to Christmas I didn’t get a chance to work on things until a couple days later.

I wired up the QRD1114 to an analog pin and collected some data.  What I found when I plotted it was a similar double wave pattern that I had seen with the QRT-1RC. 

As you can see from the graph from my post, aBot – Wheel Encoder Mystery, the highest valleys are higher than the lowest peaks.  This created a problem as there was not one voltage that could be fed into the comparator.

I spent parts of the next two days trying to figure out how to fix the problem and get a consistent set of peaks and valleys. 

As I thought my problems were caused by the wheel being untrue I experimented with other wheels.  No matter what I tried it didn’t solve the problem…

I thought maybe it was because I didn’t have the disk centered on the wheel so I adjusted the disk on the wheel.  Still no solution…

I tried placing the sensor at different distances from the wheel and double checked the datasheet.  I found as I put the sensor closer to the wheel I got a more consistent baseline for the valleys.

I found I need to put QRD1114 1mm to 2mm from the encoder disk.  Peaks are still all over the place and the voltage difference is too low…

I tried varying the speed of the motor turning the encoder disk.  The time between peaks and valleys increased as was expected.  The peaks are still inconsistent and too low…

I was running out of things to change…

On a whim I reduced the number of white and black stripes.  I dropped from 64 (32 black / 32 white) to 24 (12 black / 12 white) and was on to something…

The peaks were much more consistent peaks and much higher.

I was stumped if it could handle 24 transitions at high speed why couldn’t it handle 64 transitions at well below half the speed.  I played around with the timing a bit more before deciding that it must have to do with the size of the white and black stripes on the encoder disk.

I was using a disk that was just under 3”.  As a result on the 24 stripe disk the size of the white and black stripes was around 10mm.  On the 64 stripe disk the size of the white and black stripes was only 3mm.  My hypothesis is that with the narrower stripes the reflectance was based on a mix of white and black while with the larger stripes it wasn’t and therefore resulted in a higher peak.

To test this I created a 6” disk with 64 transitions on it and it appears to be correct.  With the larger disk the stripes end up being 6mm and the QRD1114 has a consistent baseline of valleys, consistent peaks, and a significant voltage difference between the peaks and valleys.

Sunday, December 18, 2011

aBot – Wheel Encoder New Design

Tonight I am toying around with a new design for the wheel encoders suggested by someone on the Arduino forum.
It consists of two QRD1114 sensors, one for each wheel, fed into an LM339 with two 5K trim pots to allow for adjusting the sensitivity.  The outputs from the LM339 go two two digital pins on the Arduino.

The parts list looks like this:
  • 2 - TRIMMER, POT 5KOHM 23TURN THD T93XB-5K-10-D06
  • 2 – 220 Ohm Resistors
  • 2 – 10K Ohm Resistors

Saturday, December 17, 2011

aBot – Wheel Encoder Mystery Solved (or So I Thought)

This morning I solved the mystery of the second wave.  It turns out the wheel is not exactly true and therefore as it rotates the distance between the sensor and the encoder disk varies slightly. 
How this affects the values is that as the distance varies the reflectance for the white and black lines increases when the sensor is closer to the disk and decreases when the sensor is further away.  This in turn consistently increases or decreases the discharge times for the capacitor which causes the peaks and valleys to form a wave as the wheel rotates.

Thursday, December 15, 2011

aBot – Wheel Encoder Mystery Part 2

I wanted to post some additional information on the wheel encoder development.  I have included a picture and a schematic of the setup I am using for testing purposes.
The QTR-1RC digital reflectance sensor is positioned over the wheel (1) with vcc, gnd and signal connected to the breadboard (2) and finally the signal line is connected to pin D2 (3).
All of the grounds: the servo, the +6V power supply, the QTR-1RC, the Boarduino and the +5V power supply are tied together.

Monday, December 12, 2011

aBot – Wheel Encoder Mystery

Tonight I started working on the wheel encoders for aBot.

I assembled one of the XWheels and put the 64 segment encoder disk shown below on the back of it.  I found the encoder disk on the Robot Gestation website in a very good article on IR Sensors.


I mounted the wheel on one of the servos and clamped the servo in a vice so that the back was pointing up.  Above the wheel I positioned one of the QTR-1RC sensors and wired it back to the Boarduino with the signal pin connected to the d2 pin.  I connected the servo to four AA batteries and connected the signal pin from the servo to the d5 pin.

The next step was to create a simple sketch which would both drive the servo and charge the reflective sensor and record the amount of time it took for the sensor’s signal pin to go from high to low.

Arduino Sketch

#include <MsTimer2.h>     
#include <Servo.h>
#define RRSPIN 3

Servo leftServo;

volatile boolean chargeRS;
volatile unsigned long leftRSStartTime;     
volatile unsigned long leftRSTimer;

void chargeRSISR() {      
  chargeRS = true;      

void leftRSISR() {
  leftRSTimer = micros() - leftRSStartTime;      

void setup() {      
  attachInterrupt(0, leftRSISR, FALLING);      
  chargeRS = false;      
  MsTimer2::set(2, chargeRSISR); // 2ms period      

void loop() {
  if (chargeRS) {      
    pinMode(LRSPIN, OUTPUT);    // make line an output      
    digitalWrite(LRSPIN, HIGH); // drive line high       
    delayMicroseconds(10);      // charge line      
    pinMode(LRSPIN, INPUT);     // make line an input      
    leftRSStartTime = micros();      
    digitalWrite(LRSPIN, LOW);  // disable pull-up!      
    chargeRS = false;      
  if (leftRSTimer) {      
    leftRSTimer = 0;      

When I ran the sketch I expected to see the amount of time for the capacitor on the reflective sensor to discharge would vary depending on if the sensor was over a black or white stripe on the wheel.
I have to say when I graphed the results I was a bit surprised.


The difference between capacitor discharge times over the black and white stripes showed up.  As expected the faster the wheel rotated the narrow the width of the intervals was.

What surprised me as that the series of discharge intervals change forming a second set of peaks and valleys that also decrease in width the faster the servo spins. I am not exactly sure what causes this “macro” interval.

More to follow…

Robot Project – aBot (Arduino Robot)

I have decided to call my current robot project aBot for Arduino Robot.  As I shared in my last post I am going base to be using the Budget Robotics’ ArdBot Chassis

Here is the parts list as it now stands:

  1. Budget Robotics ArdBot Chassis
  2. Pair of Budget Robotics XWheels
  3. Adafruit Boarduino
  4. Two Pololu Digital Reflectance Sensors (QTR-1RC)
  5. Two Sparkfun Large Full Rotation Servos (ROB-09347)

I expect I will add a few more things as the project progresses.

The first step is to develop wheel encoders using the Pololu Digital Reflectance Sesnors.

Sunday, December 11, 2011


A couple of years ago my daughter, who at the time was 12, attended a program to stimulate interest in math, science and engineering where she got a VEX Robot Kit.

When she got the kit we decided that it would be a good father / daughter activity to put the robot together.  Over a couple of evenings and a weekend or two we put the robot together and then put it through its paces.

We had a good time but it wasn’t something that really caught my daughter’s attention.  My daughter tends to be more a “Right Brain” person at home with the creative process and the arts.

I have always enjoyed building things.  When I was growing up one of my favorite toys was an original erector set which was a hand me down from my father.  The VEX kit reminded me of that erector set but on steroids and it didn’t take much until I was hooked.

One of the things that interests me most about robotics is that it takes computers and programming which I enjoy working with and combines that with the physical world.  This synthesis gives me an opportunity to write software that interacts with the physical world.

Soon after completing the base robot from the kit I purchased a copy of RobotC which works with the VEX and started writing programs to control the robot.  This led to my first autonomous robot.

My first robot was a VEX Squarebot.  Along with the standard components I had also picked up a set of VEX optical shaft encoders and a VEX ultrasonic sensor.  The robot’s “brain” was the VEX PIC Microcontroller programmed using RobotC.

About a year later I developed my second generation robot.  This one was a hybrid using some VEX parts and some other parts.  The “brain” this time was a breadboard Arduino using an ATmega328p and programmed using the Arduino IDE.

In mid November I decided to develop my third generation robot.  The goal this time was go lower cost and a more compact size.  This time I plan to once again use an Arduino.  After looking around I decided to try the Budget Robotics ArdBot Chassis which is both low cost $14.95 and compact.

Over the next couple of months I plan to document my progress with this project.

UPnP / DLNA AV Software

This is an update on one of the project areas that I spent a good deal of time working on during October and early November.


As I mentioned in my last posting I had recently acquired a WD TV Live Plus.  This device allows you to play picture, video and music from your computer through your TV.  Along with supporting network shares the WD TV Live Plus support UPnP and DLNA Media Servers.

After running through some slide shows using a drive mapped from our home PC based picture repository I decided to see what UPnP and DLNA Media Server had to offer.

UPnP is Universal Plug and Play is a set of protocols for small networks networks that allows devices on the network to discover each other to communicate and share data.  UPnP is promoted by the UPnP forum.

UPnP AV is an audio and video extension of UPnP which includes Media Server, Media Renderers and Control Points.

DLNA stands for the Digital Living Network Alliance which is a non-profit trade organization started by Sony to define interoperability guidelines for sharing data between consumer devices.  These guidelines build upon UPnP.

More information on UPnP and DLNA can be found in Wikipedia.

Complete Media Servers

A quick search using Google turned up a number of UPnP and DLNA compliant media server running on Windows, Linux and Mac.  Along with these software solutions there were a number of devices that could share out picture, video and music to a home network.  Finally there were a number of Network Attached Storage (NAS) that include UPnP and DLNA media server functionality.

In the software category there were Opensource, Freeware and Commercial offerings.  I found a good list that contained a number of systems at  This list was compiled in 2007 but had been updated recently.  Wikipedia has a list at

I installed and tested a number of systems including:

Windows Media Player – Windows Media Player (WMP) 12 comes with the capability to share your media on the network.  The sharing capability is UPnP / DLNA compatible.  WMP worked with the WD TV Live Plus device as well as several other clients.  However, it really didn’t give you any option to configure the look and feel.

XBox Media Center (XBMC) – The focus of this opensource software is running a home media center.  It can also serve media up to UPnP compliant devices.  The issue with XBMC is that it is first and foremost meant for driving your home media center PC and only will serve up media when it is running on the console.

MediaTomb – This looks to be an excellent program.  Unfortunately for me it only runs under linux so in order to use MediaTomb I would have to stand up a linux server which wasn’t something I wanted to do at this point.

Tiversity – Tiversity is a commercial product which has a basic version that is free.  The free version is very comprehensive and provides access to external media sources via the Internet.

All of these programs worked and I was able to access pictures, video and music from my PC using the WD TV Live Plus device and other clients including WMP.  However with the exception of MediaTomb the servers didn’t provide the level of customization I was looking for.

The next step was to look into libraries and frameworks that support developing UPnP / DLNA Media Servers.

Media Server Libraries / Frameworks

The UPnP Forum has a good listing of libraries both commercial and opensource for developing UPnP / DLNA compatible software at

I experimented with the following:

Intel – Intel has an excellent toolkit which is a must have for anyone trying to develop UPnP software.  It can be found at  It has several very useful utilities as well as a tool for generating basic UPnP devices in c, c++ and C#.

I used the Device Sniffer, Device Spy as well as the AV Media Server extensively in testing a debugging other frameworks.  I was also able to compile the device templates using MS Visual Studio 2010 Express.

Herqq UPnP – Herqq UPnP (HUPnP) is a Qt based UPnP library.  I got it installed and was able to get the Media Server to compile and run.  While it worked well with several UPnP clients I was using for testing it didn’t work with the WD TV Live Plus device due to a but with the WD TV Live Plus and escaping XML. 

As the program was cleanly written and well documented I was able to develop a patch that made the software usable with the WD TV Live Plus.  In working with this library I exchanged several emails with its creator who was ready and willing to help me making my modifications.

QT-BRisa – This is a project that was started in 2007 to develop an API for Qt to ease development of UPnP devices and control points.  I have some experience with Qt and got QT-BRisa installed and was able to compile the media server example but was unable to get it to run.

Coherence – Is a Python toolkit.  I have very minimal experience with Python.  I tried without success to get this up and running on Windows.

Two Wild Cards and the Way Forward For Now

Well into my work in this area I came across a perl based DLNA Media Server pDLNA.  The code is well organized and actively being developed by Stefan Heumader.  It is being developed on Linux and unfortunately it didn’t run right “out of the box” on Windows due to problems with the Windows Thread Model.  However, with some changes some help from Perl Monks and Stefan I was able to get a very basic version up and running on Windows.

Over time I hope to be able to take what I have and get to a state where there is a fully operational Windows version either as a patch that might get integrated back into original version or as a fork.

My next discovery was Serviio which is a free media server that runs on Windows, Linux and MAC and is written in Java.  I was able to get this software running and customize it to the point where I have something that is useable with the WD TV Live Plus and my media collection.  I plan on using this until I am able to get to a point with the perl based media server that it is full featured enough for general usage.

Wednesday, October 5, 2011

It Worked for Me - Network Media Player

I have been looking for a way to easily display digital images on a TV so that we can share pictures of our trips and vacations with friends and family.

In the past I had looked at using the Opera browser on the WII and couldn’t find a way that I could pull picture easily from the systems on our home network and display them on the TV. I had done some work with placing a PC by the TV but that was really overkill.

I ran across an inexpensive Network Media Player from Western Digital.  The WD TV Live Plus is a device that allows you to access movies and pictures on a TV or HDTV.  I purchased the device for $99.99 from Micro Center.

The box is 4” x 5” x 1.6” and has:
  1. A infra-red remote
  2. Two usb ports
  3. An HDMI 1.3 port
  4. Ethernet
  5. An optical port
  6. Componsite / Component Video
  7. Stereo Audio
It supports 1080p HD a number of video, photo, audio, playlist and subtitle formats.  It also supports a number of online services including Netflix, Hulu, YouTube and Facebook.  It supports local content via mapping to windows shares as well as UPNP DLNA Servers.

An initial test run with this summer’s vacation pictures went off extremely well. The pictures were pulled from a share on our home network.

All I had to do was plug the device into the network, and plug it into  the TV and did some very minimal configuration to setup a username and password and was ready to show the pictures.

I have done some other playing around with the device and have been pretty pleased with it.  I have been able to use it with Windows Media Player and several other UPNP servers.

The only problem I have encountered so far is that it appears that the WD TV Live Plus device has a problem with XML that is escaped specifically to the XML standard which doesn’t require “>” to be escaped with an &gt;.  I ran into this while testing a UPNP server.

Next up UPNP servers.

Saturday, September 10, 2011

Openframeworks - ofxPUI

ofxPUI is an Open Frameworks addon for building user interfaces with the PUI c++ classes. It has been tested on Windows but should run on Linux and Mac OS as well.

Base Software

OpenFrameworks is a cross platform open source toolkit for creative coding in C++.

PUI: A Picoscopic User Interface - The Picoscopic User Interface (PUI - pronounced 'poohey') is a simple set of C++ classes that allow programs written in GLUT and OpenGL to create buttons, sliders, menus etc.


To use ofxPUI, first you need to download and install Open Frameworks.

To get a copy of the repository you can download the source from or, alternatively, you can use git clone:

git clone git://

The addon should sit in openFrameworks/addons/ofxPUI/.

Next you will need to download the source for PUI which is included with PLIB and can be downloaded from SourceForge at

You will need to copy the following directories from the PLIB distribution: fnt, puAux, pui, sq and util to openFrameworks/addons/ofxPUI/src/.

Files from openFrameworks/addons/ofxPUI/src/ should be recursively added to you openFrameworks project with the src, fnt, puAux, pui, sq and util directories added to the Compiler include path.

ofxPUIexample.cbp is a Windows Codeblock's project that should compile the example project.

Openframeworks – A Much Deserved Introduction.

Looking back over my posts I cannot believe that I don’t have a post dedicated to this outstanding c++ library.

Quoting from the Openframeworks website:

Openframeworks is a c++ library designed to assist the creative process by providing a simple and intuitive framework for experimentation.

I first came across this library while working on my Bicycle Trainer project in March last year (2010) and since then have used it as part of a number of projects.

Openframeworks makes developing interactive graphic projects extremely easy.  It has routines that make accessing an Arduino from you host of choice (Linux, Windows or MAC) down right simple.  It also has interfaces to a number of additional libraries.

It has an extremely active user community that is enthusiastically supported by a core group of developers, Zach Lieberman, Theo Watson and Arturo Castro and a number of others.

If you are looking for an environment to do anything with interactive graphics or interfacing with an Arduino or a number of other things you should really try Openframeworks.

Time Flies – January to September 2011

It has been a long while since my last post.  During this time I have worked on a number of things.

February – Programmatic access to Bluetooth, accessing DLLs generated with MS Visual C++ in MINGW, and wiimote coding.

March and April – An extension for Openframeworks to access the Picoscopic User Interface named ofxPUI.

April – A very simple interactive graphics framework in QT.

May – QT and wiimote using libwiiYourself.

July – Reconstituted work with the Arduino and RFM12 along with some work with Arduino and SD Cards.

August – gstreamer on Windows 7 and UPnP Servers for Windows 7.

My plan is to post some articles based on this work over the next couple of weeks.  We will see how it goes.

Sunday, January 2, 2011

Quick Note - Windows - Hiding User Accounts on Logon Screen

In regedit go to HKEY_LOCAL_MACHINE\Software\Microsoft\ WindowsNT\CurrentVersion\Winlogon

In the left panel, right click on Winlogon, select New and then select Key.

Type SpecialAccounts and press Enter

In the left panel, right click on SpecialAccounts, select New and then select Key.

Type UserList and press Enter.

In right panel of UserList, right click on a empty area, select New then select DWORD (32bit) Value.

Type in the name of the user account that you want to hide and press Enter. eg: Hidden Account.

In the right panel, right click on the user account name, select Modify and then:
  • To hide the user account – enter 0 (zero) and click OK.
  • To show the account – enter 1 and click OK.