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 - FAIRCHILD SEMICONDUCTOR QRD1114
  • 1 - FAIRCHILD SEMICONDUCTOR LM339AN
  • 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.
image
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).
image
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.

image

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() {      
  Serial.begin(57600);      
  Serial.println("Starting...");      
  leftServo.attach(5);      
  leftServo.writeMicroseconds(1600);      
  attachInterrupt(0, leftRSISR, FALLING);      
  chargeRS = false;      
  MsTimer2::set(2, chargeRSISR); // 2ms period      
  MsTimer2::start();      
}

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) {      
    Serial.println(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.

Arduino

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

Robots

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.

Background

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 http://www.rbgrn.net/content/21-how-to-choose-dlna-media-server-windows-mac-os-x-or-linux.  This list was compiled in 2007 but had been updated recently.  Wikipedia has a list at http://en.wikipedia.org/wiki/List_of_UPnP_AV_media_servers_and_clients.

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 http://upnp.org/sdcps-and-certification/resources/sdks/.

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 http://opentools.homeip.net/dev-tools-for-upnp.  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.