PDA

View Full Version : Using the Arduino Eth shie wi AMIS18 (new thread so not so long scroll to end)



amgen
- 3rd October 2011, 00:50
If I can jump in here a little, Henrik, reading this post back it is clear that you have done a lot of work, a really lot of work.
I do not have a one of the shields but I have been learning with one of the wiznet modules. My interest got started based on the thought that just about every fricken thing out there (machines and controllers etc) wants to be able to hook up to the internet, somehow or other. Many things are already doing that more and more, but its still interesting understanding how that all works.
So, at this point, I have a PIC recieve a request from HTTP and send 1 page , as you have done over IP.
6023
Not sure what to elaberate on, so when brought up,
1- Use word pad to write and test HTML, very easy
2- Jscript & Jquery to make pages more active
3- Save HTML at end of code with 'db'


''==============TABLES============= ''!!! ADD 0,0,0 TO END
ASM
tbl1 org 0xA400
db "HTTP/1.0 200 OK",13,"Content-Length: 800 ",13,13
db "<html>",13,"<h1> PIC 18F...TT Server v1.0</h1>",13,"<input type=",34,"text",34," id=",34,"txt",34,">"
db "<script type=",34,"text/javascript",34,">" ,13," var c=0;var t;var timer_is_on=0; "
db "function timedCount(){document.getElementById('txt').value= c;c=c+1; "
db "t=setTimeout(",34,"timedCount()",34,",1000);}function doTimer(){if (!timer_is_on){timer_is_on=1;timedCount();}} "
db "</script><form method=",34,"get",34,">Project name: <input type=",34,"text",34," name=",34,"PIC",34," value=",34,"PIC18F2525 ",34," />"
db "<br>select one: <select><option>Amps</option> "
db "<option>Volts</option><option>Frequency</option> </select>"
db "<input type=",34,"submit",34," value=",34,"Submit",34," /></form> "
db "<body onLoad=",34,"doTimer()",34,"><p><b>Note: TEXT HERE </b><br><script type=",34,"text/vbscript",34,">"
db "document.write(NOW & ",34," Hello World!",34,")</script><br></body></p> </html> "
db "<style type=",34,"text/css",34,">body{background-color:#d0e4fe;}h1{color:red;} style> "
db "<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR> ",0,0,0
db "<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR> ",0,0,0
ENDASM
'''---------------------------------------------------------------

(format of code window?????)
4-Wiznet, use PC interface prog to set IP, port ,Server, or client mode, unloads PIC of teedious work
5- DHCP not so good if device is server because IP needs to stay static so can be found from outside more easily.
6- Idea to store a main HTML page on ones local computer (can have been tested and downloaded) and just have PIC send the dynamic data, and thats Jscript
and------ Someone can make a formater so HTML ,created and tested with any text prog can be inserted into 'db' asm code with correct punctuation, legnth etc. The "" quotes do not get handled properly.
7- mabye load new pages into flash somehow, without reprog of PIC.
thats enough for now.
Happy to give and get knowledge.
Don

HenrikOlsson
- 3rd October 2011, 12:23
Hi Don,
I don't know what's up with your thread title but I'm glad it's not exactly the same as mine.

Anyway, in retrospect I wish I had just called using the W5100 with PBP instead of bringing in AMICUS18 and the "shield word", after all as long as you have a W5100 the code will work, you don't have to have either a AMICUS18 board OR a Arduino Ethernet shield - which you've showed.

Right, to your comments.
1- Use word pad to write and test HTML, very easy
Agreed - if you know HTML.

2- Jscript & Jquery to make pages more active
Agreed - if you know JScript and Jquery. Please, if you have time and knowlege write something up that shows and explains how it works!

3- Save HTML at end of code with 'db'
Good idea, nice work! Care to show us how you access/read that data? ReadCode? Example?

4-Wiznet, use PC interface prog to set IP, port ,Server, or client mode, unloads PIC of teedious work
Not sure I follow you here. There is, as far as I know, no non-volatile memory in the W5100. This means it has to be configured at each powerup and/or reset. This makes it a bit unpractical to using a PC to set its MAC, IP etc - or am I completely misunderstanding?

5- DHCP not so good if device is server because IP needs to stay static so can be found from outside more easily.
Yes and no. The DHCP code allows you to pass along a host-name to the DHCP server. I'm definitely no expert on this but it's my understanding that in a typical home enviroment there's a DNS server running on the typical router also acting as the DHCP-server. So it "connects" the name and the IP-adress it "gives" the client with each other. This way you don't have to know the IP adress at all, just browse to "name of the device". After all, you don't have to know the IP-adress of Googles or Crownhills servers in order to reach them, right? If the device is on the "inside" of your internet router then, to access it from the outside, you'd have to browse to IP-adress that your router is assigned from the ISP - it then forwards (if properly setup) the trafic to the W5100 device.

6- Idea to store a main HTML page on ones local computer (can have been tested and downloaded) and just have PIC send the dynamic data, and thats Jscript and------ Someone can make a formater so HTML ,created and tested with any text prog can be inserted into 'db' asm code with correct punctuation, legnth etc. The "" quotes do not get handled properly.
Not sure I follow here.... If storing web-pages in the PC why do you need the W5100? Run a web-server on the PC instead. Or do you mean to create the web-page on the PC and then download it to the PIC/W5100 board? In any case some sort of "parameter format" would be needed in the HTML which the PIC replaces with the content of variables etc.

7- mabye load new pages into flash somehow, without reprog of PIC.
Yes, this is definitely needed. On the ethernet shield there's a micro SD-card, on my own board I put 8Mbit SPI flash but if the HTML is small enough it could be stored in the PICs flash. The best approach would be if it could be updated over the Ethernet connection but I guess downloading new HTML content over a serial line would work to.

/Henrik.

amgen
- 3rd October 2011, 19:03
Henrik, i wanted to comment to your original post, so I tried to restart a new ref to original, but to add (comment), ran into max chars so I deleted some letters to make room for my comment. But if it would be less confusing, a new named thread could be done.
Checking a little further, your using the 5100 chip and working closer with its coding compared to the modules where there is less or no directly accessing the networking controller chip, aside from the few basic tcp/ip and serial settings.
If you havn't yet, try W3schools.com. Covers about everything and free.

6029
The Wiz701 serial to ethernet module I use stores it settings in flash reguarding power-up.


'''-------TX INT ROUTINE-------------AX is start adderss in prog flash------''''
TRint:
READCODE AX , B4 'SEND OUT FLASH MEM
if b4=0 then
@ INT_DISABLE TX_INT
else
txreg=b4
AX=AX+1
endif
@ INT_RETURN

I send with TX interrupt , like you said, readcode and check for 0 to stop transmit. Allows base PIC program to keep going even with send 1-2000 chars

Don

HenrikOlsson
- 3rd October 2011, 19:16
Exactly, the W5100. My code targets the W5100 specifically though I think that it, with some minor changes, will work with the new W5200....
I took for granted you were using a module containing the W5100, like the Wiz810, 811 or 812. If you're using one of their more intelligent modules my code is of little use to you.

However, mechanisms and routines to store HTML in the PIC and "pushing it" to the chip/module (be it via USART or MSSP module) can likely be done in the same way for both types - and any other ethernet module, like the X-port for example.

/Henrik.

amgen
- 7th October 2011, 05:21
DHCP for setting PIC Server inside some LAN. You may already be clear this.
To access PIC Server from outside of its LAN, it needs to be on a specific PORT and set the Router to pass packets destined for PIC from the internet based on that PORT number. On my router, I had to enter a static PIC address and specific PORT that allows packets to pass through. That doesn't change so from outside, IP and PORT # access to PIC stays the same. I'm not sure if some routers can add that routing based on the HOST NAME,instead of IP, that you may set in the 5100.

IPV6 will change this but thats still evolving as more devices handle the addressing protocols. I think.

The HTML pages parts stored locally would be because the PIC Server can only handle so much HTML, so that could make pages more functional and appealing while still getting timely data from PIC.

Don