Web Server

hippy

Ex-Staff (retired)
You're ahead of me on harware and interfacing !

I recall the W5100 doesn't perform power-on reset so you'll likely need to take /RESET and /CS to PICAXE I/O pins so you can control them.

Connect the SPI lines to the hardware HSPI of the PICAXE. We can bit bang SPI then move to HSPI as and when.

I'd recommend a 28X2 for the larger scratchpad and extra slots. Debugging and developing might have a lot of SERTXD and that eats up memory. It may be possible to use 20X2 but probably best to develop for 28X2 drop to 20X2 if one can than hit the ceiling of the 20X2 and be stuck.

It might turn out that the INT line ( interrupt ) is useful to use, to cut down on PICAXE response times, but that can be added later.
 
Last edited:

hippy

Ex-Staff (retired)
A suggestion for wiring - whether PICAXE + Module Carrier on same board or separate - Connect by flying wires, be prepared to move those wires around, and don't design / build additional hardware which needs specific PICAXE pins as they may need to change.

Development will be driven by those on the cutting-edge and they will be dictating how things connect and are used to make things works. It's slightly arrogant, but that's the way it is. To utilise their efforts one has to follow their lead -- That doesn't necessarily mean requests and changes can't be suggested, just that the leading developers have to decide for themselves as they will likely be doing the harder work and have to choose what works best.

Once initial development settles down there should be fewer changes and hopefully definitive hardware can be specified earlier in the effort.
 

julianE

Senior Member
Development will be driven by those on the cutting-edge and they will be dictating how things connect and are used to make things works. It's slightly arrogant, but that's the way it is. To utilise their efforts one has to follow their lead -- That doesn't necessarily mean requests and changes can't be suggested, just that the leading developers have to decide for themselves as they will likely be doing the harder work and have to choose what works best.

Once initial development settles down there should be fewer changes and hopefully definitive hardware can be specified earlier in the effort.
I have never once detected arrogance in your posts which is so refreshing, in my work life I deal with a lot of IT people and am always amazed by their over confidence, they have this specialzed knowledge and think it all there is to know.

I will loiter around and learn as much as I can while the leaders do the heavy lifting.

Some good news, I went and tested my board by using the *duino board. Took some doing but the WIZNet board is working and I can communicate to it and display a web page.

The Wiznet will work on that system with only 4 wires, MOSI, MISO, SCLK and /SCS. I did find the /RESET valuable and think it should be included in the picaxe design.

One of the small discoveries I made is that in addition to the MAC Address and IP Address I also had to send my Default Gateway address to the WIZNet.

I will order a 28X2 and set up a breadboard for testing and follow along in the adventure. That's one of the best qualities about Picaxe, the competing systems are easy to implement because the libraries are like black boxes they work without knowing why.
 

hippy

Ex-Staff (retired)
Some good news, I went and tested my board by using the *duino board. Took some doing but the WIZNet board is working and I can communicate to it and display a web page.
That's excellent news and well done. At least you know your hardware works and your wiring ( unintentional pun ) is correct. And it now seems you're possibly the forum expert on W5100 :)

One of the small discoveries I made is that in addition to the MAC Address and IP Address I also had to send my Default Gateway address to the WIZNet.
In the absence of being able to check myself, one thing which would be interesting to know if you want to play some more - does the order of sending Gateway, Mac, SubNet and IP actually matter ?

Mac, IP, SubNet then Gateway would be my preferred order for writing them down and it would be nice to know if initialisation code can follow the same order.

More advanced and, perhaps more tricky, is to see how it all responds when you slow things down, for example put a 1ms delay before every read/write command sent to the W5100 over SPI. If it holds up for that it will look very promising from a PICAXE perspective.

Don't feel put-upon; only suggestions for if you want to put in the time and effort.
 

julianE

Senior Member
Best I can tell there is an order that IP configuration information is sent. Turns out, me entering the Default Gateway in the code had no effect, all that's sent in the example program is,

Ethernet.begin(mac, ip);

turns out if you do not send the default gateway the program just uses the ip address and for the last octet substitutes 1, ie. 192.168.1.1, which is correct for my network.

I can't get over how difficult C is to program in. On the surface it looks simple and then you start opening the libraries and it's just layer upon layer of steps. I do plan to wade through it but there is a lot. My version of 'duino IDE is 13 the newest is 22. It's been that long since I last touched it, the Picaxe suits me so much more.

Looking at the complexity of the duino implementation it certainly looks like a job for the higher end Picaxe.

i tried adding a delay between the byte transmissions but keep getting C syntax errors, not enough or too many { }, something not declared and so on.

delay(100); is not enough.

I miss the simplicity of 'pause 100'.

Sorry I could not be of more help, I'll keep reading.
 

ciseco

Senior Member
I must pay more attention to the forum. Seems you guys have gotten somewhere. So getting a PICAXE to chat with it looks likely, super cool.

My original attempt was on a 28x1 with a DF robot shield as I'd not got a 28x2 powered board to hand, fell quickly as I couldn't "get at" the PIC SS pin . So I've now got a 28x2 board (hopefully can set A.4) and whacked in the wiznet jobbie and just need to check connections, here's it in place.



Pins from the arduino shield are as standard, the PICAXE pins are wired such:

13 - C.3/HSPI SCK/HI2C SCI
12 - C.4/HI2C SDA/HSPI SDI
11 - C.5/HSPI SDO
10 - A.4/SERIAL OUT (PIC SS pin)

Was there any definative as to /RESET being required?

Any thoughts would be really useful, I've a friend who's big on these in duino's and would be able to assist in porting bits over, I just need to get the AXE to chat with it and we're good to go.

Miles
 

hippy

Ex-Staff (retired)
The SS pin seems simply to be a chip select into the W5100 so can be bit-banged. It is Unfortunate it's on Serial Out but if toggling it shouldn't matter as long as it's set and reset to the right levels before and after SPI comms take place and SERTXD not used during SPI comms. If SS primes W5100 SPI and SERTXD messes things up it may need moving to a different PICAXE pin.

/RESET does seem to be required. Some of the shields seem to add power-on reset for W5100 but it's also good to have PICAXE control over it.
 

julianE

Senior Member
Was there any definative as to /RESET being required?

Miles
Yes, /RESET is a must. I tried to see if the module would work with /SCS being grounded and not hooked up to pin 10 of duino and the program seized working so /SCS must be used as well.

I also found a thread from a while back that deals with the Wiznet card,

http://www.picaxeforum.co.uk/showthread.php?t=8372&highlight=wiznet

There is a program by member Puddlehaven and some skeleton code by Hippy.
Hoping to have my 28X2 chip in tomorrow's mail.
 

moxhamj

New Member
My $110 Apad arrived and to answer a question from a few posts ago, no it can't act as a USB host for the purposes of running a USB camera, but no matter, because it has a camera in it anyway. And only a few lines of Basic code to take a picture. Three lines of Basic to play a .wav file.

Pretty nifty programming - Write a Basic program, hit F5 to compile and it downloads and runs using WiFi. This is the future of programming! http://www.basic4ppc.com/android/screenshots.html

So this has me thinking - how cheap can WiFi go? http://cgi.ebay.com/MRF24WB0MB-Wi-Fi-radio-transceiver-module-/350427545246?pt=LH_DefaultDomain_0&hash=item51971bfe9e or in a module for a little more http://www.sure-electronics.net/download/MB-CM141117_Ver1.0_EN.pdf

Hmm - pretty lousy documentation from Microchip as there seem to be no code examples at all http://ww1.microchip.com/downloads/en/DeviceDoc/70632A.pdf The second example is interesting - maybe instead of a pic it could be a picaxe?

Costs are coming down. I wonder what the cheapest way is of getting a picaxe onto a wifi network? Using individual modules. Or 433Mhz modules and route them to a common picaxe that then talks to an Apad.
 
Last edited:

lbenson

Senior Member
>cheapest way is of getting a picaxe onto a wifi network?

I haven't yet seen Stan's/Andrew Hornblow's axe-to-router wifi yet, but I got a bunch of Seagate Dockstars (128MB ram, 256MB flash, 1.2G processor, 4 USB) for $25 (but discontinued). These work as wireless wifi clients with a $10 usb-wifi dongle, and have all the processing power one is likely to need.

I don't know what the lowest price is for non-discontinued gear. The Asus WL-520gU router with usb is $45US at Newegg--often discounted down below $30, but not lately.
 

lbenson

Senior Member
My $110 Apad arrived ... Pretty nifty programming - Write a Basic program, hit F5 to compile and it downloads and runs using WiFi.
What downloads from where and runs using WiFi? (Maybe you're saying that you program on the PC (as with the picaxe), and the program is downloaded to the Android device and runs there.)

Nice looking Basic programming environment. I was thinking of waiting for cheap Android 3.0 devices (some time yet), but you may have sold me. Even if OT, can you write a mini-review of the device? Does it have usb ports, to which one might be able to connect a picaxe via serial (so maybe not entirely OT)?
 

moxhamj

New Member
Hi lbenson,

Sorry about the delay - I've been deep inside the code.

Yes the apad downloads from the PC to the device using wifi. I'm now experimenting with using asus routers and OpenWRT to extend wifi.

I'll get to picaxe in a sec, but to answer what the Android has:
USB host and slave... but the only devices that work are a keyboard and USB memory devices.
WiFi - amazingly simple to use. Browse the internet from any hotspot.
Cat5 - use a wired connection
Microphone, speaker, audio out, camera, 800x480 color screen.
The more expensive ones have bluetooth (which would greatly simplify things)

What it does not have is a way of interfacing with the real world!

So how would you interface to the real world?

Wifi to serial is expensive
Microphone may work (I have an app that runs a FFT in real time on the noise, but no driver yet in Basic. It is coming soon though).
Screen - yes you can turn parts of the screen on and off and detect this with photodetectors but that is a bit clumsy.
Camera. Maybe you can take pictures of leds and decode patterns?

For Apad to picaxe, the audio out might be the simplest. I have just finished writing some code that takes some bytes and creates a .wav file at 2400 baud. Sent it to a op amp and then a max232 and it printed "Hello World" on a terminal program on a PC. Picaxe can talk 2400 baud serial so that is a solution that is at least working with one way data.

I've done some research on WiFi to serial, and many times the best suggestion is an Asus router running OpenWRT. Seems a slightly expensive way to talk to a picaxe though, and it does consume 10 watts.

So in a roundabout way, I seem to be back somewhere near the beginning of this thread looking at interfacing the Cat5 socket to picaxe and to the web.

I looked up the price of the W5100 and they taunt you on the interweb with quotes of $4.22 for volume. But at least that does indicate it is not a hugely expensive chip.

There is a writeup here http://www.circuitcellar.com/archives/viewable/Eady208/2.html and I'm sure there is more documentation out there.

I guess what interests me is the picaxe talking to the web for the lowest cost and for the lowest power consumption.

But it does open up some intriguing possibilities if you can also use cat5 to talk to an apad. For starters, the apad could act as a keyboard and display for a picaxe. It could also act as an interface between cat5 and wifi and the internet. It could also handle serving up lots of data on a webpage as it has easy access to sd card files.

Where the picaxe shines is the ability to interface to the real world and measure things and turn things on and off.

As an aside, nice comparison of the W5100 and the ENC28J60 http://www.codetorment.com/2009/10/24/arduino-goodness-ethernet-shield/

The W5100 looks very hard to solder. Sparkfun sell some breakout boards. Interestingly, this http://www.sparkfun.com/products/9476 might be one of the cheapest "ethernet to serial" devices around.

So maybe there are some synergies here to explore?
 
Last edited:

lbenson

Senior Member
Hi Dr_Acula,

I'm looking at the Android tablet as (along with its usual uses), a "remote for the house".

Regarding picaxe-to-internet, I'd be happy to find a cheaper way to do it, but I'm still happy with usb-serial with openWrt on an Asus WL-520gU router ($34.99US from Newegg today including a $10 rebate--I just ordered another one). The routers are simply acting as little computers ("little devices"), which may attach to the inter/intra-net wirelessly or wired.

My thought is to use the picaxe only for sensing and setting things, and do all the harder work of messaging, timing, and web page serving on the router, which you can get access to remotely.

The tablet would talk to the routers. The basic program application which you pointed to does tcp messaging, so it would be easy to send messages to little devices, and to either get responses back or to check device-hosted web pages to see the status of things.

In theory, the Seagate Dockstar (of which I have several) is even better than the routers I have looked at, tho you do need to add a $10 dongle to get wifi. It has a 1gHz processor, 128MB ram, and 256MB flash, and 4 usb ports--just about all the processing power one could ever want in such a device (famous last words). The Dockstar is out of production, but has been available for as low as $25.

The Bifferboard, which Stelios advocates, is also outstanding for size, but too pricy for my liking.

For an Android tablet, I'm now looking at the just-released Superpad2. I expect to spring for something sometime this month.
 

julianE

Senior Member
I'm thinking of interfacing the duino/wiznet combo to the picaxe. Programming the duino is so tedious compared to the picaxe, I would like to do it once and then use the duino as a go between. What would be the best way to communicate between the two. From what i read, the serial option has issues due to differences between the serial implementation. I have found some samples of using I2C, would that be the best way to go?

Of course, I will switch to a full picaxe implementation once the smarter folks on the board sort out the communication between the w5100 and the 28X2. BTW, I ordered the 28X2 and received the older version, I guess the sellers need to clear out the older inventory.
 

hippy

Ex-Staff (retired)
Serial would be the best option. I'm not sure what the issues are in "differences" but I can't imagine they'd be difficult to overcome.
 

julianE

Senior Member
Serial would be the best option. I'm not sure what the issues are in "differences" but I can't imagine they'd be difficult to overcome.
has something to do with polarity, picaxe is Low when idle with a high start bit and duino is High when idle with a low start bit. From what i read on the forum i can use a CMOS inverter like the 74HC04 as a buffer between them. I must admit it's a bit hazy to me why there is a difference, can I use something like,

serout 7,T2400,(b1)

where having a T in front of the baud rate would allow for positive polarity.
I'll read the manual some more.

Thanks for all the help.
 

MPep

Senior Member
@julianE,

Give it a go and try it. You've got nothing to lose.
As far as I knew, serial is serial. If you overcome any difficulties, let us all know.

MPep.
 

julianE

Senior Member
@julianE,

Give it a go and try it. You've got nothing to lose.
As far as I knew, serial is serial. If you overcome any difficulties, let us all know.

MPep.
First I have to learn my way with the duino, real pain that.

More important, glad to hear from Christchurch, hope all is well with all the New Zealand forum members.
 

MPep

Senior Member
Hi Julian,

Check the "Kiwi roll call" post!

The Arduino has always seemed like a strange beast to me. Touted as being the latest and greatest but in effect it is nothing more than a hardware protocol-defined C-language programmable AVR.
I love PICAXE, although no projects on the go at the moment. Many many ideas though. Lack of time!

MPep.
 

hippy

Ex-Staff (retired)
has something to do with polarity ... I must admit it's a bit hazy to me why there is a difference, can I use something like,

serout 7,T2400,(b1)
Yes, that should work. Alternatively use HSERIN/HSEROUT if you have a PICAXE which supports it. Background serial receive will also be a big advantage as well.

The reason for the difference is that the AVR uses the UART by default which has idle high ( same as the high-speed serial UART on PICAXE ) whereas most PICAXE serial comms is software bit-banged. It should be possible to find bit-banged code for the AVR. That's usually the first thing I write for a micro I'm new to after the 'flash a LED' program; a good way to get familiar with the programming language and the tools. With the added benefit you can then do serial without needing any MAX232, and these days by simply plugging an AXE027 into it.
 

wall_axe

Member
I've been watching this thread with great interest. I'm using the siteplayer to implement a web based thermostat. It has some quirks, but once it works it's pretty slick. The hserin/hserout commands are priceless with a siteplayer/picaxe setup. I've got the development board; it's overly complicated (and priced) for most stand alone applications, but it sure helps getting the main circuit up and running. The problem I've had is getting the proper magnetics. The SP is VERY fussy about the ethernet jack. I've made my own breakout board, but jack is still a thorn in my side. Robotshop sells the jacks in 5 packs (anyone interested in splitting up an order?).

Has anyone looked at the new spinnernet from parallax? $50 buys a ton of processing power, but it's yet another language to learn. I love how easy it is to program in basic. SPIN looks a little daunting to me!

Keep up the good work! If anyone is looking at the SitePlayer route, I'm glad to share what I have.
 

julianE

Senior Member
Yes, that should work. Alternatively use HSERIN/HSEROUT if you have a PICAXE which supports it. Background serial receive will also be a big advantage as well.

The reason for the difference is that the AVR uses the UART by default which has idle high ( same as the high-speed serial UART on PICAXE ) whereas most PICAXE serial comms is software bit-banged. It should be possible to find bit-banged code for the AVR. That's usually the first thing I write for a micro I'm new to after the 'flash a LED' program; a good way to get familiar with the programming language and the tools. With the added benefit you can then do serial without needing any MAX232, and these days by simply plugging an AXE027 into it.
Thanks Hippy. It worked on first try. I just used the duino to send different single characters on it's tx line, I can see it in the duino terminal and on the picaxe 20X2, also was flashing different lights depending on which character sent, worked well. I reused a program you helped me with for bluetooth module.

my excerpt on the 20X2 side,

hsersetup B9600_8,%00
main:
hserin 0,1
ptr=0
get 0,b1
debug b1
goto main

I need to work some more on hserin and then on to sending to duino from 20X2. So far so good.
 

julianE

Senior Member
It was just as easy to send to the duino from 20X2.

hsersetup B9600_8,%00
main:
hserout 0,(b1)
b1=b1+1
debug b1
pause 1000
Goto main

Still have a long way to go to fully understand all that hserial can do but it's encouraging.
 

Pauldesign

Senior Member
Looks cool indeed but unfortunately, from the specs, there is no built-in TCP stack, except the user don't mind using UDP which has it pros and cons over TCP :(.
 

wall_axe

Member
Looks cool indeed but unfortunately, from the specs, there is no built-in TCP stack, except the user don't mind using UDP which has it pros and cons over TCP :(.

I'm not very versed on network protocols. I saw SMTP and HTTP which (I thought) would take care of what I'm trying to do. Could this not function as a webserver?
 
Top