Web Server

julianE

Senior Member
I've been looking about for a web server a while now, the ideal solution being the NET 001 Picaxe Net Server but it is very pricey and not all that available in the US. While browsing around I stumbled on a basic stamp Spinneret web server. Looks interesting, has anyone tried interfacing the Picaxe to it?

I looked around the sparkfun site for Wiznet modules and each one seems to have some issue judging from the comments.

Seems like the best solution was the discontinued SimpleLan.
 

hippy

Technical Support
Staff member
The real question is what you want the web server to do and how much effort you are prepared to put into getting that. Do you mean "Web Server" ( aka HTTP Server ) or do you want something more ?

Various modules often allow no more than raw ethernet packets to be received and sent which means having to write the software and the entire TCP/IP stack or find someone who has already done it. More advanced modules are that; a micro with interface plus some software included which may or may not do what you want.
 

julianE

Senior Member
I'd like something very simple, a web page I can access remotely and be able to control a picaxe and read data from picaxe. I've done it with an apache web server where I can control X10 modules and a Picaxe. The problem is, my PC has to be on all the time. I would rather have a small Web server that can be left on all the time. I have a little FTP dongle that I bought for under $50 that just stays plugged in my router and I can upload or download files to it. I would like something similar to interface to a picaxe and be able to publish it on the web.

Does rev-ed have any plans to come out with a cheaper module then the NET001?
 

1968neil

Senior Member
The silicon chip "WIB" webserver in a box would possibly suit your needs.
Its available from Jaycar as a kit, i have built one and find it excellent.

just google siliconchip & wib

Regards
Neil
 

hippy

Technical Support
Staff member
I've done it with an apache web server where I can control X10 modules and a Picaxe. The problem is, my PC has to be on all the time.
The never-ending battle between having what does work but not quite how you'd like it, and how you'd like it not existing for what you'd like to pay.

Does rev-ed have any plans to come out with a cheaper module then the NET001?
I don't believe there are such plans.
 

julianE

Senior Member
Thanks for all the responses. Hippy's advice, as usual, is right on the mark. My next question is who do I order the Net001 from. The only place I have found is the Robotshop and it's nearly $160, any other sellers carrying the item. I usually order all my Picaxe products from PHANDERSON, his service is the best but I don't think he carries the NET001.
 

NXTreme

Senior Member
I've wanted to go the OpenWRT route but haven't found a cheap enough router that supports it yet. Meanwhile, I found the Netmedia SitePlayer. RobotShop has the SitePlayer for $25 US, not a bad deal.
 

hippy

Technical Support
Staff member
My next question is who do I order the Net001 from. The only place I have found is the Robotshop and it's nearly $160, any other sellers carrying the item.
£99 excluding P&P excluding VAT at today's exchange rate is $154 USD so I doubt you'll find it much cheaper.
 

manuka

Senior Member

Attachments

Last edited:

centrex

Senior Member
Very interesting listening to him is he likely to provide more details at some time.
Regards
Centrex
 

manuka

Senior Member
There's talk of a short video, or perhaps a longer "SiChip" style article (which yours truely may get involved with).
 

julianE

Senior Member
I've wanted to go the OpenWRT route but haven't found a cheap enough router that supports it yet. Meanwhile, I found the Netmedia SitePlayer. RobotShop has the SitePlayer for $25 US, not a bad deal.
The SitePlayer module needs a carrier board, where do you get one of those, I could not find it at the robotshop.
 

ciseco

Senior Member
I'd like to propose a collective effort in getting a PICAXE to converse with a Wiznet 5100, then a PICAXE could have ethernet capabilities for mere £'s (chip is about a fiver). I started one night to do this on a 28x1 XINO and arduino ethernet shield on it, but found the PIC chip select pin wasn't accessible. I've not found time since to whip out a 28x2 version and retry.

@Tiny, didnt you have similar plans?

Miles
 

hippy

Technical Support
Staff member
I'd like to propose a collective effort in getting a PICAXE to converse with a Wiznet 5100
Sounds reasonable. The Wiznet 5100 looks interesting but I don't know a lot about it and couldn't fully understand the datasheet with a brief reading and haven't looked at all the documentation. What I couldn't understand is how it's actually used as it seems to have a full TCP/IP stack on board, but little explanation as to how to use it with something like a PICAXE.

First I'd suggest someone compiling a list of ready made boards which have a Wiznet 5100 and RJ45 on them and how to connect those to a PICAXE, added to as others use different boards and get projects up and working.

Second some overview of how the Wiznet 5100 interfaces to the PICAXE in terms of data or packets sent and received, for server and client.

Third some very simple examples of PICAXE code which works and puts the second into practice -

1) A single socket 'quote of the day server' on port 17. That simply returns a quotation whenever anyone connects to it.

2) A multi-socket 'quote of the day server' which returns a different quote depending on the socket used to connect.

3) An 'echo server'on port 7 which simply sends back exactly what was sent to it.

4) A client which requests a web page and gets that page back.

From that you'll probably hook enough people ( like myself ) into running with the idea and getting on-board. And from that you'll get better documentation, more examples, and more advanced examples.

You need to first bridge the "I've got this chip!?" to "heck, this is easy!" :)

Give a man a fishing rod and ... he'll be completely lost if he's no idea what to do with it or any fish he does manage to catch. Once you've got the basic 'how to', explained and shown how it works, get people interested, going onwards should be self-perpetuating.

So what you need to start with is a team of people who can build the foundations everyone else can build on. That may include people outside the community who have experience of Wiznet 5100, those who can spend the time and effort working things out from basics and datasheets, and those who can put it all in terms other PICAXE users can understand. It sounds like a very worthwhile project.
 
Last edited:

hippy

Technical Support
Staff member
Having read a bit more on the Wiznet W5100 it seems to be relatively straight forward. It's a 'memory mapped' device, everything is controlled and accessed as if it were a large memory chip. The SPI interface allows the access without using up a lot of parallel I/O lines. As a very simple overview of how it works which may not be exactly right in all its detail -

There's a set of memory locations for configuring the chip, setting its IP address and so on.

There are another set of memory locations for each of four 'sockets'. Each of these can be set up for being inactive, a client or server. They hold the port, protocol type (TCP/UDP), there are flags to indicate data received etc.

The rest is memory for reading what a socket received or for writing responses to send back.

So you set up the chip, configure one or more sockets and write associated servers, wait for data to arrive on the sockets and respond to them. Easy-peasy in principle. This should be familiar territory for any VB6 WinSock programmer; it's just coding up the WinSock1.DataArrival and using WinSock1.SendData methods, and probably similar in VB.Net, C# etc.

For example, if you had a port 80 HTTP server placed on a socket, that socket would 'light up' when someone accessed the server, you'd read "GET /index.htm HTTP/1.0 etc" from the receive buffer, write "<html><body>Bingo!</body></html>", close the socket and that's it. You might get clever and parse what's received and adjust what's sent back, the reply might include data from sensors connected to a PICAXE, you might even keep what's sent back in I2C Eeprom, even have markers which indicate 'insert PICAXE sensor data here'.

One neat trick would be to connect a W5100 to a PICAXE, run a single socket server, take what comes in and send that as serial out, take serial in and send that back to the socket. You could then have a separate PICAXE which only has to deal with serial in and produce serial out. The PICAXE which is handling the server could almost be as simple as ...

Do
SerRxd( "GET" )
SerTxd( "<html><body>Bingo!</body></html>" )
Loop

Of course more advanced PICAXE programmers could perhaps handle it all within the one PICAXE.

It should be feasible but it may depend on how quickly the W5100 expects the attached micro to take data and to respond and exactly what PICAXE resources are required in moving that data around. That's only going to get known by studying more and trying it.
 

hippy

Technical Support
Staff member
Thinking further on how most PICAXE users would want to make their projects internet enabled and their skill levels then using serial seems to be a good way of providing for this. It allows hiding the complexity and providing a very simple interface which most PICAXE users will be able to grasp. The simple example given above can be extended to let the user control what they are doing, decide what IP they are and which service they are providing -

SerTxd( IP, 192, 168, 10, 123 )
Do
SerTxd( LISTEN, HTTP_PORT )
SerRxd( "GET" )
SerTxd( "<html><body>Bingo!</body></html>" )
SerTxd( CLOSE )
Loop

The first benefit is that a simple protocol should be simple to describe and easy to follow, within almost any PICAXE user's capabilities.

The second benefit of this is, that by defining this protocol and interface level well, it is possible to then provide the bridging between the user's PICAXE and the internet by a variety of means whether using another PICAXE + W5100, an AXE027 + PC/Laptop, PL2303 + Router/NAS/LaFonero or whatever.

The average PICAXE user can then simply pick from recommended PICAXE, follow the API description and example code, choose a bridge which suits them, connect up and they have their PICAXE on the internet. They can swap bridges as and when they please and it should still work. They can improve their servers and clients without worrying over the bridge itself.

The whizkids who understand TCP/IP, W5100, Windows, Linux and OpenWrt can develop the bridging to meet the API and can add whatever bridges they feel like. The common and standardised API allows freedom to do it anyway they want as long as the API is supported.

I think there would be real merit in considering such an API, giving a top-down approach to meet what average PICAXE users want, as well as providing a definition of what those writing bridging software are aiming for. The bridge could first be implemented on PC which gives others a good idea of what they need to provide and do using other hardware, making it a 'simple porting job' [sic].

Proof of concept code, getting a PICAXE running as a web server in the above example via AXE027 on a PC, shouldn't take more than a couple of days. IMO, the sooner something tangible and working comes along the more momentum it will gather. Nearly every PICAXE user has a download cable and a PC, so by running a PC-based bridge they can get their PICAXE on the internet easily at zero-cost. It may not be perfect but it's a pretty good starting point.
 

techElder

Well-known member
It might be educational to list a few reasons why a new PICAXE user would want to connect their PICAXE system to the Internet. (I know this could be an endless list, but might generate some support where it might not otherwise be.)
 

hippy

Technical Support
Staff member
The most likely would probably be so a PICAXE owner can see what sensors attached to a PICAXE are reading from a remote location; temperature for example. Second would be to control things remotely, such as turning lights, heating or VCR on and off.

A second group probably want to connect to other internet services such as email so they can be informed of things happening, temperatures exceeding limits, their PICAXE burglar alarm having activated. Some may want to update Twitter feeds with the current household temperature or electricity usage.

A third group will want to be able to act on things from the internet, to be able to receive emails to control things, read weather web sites to turn on flashing lights to warn of impending bad weather and so on. Some may be running servers and clients across distances and see this as a means of connecting the two and passing data.

For the famed 'This 08M will flash forever on 3xAA batteries" experiment, one might add a web server so people can simply go there, tell if it is still flashing, see the battery voltage now and how long it's been flashing for.

There's also a 'because I can' and 'I bet you haven't got this' aspect to things which fall into the "cool!" category. Being able to use a phone to see what the temperature is in your home may not be entirely useful but it will no doubt impress some. There are more practical examples such as being able to inhibit and enable your car from your phone this way.
 

hippy

Technical Support
Staff member
One actual problem I have is having multiple AV units all wired together and each with their own remotes, an absolute nightmare and I haven't found a universal remote which lets me do things exactly how I want. The solution seems to make or find an IR remote which can be used and add a 'buffer PICAXE' which receives button press IR from the single remote and sends IR control to each particular AV unit.

That's likely to be a two-part system; receive remote codes and work out what they mean, pass a command to a back-end which generates the right code for the particular AV unit. It could be a single PICAXE but two-parts makes each part easier to spec, easier to build, easier to debug.

Now if I drive the back-end from the ethernet, have my front-end drive the ethernet, it's no more than doing 433MHz radio or XBee and replacing a hard-wired cable with a virtual cable. But, I can also control the back-end from anything which connects to the ethernet so I could junk the front-end and the need to build my own IR remote and simply use a PDA with a WiFi connection and have a touch screen controller which I can program however I want. That simply needs to send out the right ethernet packets rather than IR commands.

What's more I can write a virtual remote control for running on my PC if I'm at it and I can't be bothered to walk a few yards to find the PDA. I can also write a phone app so I can control the same when I'm out and need to record something I'd forgotten about. I could even run a PC program which reads TV listings and turns the TV on and to the right channels when it realises I should be watching something. It could even turn the TV off when I should go to bed :)

It's unlikely to be as functional as that but it's opening up of possibilities and alternatives which is the real drive to wanting ethernet connected PICAXE. How pracatical comes down to how easy and how cheap.
 

hippy

Technical Support
Staff member
One very useful page on W5100 interfacing and the software required seems to be this page ...

http://www.ermicro.com/blog/?p=1773

Apart from being in C code and for another processor it looks straight forward. A few bits of trickery with addressing the TX and RX memory buffers and I've no idea how one deals with greater than a socket buffer's worth of data but in general it's a 'write this, read that, wait until it's right, continue', 'loop until we read that we need to do something' process.

Implementing Quote of the Day, Echo, Discard, Chargen, Daytime and simple Telnet servers should be no more than a day's work with a PICAXE; do one and the others should near instantly follow. A simple HTTP server should be just as easy. No example code for clients but grabbing a short web page should be fairly easy. Sending email etc may be more complicated as it's a more send this, receive that process.

There's probably some gotchas, fiddling with SPI mode and it would help to read and understand the documentation ( haven't even looked at it ! ), but I'd say one should be able to have an X2 and W5100 up and working within a week or over a weekend.
 

hippy

Technical Support
Staff member
Which board would you order out of these 2, i have nowhere the skills of the folks on the forum but am willing to try,

http://www.sparkfun.com/products/9476

or

http://www.sparkfun.com/products/9473
Having learned more I'd say the second (9473) - HOWEVER - that gets you into the arena for playing and developing but with no guarantee of success or that you can do whatever you want to achieve. There are other makers of W5100 modules which may be cheaper, including W5300 modules which are more powerful ( more sockets ).

The first is just a Telnet-style module AFAICS but I don't know the details so cannot fairly judge on it. It doesn't look to be that useful beyond PC-based App to PICAXE connection, I can't see it being useful to give a PICAXE standalone internet features.
 

julianE

Senior Member
There are other makers of W5100 modules which may be cheaper, including W5300 modules which are more powerful ( more sockets ).
It looks like the W5300 modules are also more complicated to use and don't have as many examples as the W5100.

Yea, Sparkfun is more expensive then other suppliers, I've seen the same module for $5 less but sometimes I don't mind paying more since sparkfun does a lot of good. I will probably end up ordering the 9473 module but the more I look it at the more I realize that it's way over my head, hopefully I can draft in your wake. :)
 

hippy

Technical Support
Staff member
I can't say how the W5300 really differs from W5100, but yes it is more complicated, though I'd expect it to be similar in concept, and the basic idea is very simple when one 'gets it'. With more memory ( 64KB TX/RX ? ) that could complicate addressing and handling that but I wouldn't expect great changes, just more of everything, slightly different memory map. Could be wrong :)

I'd probably argue for starting with the W5100 regardless, at least unless someone can say W5300 is just as easy.
 

moxhamj

New Member
It might be educational to list a few reasons why a new PICAXE user would want to connect their PICAXE system to the Internet. (I know this could be an endless list, but might generate some support where it might not otherwise be.)
One application I've been working on for some time is networking many devices. 433Mhz modules are certainly one solution, but the amount of data is limited, especially when you consider the possibility of data clashes, resending data, routing packets etc.

The "internet" is more and more the wireless standard, and that means more off the shelf components and cheaper prices.

My specific application is to collect data from 1-2km away and transmit it. Initially I started with simple data, like soil moisture and tank levels, but sooner or later I found I wanted more data, specifically video.

The hack-a-router manuka posted looks a very interesting way to get the internet to a picaxe.

I'm going to do some more experiments with wifi repeaters.

1) Take an existing low power wifi signal from my home, amplify it and retransmit it from the roof. A company in Canada makes these http://stores.ebay.ca/InnovativeDevice/Trio-Yagi-Routers-/_i.html?_fsub=1097403012&_sid=63696162&_trksid=p4634.c0.m322

2) See how far the signal goes. Yagi to a USB adaptor and plug that into a laptop. Go for a walk http://cgi.ebay.ca/High-Gain-dBi-Yagi-Antenna-Built-In-adaptor-USB-200mw-/400180124295?pt=LH_DefaultDomain_2&hash=item5d2c981a87

If that works, one could use similar equipment to 1) to capture the signal from the yagi and retransmit it locally using an omni antenna.

In remote locations, maybe a laptop might be using too much power, so I've also ordered an "apad", which looks like an ipad but is a lot cheaper and runs Google's Android operating system, which appears to be becoming a popular standard.

Hopefully I can use that with a standard USB camera. If not, a laptop is a fallback position.

manuka's device can translate wifi to picaxe.

Maybe also there is a solution using an apad device and a USB to serial adaptor and that interfaces to the picaxe.

There could also be a local 433Mhz network, which can provide near comms while staying under the 10mW limit.

Long distance internet is attractive as routers have security settings, so even if someone can see your network they won't be able to hack in.

Many interesting hybrid possibilities here.
 
Last edited:

lbenson

Senior Member
Dr_Acula's find of a long range wifi extender is interesting. I have a shorter range version of this between house and barn.

In the barn a Linksys WRT54G router (old gear) is set up using openWrt Linux 2.4 in "client bridge" mode. Any ethernet device plugged into it connects to inter- and local-net, and can be connected to.

I have a Nslu2 also running openWrt plugged onto it with a webcam which is served to the net. Pan and tilt is controlled by the NSLU2 through a picaxe 08M.

It is written up here: http://www.picaxeforum.co.uk/showthread.php?t=13705

Unfortunately, it is not working right now. The freezing weather has apparently done something to the NSLU2 or its power supply, and it's not accessible.
 

julianE

Senior Member
Having learned more I'd say the second (9473) - HOWEVER - that gets you into the arena for playing and developing but with no guarantee of success or that you can do whatever you want to achieve. There are other makers of W5100 modules which may be cheaper, including W5300 modules which are more powerful ( more sockets ).
I went and ordered the 9473 module. Hopefully it will work out, if not, all I'm out is a few dollars.
 

Innes

Member
Hopefully I can use that with a standard USB camera. If not, a laptop is a fallback position.
I think it would be unusual for such a device (i.e. the APad) to have USB host support; most will only act as a 'slave' so that they can be attached as a portable storage device.
 

NXTreme

Senior Member
The newest line of Archos internet tablets all have USB host support. You can get screen sizes from 2.8" to 10.1". I've been thinking about getting the 3.2, WiFi, Bluetooth and USB host all for $150 (or less if you know where to look) makes it a pretty good deal for a portable test platform. Now if only we could have a Picaxe programming "AxePad" for Android... but that might be asking too much.
 
Last edited:

julianE

Senior Member
To prepare for the arrival of the W5100 module I've been brushing up on the SPI communication, found the entry on wiki simple to understand,
http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus

I'm thinking the easiest way to learn would be to setup a link between 2 picaxes, is there an example of it on the forum? I have not found too much info on SPI on the forum, probably because everyone thinks it simple. I've only used the uart and I2C so SPI is exotic to me and something I need to learn.
 

hippy

Technical Support
Staff member
The best way to approach would be as with serial; one side sends an incrementing byte every second or so, the other side grabs and displays whatever comes in.

However, the PICAXE is designed as an SPI Master, not an SPI Slave. To be used as an SPI Slave means poking SFR and hand coding that functionality. It can be done but it's not as straight forward as issuing SPIIN / HSPIIN which is a Master-to-Slave command, not a Receive-by-Slave command.

The best way to test and learn is probably to interface to a genuine SPI Slave device, SPI Eeprom or a Wiznet module when you get it, or to look at the SPI signals on a scope or logic analyser.

I'd say there's little you can learn more than reading about SPI and it's basically very simple; SPIOUT etc sends data out, each bit sent on the Data line is clocked by a pulse on the Clock line. The Slave reads each bit on the Data line for each pulse on the Clock line. As each bit is clocked out, a bit from the Slave is clocked back in. There's no more to it than that.

When you see the SPI code rerquired for interfacing to Wiznet it will likely be self-evident with a little explanation.

HSpiOut ( command ) ' Send out a command
PeekSfr SSPBUF, b0 ' Get what the response was

I'm not sure the Wikipedia link is the best to look at as it overly complicates things and includes things which aren't actually important for what you'll need to do. If you understand that I'm not sure what else there really is, other than a desire to see it in action.
 

hippy

Technical Support
Staff member
Have done some more reading and a few bits of information to add to the pile ...

The W5100 is what's best for PICAXE users; the W5300 does not support SPI and while 'better' makes things far more complicated hardware and software wise. The W7100 similarly.

For W5100 modules to connect to a PICAXE there seems to be five primary options -

WIZ811MJ - As sold by Sparkfun and others. Annoyingly it has two sets of double-row 0.1" pins which makes plug-in use with bread-board impossible and requires cutting tracks between adjacent holes for vero-board. Ribbon cable and IDC connectors may be an option. Though a lot of pins aren't required with PICAXE there are multiple power and 0V connections.

WIZ810MJ - As above but connectors on 2mm pitch, not much smaller and slightly different interface / pinout. Probably best to choose WIZ811MJ so on the same sheet as everyone else.

W5100 Shields - Not all pins on 0.1" x 0.1" spacing but all 0.1" single row. Not sure how standard every shield is but seem to include 3V3 regulators plus other stuff ( SD Card socket ).

SPI Breakout boards - I've seen DIY versions, would be ideal in minimising connections but haven't found any commercial versions.

Parallax Spinneret - A Propeller Chip plus W5100 combo. Could be best for making a W5100 to PICAXE over serial interface but needs coding, needs additional development tools purchasing, and isn't 'in the spirit' of a pure PICAXE-W5100 project. It's also a more expensive option.

I'd probably go with the WIZ811MJ on vero-board as the (seemingly) cheapest option, a W5100 Shield for pre-assembled and less effort.
 

julianE

Senior Member
I'd probably go with the WIZ811MJ on vero-board as the (seemingly) cheapest option, a W5100 Shield for pre-assembled and less effort.
I'm glad that the WIZ811MJ was a good choice. I should have mine within a couple days. I'm going to use female headers, like these
http://www.sparkfun.com/products/115
to mount it to a vero board. That way I can move the module around or replace it if it were to go bad.

Unfortunately I don't have a fraction of skill the rest of the forum members do
but will give it a try.
 

hippy

Technical Support
Staff member
Good idea with the headers.

To cut between adjacent holes on vero-board / strip-board I find the best way is to solder only the diagonally opposite ends of the two rows then use a junior hacksaw between the pins to gently cut through the tracks. The pins keep the blade from flapping about so you get a nice straight cut.

Any tracks cut beyond where you want them you can fix with a wire link on the track side and a blob of solder. Viewed from the component side you don't see the mess made :)
 

eclectic

Moderator
Good idea with the headers.

To cut between adjacent holes on vero-board / strip-board I find the best way is to solder only the diagonally opposite ends of the two rows then use a junior hacksaw between the pins to gently cut through the tracks. The pins keep the blade from flapping about so you get a nice straight cut.

Any tracks cut beyond where you want them you can fix with a wire link on the track side and a blob of solder. Viewed from the component side you don't see the mess made :)
There's also Tripad
as an option.
http://maplin.co.uk/tripad-board-1922

e
 

Attachments

julianE

Senior Member
Surprisingly, the Wiznet board came in the red sparkfun box today.
I have to work the entire weekend so will not have much of a chance to play with it, perhaps late Sunday.

I tried fitting it into proto boards I have on hand, ones with 3 pins connected but the spacing is such that if i get one side to fit the other one does not, i end up shorting the pins on J2.
Here is the link to the pinout, it's in section 2.
http://www.sparkfun.com/datasheets/DevTools/WIZnet/DEV-09473-Datasheet_V_1.1.pdf

my plan is to cludge together 2 separate boards, should not be too hard, will still use headers.

From a quick look, I only need to use 1/3 of the pins. Plan is to go with a 28X1 or 20X2 on the Picaxe side of things.
The pins I'll need from the WIZnet module,

J1 pins

MOSI
MISO
GND
3.3v

J2 pins

3.3V
/RESET
SCLK
/SCS
/CS
GNDs

That should do it, I think.

I would think the 20X2 is all I need but I have the 28X1 if that's the wiser way to go.
 

julianE

Senior Member
It's not pretty but it's ready for testing.
I did not have many different colors of wire on hand so I just grouped them in sets of 2.

MOSI
MISO

SCLK
/CS

/RESET
/SCS

and the power wires.

The board has enough room to mount a 20X2 after breadboarding.

I'm going to use 2 batteries for the 3.3 Volts.

Now for some questions,

Should I just ground the Reset and CS chip select pin or should I use one of the outputs on 20X2 to control Chip Select.

I will attempt to use the SPI using the example in the Manual 2, HSPISETUP command.

Anything else I might be missing?
 

Attachments

Top