Thursday, 21 March 2013

Wiznet in AVR assembler

I've been exploring the use of the Wiznet W5100.
I have a logging/serving system at home using a Freetronics Ethermega. It runs as a combined web-server and logging client.
The Ethermega has on board the W5100 ethernet chip and a mini SD card socket. Ideal for serving web pages.
Assorted RFM12 nodes send back sensor data which is collected and then available on the web pages. Much of this data is also logged to Thingspeak and Nimbits.
The web related stuff is all done in the Arduino environment and that has become my problem.
So far, it just is not reliable. There seems to be a lot of stuff out there about the problems with the Arduino Ethernet implementation.
In my case, it is just as likely to be my software as I write C at kindergarten level. I just aint very good at it!
I lack the knowledge to dig into the libraries to add/modify/diagnose.
So I started on an AVR assembly language version for the W5100.
Once the W5100 version is done, I have a W5200 module just waiting for its turn. Its TINY and has a power-down mode.

Masochist? perhaps...

The easy way to start was to use a WIZ811MJ module, commonly available and reasonably priced.

The client side is done, I can post data to Nimbits and Thingspeak. A couple of days back I signed up for a free PROWL account and pushed data to my Ipod touch. It was quite straightforward so that was a pleasant surprise.
Server side is done in the sense that it can serve pages from flash but not yet from any other medium.

Just getting to grips with DNS as I dont like to hard-code IP addresses.
Its a working skeleton and I get responses back now and can (at last) understand them. Next bit is to make a parsing module to find and extract the data, shouldn't be too difficult.
Then its on to NTP requests.

So far, with client/server/DNS/serial/timebase and other support routines,code size it at 4.5K, another 1,4k used for data so not too bad yet. Its by no means optimised.
I mostly use Mega328's so space will not be a problem for a while.

The client and server are done as state machines so the software (as part of the operating main loop) checks in to see if anything needs doing. It is designed to be non blocking for the 'main' application so the micro can continue with other tasks and as the web system needs attention, it gets it.
At this point it is not interrupt driven and so far during the learning process I'm only using one socket from the 4 available.

The starting point for my code was mainly from a contest entry, the WIZnet iEthernet Design Contest 2007 by Chuck Baird.
This enabled a good start to getting things going.

No comments:

Post a Comment