Sunday, December 13, 2009

Quick Note – Windows Serial Port Enumeration

I am working to develop a serial port application on Windows. As part of this project I ended up wanting to code a routine to present a list of active serial ports on a PC.

What I thought would be an easy tasked turned into an evenings worth of work…

It turns out that there are a number of different ways to pull serial port information from a PC and they don’t all come up with the same set of ports.

The list of ports in some cases includes ports that are defined but not active or in some cases doesn’t include serial ports assigned to devices like modems. What a mess.

If anyone finds there way to this posting I wanted to give them a pointer to a site that helped me out a great deal. Check out Naughter Software’s EnumSerialPorts the shows 9 different ways to enumerate serial ports.

Thanks to PJ Naughter for putting this together and making it available to the rest of us.

It Worked for Me – FIOS Installation

We recently moved from Comcast to FIOS. The change was sparked by recent changes in Comcast’s cable service. We had been a long time Comcast customer and had a very good experience. However, when I compared bundled offerings from Comcast and Verizon the FIOS bundle came out better.

The week before Thanksgiving I put in a FIOS order and scheduled the installation for the next week. The day before the installation Verizon called to confirm that we would be home during the appointed window. The morning of the installation the Verizon Installer called to let us know that he would be arriving towards the middle of the installation window.

When the installer arrived we reviewed the setup. We looked at where the phone lines came into the house, the cable TV and found an appropriate power outlet that would be able to supply power to the box on the outside of the house.

It was an aerial delivery so shortly after we finished with the review another Verizon person showed up with a bucket truck and between the two Verizon personnel they installed the fiber to the house.

Overall the installation took four or five hours. The installer was very professional and even went to the trouble of having shoe covers for the inside work.

We now have a new box on the outside of the house, two phone lines moved over, three TVs connected and a new wireless Internet firewall/router. With one minor exception all parts of the installation went without a hitch. There was a problem with features on the two telephone lines which were reversed. A follow up email to customer service fixed this within 24 hours.

Two weeks after the install the TV service has been working flawlessly as has the Internet. One of the phone lines still has a problem with call forwarding.

Customizing the setup of the TV remotes and the Internet was easy to do. The Internet firewall/router even has a few bells and whistles that my previous Linksys and DLink boxes did not.

All in all a very good experience…

Time Flies – November 2009

Wow, looking back at my last post I see it was in October. November just flew by. Look for a couple of posts on activities that were squeezed in with everything else:

  • FIOS Migration
  • Garman GPS MAP 60 Acquisition
  • Hacking around with Qt
  • Arduino Robotics

Saturday, October 24, 2009

Arduino – SD Card

This afternoon’s project was to connect an SD card to an Arduino to be able to record log information on the card for later retrieval using a PC.
For the project I used an SD/MMC Mini Board from Futurelec. Futurlec has a number of interesting products which are reasonably priced. The order took a little over a month given the fact that they didn’t have the board in stock and due to international shipping. During the wait the folks at Futurelec were quite responsive to my queries via email.
I was using an atmega328p chip powered at 3.3v with an 8mhz oscillator. This made things easier as I didn’t need to worry about voltage dividers between the microprocessor and the SD card. The hardware I used was rounded out with a 512mb Kodak SD Card I had laying around.
SDCard
For software I used Bill Greiman’s fat16lib which performed flawlessly. I tested my project with fat16info, fat16write and fat16tail with version 17 of the Arduino IDE.
The only problem I had was that I missed that the SD/MMC Mini Board has two pins labeled CD. One is in fact pin 1 from the SD card while the other is Card Detect. Pin 1 from the SD card is clearly labeled as such but I missed it the first time and connected to the other CD.
The pinouts that I used are below for reference:
Arduino Pinsatmega328p PinsDescriptionSD Card PinsSD Description
1016ssel1cd/dat3
1117misi2cmd
1319sck5clk
1218miso7dat0
vcc 3.3vvccvcc 3.3v4vcc 3.3v
gndgndgnd3+6gnd
I want to thank Bill Greiman for the great library he has put together. Also, my thanks to all of you who have posted information about your projects that helped me along.

Friday, October 23, 2009

Arduino – Serial Programmer

I decided that I wanted to experiment at programming the boot loader into chips myself. This started me down an interesting path.

After spending some time with Google and based on what I had around I decided that I would build a parallel programmer. For reference I used the directions on the Arduino site for a parallel programmer.

I modified the design to include a 28 pin dip socket so I would have something to put the chip in. After putting it all together and checking the connections with my trusty multi-media I couldn’t get it to work. I played around with it and with avrdude finally giving up after running out of ideas.

I went back to the drawing board and this time settled on a serial programmer that I could build with what I had on hand augmented with some parts from Radio Shack. Using this schematic I found in the adafruit forums.

I modified the design to us a 6 pin isp connector rather than the 10 pin in the schematic. I also built a simple chip cradle with a 6 pin isp connector and a power connector.

Once I had completed building both the programmer and the chip cradle and checking them out with the multi-meter I plugged it in and…

Nothing. Avrdude running on the PC didn’t see the atmega chip.

After a good nights rest and some more time with Google I determined that my problem was that, as I was using a pre-loaded Arduino chip that was set to us an external crystal/oscillator that I needed to add one to my chip cradle.

Given the mess of wires connecting all the pins together on the underside of the chip cradle this wasn’t easy. However, soon I had a chip cradle with a socket for an external oscillator. I plugged in the oscillator and…

Nothing. Once again avrdude running on the PC didn’t see the atmega chip. Looking at the oscillator and the socket it appeared that the legs of the oscillator might be thin enough not to be making contact. A slight wiggle of the oscillator and success!

I fixed this problem by soldering the oscillator to 3 pins which fit the socket better and it has been working ever since.

Below are several pictures of the finished product.

As usual I need to thank a number of good people who have been down this path before me for marking the way with their posted results. The adafruit, Sparkfun and Arduino forums were invaluable.

Serial Programmer with DB9 serial connector.

SerialProgrammer1

Serial Programmer with Sparkfun 3.3v/5v regulated power supply attached.

SerialProgrammer2

SerialProgrammer3

Chip cradle with oscillator

SerialProgrammer4

Friday, October 2, 2009

Arduino – Light from Sound

For this project I connected a microphone via an amplifier IC (LM386N) to the Arduino to drive the Sparkfun 8x8 multicolor LED Matrix. The LED was programmed to generate random ranges of colors based on the how loud the sound is.

This week I got in an order that I had been waiting for from Futurlec and therefore I am going to put this project on hold as I have some new components I want to test out.

I am posting this mostly so I will have a record of what I had done that I can come back to.

LEDSound

Below is the amplifier on the breadboard.

LEDSoundBlowup

The code was hacked together quickly from a couple of examples.


//Define the "Normal" Colors
#define BLACK  0
#define RED  0xE0
#define GREEN  0x1C
#define BLUE  0x03
#define ORANGE  REDGREEN
#define MAGENTA  REDBLUE
#define TEAL  BLUEGREEN
#define WHITE (REDGREENBLUE)-0xA0

//Define the SPI Pin Numbers
#define DATAOUT 11//MOSI
#define DATAIN  12//MISO
#define SPICLOCK  13//sck
#define SLAVESELECT 10//ss

//Define the variables we'll need later in the program
char cleardisplay [64];
char n1 = 0;
char reddisplay[64];
char n2 = 0;
char greendisplay[64];
char n3 = 0;
char bluedisplay[64];
char n4 = 0;
char rdisplay[64];
char n5 = 0;

char color;
char clearcnt;

int val;
int amp;
int ledPin = 8;                // LED connected to digital pin 13

void setup() {
  //SPI Bus setup
  //Enable SPI HW, Master Mode, divide clock by 16    
  SPCR = (1<<SPE)(1<<MSTR)(1<<SPR1);    

  //SPI Bus setup

  //Set the pin modes for the RGB matrix
  pinMode(DATAOUT, OUTPUT);
  pinMode(DATAIN, INPUT);
  pinMode(SPICLOCK,OUTPUT);
  pinMode(SLAVESELECT,OUTPUT)

  //Make sure the RGB matrix is deactivated
  digitalWrite(SLAVESELECT,HIGH);

  for(int LED=0; LED<64; LED++){
    cleardisplay[LED] = 0;
    reddisplay[LED] = RED;
    greendisplay[LED] = GREEN;
    bluedisplay[LED] = BLUE;
  }
  color = 0;
  clearcnt = 0;
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output 

  Serial.begin(9600);
  setdisplay(cleardisplay);
}

void loop() {
  val = analogRead(1);
  amp = (val >= 415) ? val - 415 : 415 - val;
  if (amp > 30) {
    digitalWrite(ledPin, HIGH);
    if (amp > 50) {
      if (color != RED) {
        rnddisplay(RED);
        color = RED;
      }
    } else if (amp > 40) {
      if (color != GREEN) {
        rnddisplay(GREEN);
        color = GREEN;
      }
    } else if (amp > 30) {
      if (color != BLUE) {
        rnddisplay(BLUE);
        color = BLUE;
      }
    }
    delay(250);
  } else {
    if (clearcnt > 1) {
      digitalWrite(ledPin, LOW);
      setdisplay(cleardisplay);
      color = 0;
      clearcnt = 0;
    } else {
      clearcnt++;
    }
  }
}

void rnddisplay(char color) {
  for(int LED=0; LED<64; LED++) {
    rdisplay[LED] = random(9) + color;
  }
  setdisplay(rdisplay);
}

void setdisplay(char displaybuf[64]) {
  digitalWrite(SLAVESELECT, LOW);
  for(int LED=0; LED<64; LED++){
    spi_transfer(displaybuf[LED]);
  }
  digitalWrite(SLAVESELECT, HIGH);
} 

//Use this command to send a single color value to the RGB matrix.
//NOTE: You must send 64 color values to the RGB matrix before it displays an image!

char spi_transfer(volatile char data) {
  SPDR = data;                    // Start the transmission
  while (!(SPSR & (1<<SPIF))) {   // Wait for the end of the transmission
  };
  return SPDR;                    // return the received byte
}

Sunday, September 20, 2009

Arduino – Breadboard Arduino

As I have said in earlier posts I have been working with Arduino for the last several months. My latest project was to take the ATmega328 chip and assemble a very basic Arduino on a breadboard.

Using various sources found using Google I was able to assemble the breadboard Arduino in an evening and get it running a basic blink program.

ArduinoBreadboard

I found several excellent sources for parts and information which I pass along below:

Once I got all the parts and pieces the project was easy to assemble and get running. I was also able to combined this with the power supplies I built earlier to have a free standing finished product.

Monday, September 7, 2009

Simple 5V Regulated Power Supply Projects

Spent this Labor Day Weekend on a number of projects around the house but still had some time to undertake a couple of simple electronics projects.

The first project was to bread board a simple 5V regulated power supply using parts from Radio Shack and schematics from a couple of helpful websites found via Google.

The end result was a hybrid using the diagram below from http://www.tkk.fi/Misc/Electronics/circuits/psu_5v.html

and the schematic below from the Sparkfun Embeded Electronics Tutorial at http://www.sparkfun.com/commerce/tutorial_info.php?tutorials_id=57

http://www.sparkfun.com/images/tutorials/BEE-Lectures/1-PowerSupply/PowerSupply6.jpg

My design didn’t include the diode or the switch as the Sparkfun design does but did include the 0.1uF capacitor and the LED/resistor. The Sparkfun tutorial also included a diagram of the pinout for the 7805.

http://www.sparkfun.com/images/tutorials/BEE-Lectures/1-PowerSupply/LM7805-Pinout.jpg

The second project was to assemble the Sparkfun Breadboard Power Supply 5V/3.3V (Part No: PRT-00114) http://www.sparkfun.com/commerce/product_info.php?products_id=114 which arrived during the week.

clip_image001[4]

The assembly was a breeze and took less than an hour.

A word of thanks to the folks at Sparkfun for all the good information on their website, the wonderful products they make available and for the speed with which they get things out the door. I have now ordered from them twice and both times have used the USPS Priority shipping option and gotten my order the in three days of placing it.

Friday, August 21, 2009

Arduino – Amplified Speaker Project

I have been playing around with the Arduino for a couple of months. The Arduino is an inexpensive open-source electronics prototyping platform (http://www.arduino.cc/. The compilation below represents a very simple project to connect an amplified speaker to the Arduino.

The amplifier I used for this project is an LM386. The LM386 is a power amplifier designed for use in low voltage applications. It ant the other parts needed for this project , capacitors, resistors and a speaker, can be purchased at Radio Shack.

This example makes use of a Sound Hello World sketch by David Fowler to generate tones.

This also represents my first attempt at a circuit schematic using the freeware version of Eagle from CadSoft at http://www.cadsoft.de/.

My hope is that someone will find this useful and will be able to follow what I have done as I have done following the examples posted by others.

ArduinoAmplifiedSpeaker

ArduinoAmplifiedSpeaker


//Arduino Sound Hello World
//Created by David Fowler of uCHobby.com
//Define the I/O pin we will use for our sound output
#define SOUNDOUT_PIN 9

void setup(void){
  //Set the sound out pin to output mode
  pinMode(SOUNDOUT_PIN,OUTPUT);
}

void loop(void){
  //Generate sound by toggling the I/O pin High and Low
  //Generate a 1KHz tone. set the pin high for 500uS then
  //low for 500uS to make the period 1ms or 1KHz.

  //Set the pin high and delay for 1/2 a cycle of 1KHz, 500uS.
  digitalWrite(SOUNDOUT_PIN,HIGH);
  delayMicroseconds(500);

  //Set the pin low and delay for 1/2 a cycle of 1KHz, 500uS.
  digitalWrite(SOUNDOUT_PIN,LOW);
  delayMicroseconds(500);
}

Thursday, August 20, 2009

It Worked for Me - Disk Recovery Software

A couple of weeks ago a friend of mine's computer failed to reboot after a power failure. Unfortunately, there were a number of files on the computer that were not backed up.

After attempting to help him recover his system over the phone and not getting anywhere I asked them to drop it by my house.

The computer showed up a couple of days later. I plugged it in and powered it up. It started through the boot sequence and then gave up with a BSOD. The error message wasn't too much help but seemed to indicate either a memory or disk error.

Not that I expected much I swapped the memory with some I had and the system still would not boot. I moved the disk drive over to another system and found that while some of the data was available much of the data wasn't.

A CHKDSK run on the disk would get to 78% at which point the computer would lock up and need to be rebooted.

At this point I decided to see what I could recover using various recovery software. A quick google search turned up a couple of options:

  • Stellar Phoenix Windows Recovery Software
  • Data Recovery Wizard
  • GetDataBack for NTFS
  • Data Doctor Recovery NTFS
  • Nucleus Kernel for FAT and NTFS
  • Recover My Files
  • Pandora Recovery (free)
  • Testdisk (free)

The basic model that many of these software products use is that they run in a mode where they will show you the data they find on your disk but to recover the data you must buy the software.

Some packages focus on recovering deleted files or files from drives that were reformatted where others focus on drives that have hardware problems.

Each package works somewhat differently. However, most of the have a mode that will attempt to recover files within the directory structure they were stored in and a second mode where they just recover files with a guess at the file type but little else.

In this case I needed a program that was able to deal with a drive that had obvious hardware problems. The problem was that with the programs above that they would work up until they "hit" the bad spot in the drive but then they would hang the system requiring a reboot.

The problem area appeared to be right in the middle of the MFT. It turned out that only one tool Stellar Phoenix Windows Recovery Software was able to access the files that occurred in the MFT after the problem area.

I purchased the "Single User (Home User / SOHO Segment)" License for $99 off the company web site at:

After putting a new disk drive in the system and rebuilding it I was able to return with all but one or two of the files that were on the bad disk drive.

In this case we were lucky. The obvious moral to the story is to backup your critical files to another disk or CD-ROM/DVD or an online service.

However, if you do get stuck in a situation like you may want to check out Stellar Phoenix's Windows Recovery Software. I cannot say that it will work for you but it did for me.

Wednesday, June 17, 2009

Wii Fun Wrap Up - Part 5 - On Hold For Now

So after almost a month of off and on work, including a couple of very late nights, I have decided to shelve this project since I am not able to get the ease of use or the quality I am looking for.

One area I did not pursue was to hack into the Wii using one of the well publicized hacks and setup a Homebrew Channel. This would allow me to run code on the Wii with the same capabilities as official software. There were several options that looked very promising.

For now, when I want to run slideshows or videos on my TV via the Wii, I will use the Wii's Photo Channel and sneaker.net to move the images and videos from my PC to the Wii.

Wii Fun Wrap Up - Part 4 - Flash Media Players

My next step was to look at Flash Media Players. I wanted to see if there were flash options that would work for both my slideshow needs and also allow me to play family videos.

Back to google which provided me with a number of options. However, I quickly determined that most of these options wouldn't work. The problem is that the Wii's Opera Browser only support Flash version 7 and most of the flash media players required Flash version 8, 9 or even 10.

The problem according to several web sources is that the Adobe SDK required to run flash on platforms other than Windows, Linux or Mac hasn't been released. As a result the Wii Opera browser is not able to run anything above version 7.

I was able to find two FLV Players that ran, to some degree, on Flash 7. The two players were:

My next disappointment was that when I converted the Quick Time Movie generated by my camera to FLV using default settings this quality of the video degraded a great deal.

This led me down a path to better understand FLV and the software options to convert from Quick Time to FLV. After trying a number of different conversion options I finally settled on mencoder which is a video decoding, encoding and filtering tool from the OpenSource MPlayer project at:

It took me a while to settle on a set of conversion parameters but finally after much trial and error I found a set that produced nearly the same quality video.

Unfortunately, when I displayed the newly created FLV video using either FLV Player or JW FLV Player on the Wii the video would hang and/or stutter. The Wii appeared to lack the power to display the video acceptably.

I went back to the drawing board but was not able to come up with a combination that produced a video that looked acceptable on the Wii.

Tuesday, May 26, 2009

Wii Fun Wrap Up - Part 3 - Javascript/Ajax Slideshow Software

I started this activity by returning to google and doing a number of searches for javascript slideshows, javascript image gallary, ajax slideshow and finally ajax image gallary.

There were several sites that came back with 20 to 30 different options. Most were oriented towards displaying a gallery of images on a traditional website and were more complex than what I was looking for.

After much searching and reading I settled on the ones listed below and set them up to test from the Wii.

  1. Highslide
  2. Lightview
  3. Google
  4. Floatbox
  5. dojo.image.SlideShow
  6. Slideshow2
  7. Simple Controls Gallery

Generally my experiences were not as favorable as I had hoped. Several of the routines didn't work while others had some quirk that made them less than optimal.

One of the more unfortunate problems I ran into was that the Wii would issue a sound confirmation when it finished loading images. This along with the blue status bar was distracting.

Highslide

Available from: http://highslide.com/.

This software worked but the controls were awkward.

Lightview

Available from: http://www.nickstakenburg.com/projects/lightview/

I wasn't able to get this software to work on the Wii. The first time a series of images are loaded they don't display right. The next time they do.

Google

Available from: http://www.google.com/uds/solutions/slideshow/helloworld.html

This software worked but requires that images be on a server that is publicly accessible to the Internet. As I was looking for an easy way to pull photographs from my own internal server this wasn't going to work for me.

Floatbox

Available from: http://randomous.com/floatbox/home

I wasn't able to get this software to work on the Wii.

Dojo

Available from: http://www.dojotoolkit.org/

The dojo routine worked as long as you used v1.1.1. The Dojo library doesn't appear to work on the Wii's Opera Browser for any version of Dojo after v1.1.1. This caused some problems as the dojo.image.SlideShow in v1.1.1 didn't work quite right. This was fixed by taking the slideshow widget from a later verison of Dojo and running it with an earlier version of the library. Not something I would recommend but it worked. Also, the transitions were not smooth.

Slideshow2

Available at http://www.electricprism.com/aeron/slideshow/

This software is built on Mootools v1.2. I wasn't able to get this software to work on the Wii.

Simple Controls Gallery

Available at http://www.dynamicdrive.com/dynamicindex4/simplegallery.htm

This software appears to work but I didn't spend too much time with it.

After testing these applications I moved on to see what I could do from a flash perspective.

Monday, May 11, 2009

Wii Fun Wrap Up - Part 2 - Package Solutions

Based on my decision to pursue web based media servers I narrowed my Google search criteria and came up with the following candidates:

Wii Media Center X

Written in java by Red Kawa available at http://www.redkawa.com/mediacenters/wiimediacenterx/.

This software is free but is listed as Alpha or Early Alpha and has not been actively developed since Dec 2007.

Orb

A service available at www.orb.com which consists of software that you load on your PC which then sends the pictures, music or video to servers at orb which then stream it back to your Wii.

Makes use of the Flash 7 player in Opera on the Wii.

Tversity

Available from http://tversity.com/. This software allows you to stream pictures, music, videos and Internet content from a PC to your Wii.

An interesting note is that tversity is built from open source but is not open source itself. It is free to home users with an option to upgrade to a Pro version.

Makes use of the Flash 7 player built into the Opera browser on the Wii.

X-oom

X-oom Media Center for the Wii software costs $40 and is available at http://www.x-oom.com/usa/index.html. It looks to allow access to the following media files: MP3, WMA, OGG, DivX®, Xvid, MPEG2, MPEG4, WMV, JPG, BMP etc.

Wiideo Center

This project hosted at SourceForge was updated as recently as Dec 2008. It is located at http://wiideocenter.sourceforge.net/wiki/index.php/Main_Page. The software uses mencoder from the mplayer project to encode source media as flash and then download to the Wii utilizing the Opera Flash 7 player.

WiiCR

This project is also hosted at SourceForge but hasn't been updated since Feb 2007 and there has been no activity since Dec 2007.

This is by no means a complete list but rather the software I looked more closely at. Where they existed I looked at the feature sets, looked over the screenshots and read what documentation existing. I even installed it Tversity.

I didn't find any significant endorsements for any of the solutions. The one that looked the most interesting was the orb solution but I didn't really want deal with my content being hosted through someone else's server. In the end I decided to move on.

My next step was to look and see what existed in the way of javascrip/ajax slideshow components that would meet my requirements.

Wednesday, April 22, 2009

Wii Fun Wrap Up - Part 1 - Setting the Stage

Introduction

Our family got a wii fit this Christmas. It was primarily bought for others in the family as I am not much of a game player. However, I have to say that I was pleasantly surprised by the Wii. It was easy to setup, ran flawlessly and the games were fun and physically interactive.

I was especially impressed with technical capabilities of the wiimote and the balance board and also the games that had been designed around them.

While setting up the Wii I had come across the Internet channel. As there was much to explore it took me about a month and a half to get around to activating it. My interest in it was to see how I could use the Wii connected to my television set as an easy way to access media, pictures and movie clips, resident on my home network.

On an off over since then I have tried with little success to realize that goal.

To Hack or not to Hack

I started, as I do most projects, by spending time on Google to see what other folks were doing. My initial searches were turned up a number of options. The options fell into one of two categories:

  • Web Based Media Servers
  • Console Hacks

The web based media servers were more inline with my goals as they utilized the built in Opera web browser to access content from the media server which was installed on a computer connected to the home network.

The Console Hacks are a series of steps that allow you to load your own code to run on natively on the Wii. These hacks appear to provide more flexibility but require a more technical knowledge and some risk of "bricking" the Wii resulting in an device that no longer functions.

Armed with this information and not interested in experiencing the wrath of other family members if I damaged the Wii my go forward plan was to look at web based media server options.

Tuesday, January 20, 2009

Perl, SSH and Windows

I recently had the opportunity to do some development in perl to use SSH on a windows platform. When I took on the assignment I didn't realize what a lonely road I was about to head down.

Being someone who hates to reinvent the wheel I started off as often do by seeing how other people we solving similar problems. After a good deal of googling, reading in CPAN and writing a few test programs I determined that:

  • Net::SSH
  • Net::SSH::Perl
  • Net::SSH::W32Perl
  • Net::OpenSSH
  • Net::SSH2

all wouldn't work for me. There were a number of problems:

  • The modules didn't run reliably, or in some cases at all, on windows.
  • Support for deployment in a non-interactive environment was limited.
  • They didn't have support for non-password based authentication.

The solution I ended up going with was to create a simple patch for OpenSSH compiled under Cygwin and then run using Open3.

The hack to OpenSSH was made to the readpass.c routine and forces OpenSSH to read from stdin if an environment variable is set. Reading the code this behavior should happen based on the following comment:

If RP_ALLOW_STDIN is set, the passphrase will be read from stdin if no tty is available

but this wasn't happening under Cygwin.

With the environment variable set you can handle the server host key and password prompts from within a script.

At some point I hope to clean the code up and post it but for now if anyone is facing a similar problem please let me know and I will share what I have.