jordan.terrell
Just trying to make sense of things...

Arduino DHCP Library: A Life of its Own

Wednesday, 22 April 2009 07:38 by jordan.terrell

There has been a good amount of interest in the DHCP library I made public on Sunday night.  So far I've registered almost 1200 page hits and over 140 downloads.  Not a huge following, but larger than I expected.  As a result going forward I will be treating the DHCP library as a separate project - separate from my RFID lock.

A number of people have indicated that the library is working just fine for them.  However, I know of one case where the lack of retry logic is preventing someone from using the library without making changes.  The goal with the next release is to add retry logic and hopefully trim the program size of the library.

Thanks to everyone giving their feedback and please continue to do so!

RFID Lock Prototype: DHCP Library v0.1

Sunday, 19 April 2009 22:11 by jordan.terrell

Update: This has been blogged about on the Makezine Blog – excellent!  Thanks to John Park for making this happen.

Well, I now have a version of the Arduino DHCP library that I feel moderately comfortable releasing to the wild. If you're interested in the background story, check out these posts.

       Download here: Arduino DHCP Library v0.1

I've tested it with an Arduino Duemilanove (ATMega168), but I'm positive that there will be bugs in the code and that for some (hopefully not many) people it will just plain not work.  If you do try to use it and find that it doesn't work, try using Wireshark to see what packets (if any) are flying across the wire.  Even if you can't figure it out, sending Wireshark capture logs to me will be helpful for me to debug.

In order to use the library, you need to drop the contents of the zip file into your "Arduino\hardware\libraries\Ethernet" folder.  There is a sample in the zip file called "WebClientWithDHCP" that is a modification of the standard Ethernet "WebClient" example.  There are the basic steps to get it working.

1) Add "#include "Dhcp.h" to the beginning of your Arduino sketch
2) Declare a variable of type Dhcp (e.g. "Dhcp dhcp;")
3) Call the beginWithDHCP() method, while providing it a MAC address

It has been a challenge writing this library, and I've just scratched the surface.  I don't have IP lease renewal, retry, cable detection, or even much error handling/reporting.  I'm just interested in getting feedback from the Arduino community to see if they find this useful and where to take the library next.

Enjoy!

I Still Work With Software

Thursday, 16 April 2009 10:51 by jordan.terrell

I wanted to take a moment to assure my handful of readers that I am still very much involved/interested in software development on the .NET platform.  I’m actively learning jQuery, ASP.NET MVC, and I’m looking forward to spending some serious time in Visual Studio 2010 (and related releases) when they make Beta 1 available (I’m not dealing with the VPCs).  I’m just a little more inclined to write about my hardware escapades because such things seem to get less coverage in the blogosphere.  However, if I do come across something novel or interesting in the software-only space, I’ll be sure to write about it.

RFID Lock Prototype: DHCP Enabling - Follow Up #2

Wednesday, 15 April 2009 09:35 by jordan.terrell

Continuing on my work to build a DHCP client for my RFID Lock Prototype, I’ve read through the datasheet for the W5100 Ethernet chip (in use on the Arduino Ethernet shield) and I’ve studied the source code for the existing Arduino Ethernet library, and now I know how to work more directly with the transmit and receive buffers (16K shared across 4 sockets) on the W5100 chip.  Hopefully over the next few days I can carve out some time to refactor the DHCP library I’ve built so far to make use of this technique.  Once I do, I will release it publicly – hopefully I will find some willing beta testers.  If all goes well, perhaps it might be included in a future Arduino software release!

RFID Lock Prototype: DHCP Enabling - Follow Up

Sunday, 12 April 2009 22:02 by jordan.terrell

I've got a first pass at a DHCP library that works on the Arduino with an Atmega168 MCU.  It's working and I'm able to get an IP address, and then connect to Google.  It is still really memory intensive - I think I have less than 10 bytes of memory remaining while I'm acquiring the IP address.  I've got some ideas on how to lower the memory requirements, but that will require working with the W5100 IC at a lower level.  That's my next step, but in the meantime check out this video!

 

RFID Lock Prototype: DHCP Enabling

Sunday, 12 April 2009 12:15 by jordan.terrell

Last time I mentioned my RFID Lock prototype, I said that I was going to work on enabling Ethernet connectivity.  I knew that the Arduino Ethernet hardware and supporting library didn't directly support getting an IP address (and other supporting information) via DHCP.  I began to look around to see if someone had developed a library that would handle the DHCP handshake, and unfortunately I could find no such library - only comments of people wishing someone would develop such a library.  Well, I've started just that - a DHCP library for the Arduino Ethernet shield.

I found an DHCP Application Note on the W5100 (Ethernet IC used on the Ethernet shield) manufacture's web site.  It contained an entire application designed for an Atmel ATMega128 that would acquire an IP address via DHCP.  Although much of the code was written for already, I had to do a LOT of refactoring to get it to work as an Arduino library.  Good news is, I just accomplished my first DHCP handshake and acquired and IP address with it. However, it wasn't easy.  I kept experiencing some really strange behavior - random garbage being sent in the DHCP packets (I used Wireshark to monitor the traffic), the MCU would appear to freeze, and it would restart itself.

Finally, I had a hunch that I might be seeing the results of memory corruption or memory boundary violations - after all, I'm coding in the "Arduino language", which is essentially C++ under the covers.  I found a little code snippet that would check for available memory and found that I didn't have enough memory to allocate the structure I used for sending DHCP packets.  The provided Client class in the Ethernet library apparently takes up a lot of memory and I was allocating it right at the start of the Arduino program; I was using a modified version of the sample program that queries Google for sites containing "Arduino".  Once I removed the code that allocated the Client object, I saw that I had ~630 bytes of memory remaining, and I knew that the DHCP packet takes ~550 bytes of memory.  I ran the program again, and it acquired the IP address successfully.

I'm going to try and refactor a few things so that the DHCP packet memory is only used when it is needed - however, since it takes up more than half of the memory available on an Atmega168 chip, I'm thinking that it will be difficult to support on that chip.  I'm going to have to switch to the Atmega328 chip - TWICE the memory!  I plan to test it on an Arduino Duemilanove (both Atmega168 & Atmega328), and Arduino Mini (Atmega168-20AU), and the Arduino MEGA (although I read something that said the Ethernet shield might not work with the MEGA yet).

Once I get a little more polish on the library, I'll submit a patch to Arduino and publish it myself.  I'll be sure to note any memory issues or other concerns that I come across.

Magazine Subscriptions via Amazon.com

Thursday, 9 April 2009 10:28 by jordan.terrell

In late December and early January I subscribed to a few magazines related to building electronics/embedded hardware and I did so via Amazon.com.  My experience has been --- less than ideal.

Upon placing the order, Amazon said that it would take roughly 2 months to receive my first issues.  Pretty standard for subscribing to periodicals.  However, for 3 (SERVO Magazine, Nuts and Volts, and Everyday Practical Electronics) of the 4 subscriptions I have still not received them.  The one subscription (Circuit Cellar) that I have started received has already missed sending me my March issue – I have the February and April issue.  I contacted Circuit Cellar customer support about this and they said they would get the March issue out to me immediately.  No big deal.

For the other subscriptions, I contacted Amazon Customer Service and they informed me that I could not deal directly with them to resolve these issues and proactively gave me contact information for the magazine distributors.  I didn’t like that fact that I couldn’t deal with Amazon, but at least I didn’t have to go hunting down phone numbers and email addresses for the distributors.

I contacted the two distributors via email and I did not get a response for a couple days.  The first one for Everyday Practical Electronics asked me to confirm my address.  Once I did, the next day I got an email saying that they are looking into it and they should get back to me in the next 5 to 7 days!  And that’s business days!  Not the response I expect.  The other distributor for SERVO Magazine and Nuts and Volts never even knew about my subscription and said that it would take another 6 to 8 weeks to receive my first copies.

This strikes me as a poorly setup and run operation between Amazon and these distributors.  I don’t know if by some random convergence of events I was the one person who was affected by this, if this is endemic to these few magazine distributors, or if this affects the entire network of distributors that sell magazines through Amazon.  All I know is I was looking for a simple way to subscribe to some magazines – so much for that!

Caveat emptor!

Tags:   ,
Categories:   General
Actions:   E-mail | del.icio.us | Permalink | Comments (1) | Comment RSSRSS comment feed

RFID Lock Prototype: Ethernet Enabling

Sunday, 15 March 2009 09:32 by jordan.terrell

I've made a bit of progress on my RFID Lock prototype.  I've got it recognizing valid RFID tags, and rejecting invalid ones.  I've also got it recognizing all the keys on a keypad, and if the deadbolt is in the unlocked state, pressing the lock button will lock the deadbolt.

One might think that this prototype is done - ready to be installed.  Not so!  The next phase of the project is what, I think, is going to make the lock interesting.  I'm going to add Ethernet support!  The end goal is to have a secured custom web site that will let me manage the list of RFID tags that are able to unlock the deadbolt, time windows when individual tags are active, plus logging and notification.  When I use my card, I don't need to be notified, but if a family member uses their card (someone who, under normal circumstances, shouldn't be unlocking my door) I will be notified via email/SMS.  I can also imagine having the "hidden key under a rock", but have it not be active - if someone who I haven't given a key to needs to unlock my door, I can remotely activate the hidden key for a brief period of time.  In talking with John Park about this prototype at MAKE: Day, he asked if I was going to have some kind of remote unlock directly from the web site.  Probably not - I'll stick to requiring an RFID tag.

Since I've been using Arduino for my microcontroller platform (technically it is the Atmel ATMEGA168 microcontroller), much of the design heavy lifting for including Ethernet connectivity has been done for me.  There is an Ethernet hardware shield and an Ethernet software library.  It's all based around the WizNet W5100 Ethernet chip. At first, I just bought the W5100 chip from Saelig, thinking that I could build a breakout board I can use on a breadboard.  Being that it has 80 pins (73 of which can be connected to) it was going to be a rather long breakout board, but I've been having trouble with the board layout.  The PCB manufacturer that I want to use requires traces to be 8 mils (0.008 inches) wide and spaced 8 mils apart.  You might think that that is very small, but since I'm trying to route this on a board that is spaced about one (1) inch wide, it is proving difficult.  If they would allow 6 or 7 mil width/spacing on a two layer board, I would have been done already.

SchmartBoard with ATMEGA168-20AU For those familiar with Arduino and the Arduino Ethernet shield, this might seem like an unnecessary task.  My argument is that I want to learn more about the W5100 chip and how to embed it in a circuit because 1) I like understanding how things work under the covers, and 2) I'm not planning to use the Ethernet shield in my final design.  I plan on building a custom PCB.  To do that, I'm going to need to be able to program an Atmel ATMEGA168-20AU - it's the same chip that is on the Arduino Mini board.  To put the Arduino bootloader on the chip, I'm using the FTDI FT232RL BitBag approach.  I wanted the have some way of easily programming the chips without them having to be in a permanent circuit, so I bought a SchmartBoard of the appropriate size from Mouser, and using painters tape I affixed the chip to the surface (see photo).  Now I can install the bootloader on this chip without having to put In-Circuit Serial Programming (ICSP) pins on my RFID lock PCB.  I tried to use a SchmartBoard for the W5100 Ethernet chip, but the traces in the center of the board were too short.  So I ended up buying a standard Ethernet shield for now so I can work through the rest of the firmware development.

Once I have a stable build of the firmware using the Ethernet shield, I will make another post.

DSC_9621   DSC_9622

MAKE: Day

Saturday, 14 March 2009 22:16 by jordan.terrell

One of the technical resources that I've been using as I've started to learn about electronics and making physical devices is MAKE: Magazine.  I remember subscribing when the magazine first came out, and it's been a great source of ideas and tips.  Since then, MAKE has grown quite a bit.  They now have a blog, talk radio, and a television show.

Today, MAKE co-hosted what they called "MAKE: Day" at the Science Museum of Minnesota, and gave a lot of their "Makers" a chance to show their stuff.  Besides taking a look at a lot of the stuff others are making, I got a chance to meet and chat with the main host of the MAKE: Television show, John Park - he's a really nice guy.  Even cooler, someone took a photo of John working at the MAKE: Television booth today, and they used the photo on the MAKE: Blog - guess who just happened to be in it?  Yours truly - although it's not very clear; my father, who went with me, is in the way!

johnpark-makeday

Tags:  
Categories:   Embedded Hardware
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

It’s Just Not Fair

Thursday, 5 March 2009 10:47 by jordan.terrell

Given my recent interest in electronics, I find myself a little bummed that there isn’t someplace like this (another reference) in the US – at least that I know of.  Seriously, if I ever visit China, I should probably not bring any credit cards, because I might go nuts!