Pages: [1]   Go Down
Author Topic: What library is best for the ECN28J60  (Read 818 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Any problem has n+1 solutions
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Im working on a project on a ATMEGA2560 board. It needs to display graphs and long texts on an iPad.
For this I'm using a ECN28J60 board because I already have a highspeed SPI RAM connected to the SPI bus and I did not want to get in trouble with the W5100 problems.
I have tried the EtherCard library but when the javascript on my web page becomes to complex (large (66 lines)) it quits. One line less and it runs... smiley-sad
So now I'm looking at something more reliable.

Does anyone have some sugestions?

Cheers,

Marijn
Logged

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 569
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

UIPEthernet is a direct replacement  for the standard ethernet library, meaning you can use many code examples that already exist.
Logged

Offline Offline
Edison Member
*
Karma: 36
Posts: 1219
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What kind of W5100 problems ?
The ENC28J60 and the W5100 both use the SPI interface. The W5100 is supported by Arduino and good, and the ENC28J60 is for those who like to get into trouble by being cheap.

The Ethercard uses a buffer to load the webpage in. So it is only for small webpages.

The UIPethernet is new:
https://github.com/ntruchsess/arduino_uip
Logged

FR
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

good evening,
have you noted than in some circumstnces Ethercard limits the size of ethernet packets to 220 bytes (even if you give bigger buffer); I have posted about: http://forum.arduino.cc/index.php?topic=216154.msg1580445#msg1580445

could you precise the size of page in bytes rather than lines.

Regards
PO.
« Last Edit: February 22, 2014, 02:49:49 pm by flavigny » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Any problem has n+1 solutions
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Caltoa,

As far as I remember there are problems with the W5100 that it is slow. So other devices on the bus also need to be slow. For a RAM that I want to access quickly that could be a problem.
I also read some where there were problems with the W5100 not clearing the SPI buw when it was not selected with the SS pin. I did not try this by myself but wanted to avoid these kind of problems.
In other projects I have used the W5100 with success and I have still at least 3 boards with them laying around. So judging others for being cheap is kinda shortshighted.

Cheers,

Marijn
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Any problem has n+1 solutions
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok Here is the code I used. It draws a graph with html5 and jscript. Then it fills the graph.
It was the idea to execute a
Code:
bfill.emit_p(PSTR("ctx.lineTo(pq+$D,$D);"),x,y);
for each point in the code in a loop and fetch the data out of the RAM
This code just has a few lines of the ctx.lineTo satement after each other to simulate the loop.
Increasing the size of byte Ethernet::buffer[6000]; has no effect. This was compiled for a ATMEGA2560 so a buffer of 6000 should be ok.

I'm now looking at the UIPEthernet code.

Code:
// This is a demo of the RBBB running as webserver with the Ether Card
// 2010-05-28 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

#include <EtherCard.h>

// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
static byte myip[] = { 192,168,1,203 };

byte Ethernet::buffer[6000];
BufferFiller bfill;

void setup () {
  Serial.begin(115200);
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
  ether.staticSetup(myip);
}

static word homePage() {
  int x=1200;
  int y=300;
  int pq=30;
  int xGrid=20;
  int yGrid=30;
  int lineWidth=2;
  int xGridNumStart=10;
  int xGridNumInc=10;
  int yGridNumStart=1000;
  int yGridNumInc=20;
  int fontSize=9;
  int xVal=0;
  int yVal=0;
 
  bfill = ether.tcpOffset();
  //HTML HEADER
  bfill.emit_p(PSTR(                                                         
    "HTTP/1.0 200 OK\r\n"
    "Content-Type: text/html\r\n"
    "Pragma: no-cache\r\n"
    "\r\n"
 //   "<meta http-equiv='refresh' content='1'/>"
    "<title>Navtex Stat</title>"
   
"<!DOCTYPE html>"
"<html>"
"<body>"
"")); //,h/10, h%10, m/10, m%10, s/10, s%10);
//HTML PAGE
bfill.emit_p(PSTR(
"<canvas id='myCanvas' width='$D' height='$D' style='border:1px solid #c3c3c3;'>"
"Your browser does not support the HTML5 canvas tag."
"</canvas>"
"<br>"),x,y);
//HTML START SCRIPT
bfill.emit_p(PSTR("<script>"));
//DRAW TABLE AND FILL IT
bfill.emit_p(PSTR(
"var canvas=document.getElementById('myCanvas');"
"var ctx=canvas.getContext('2d');"
"var x=$D;"
"var y=$D;"
"var pq=$D;"
"var xGrid=$D;"
"var yGrid=$D;"
"var lineW=$D;"
"var xGridNumStart=$D;"
"var xGridNumInc=$D;"
"var yGridNumStart=$D;"
"var yGridNumInc=$D;"
"ctx.font='$Dpx Veranda';"
"var gridNum=0;"

"ctx.beginPath();"
"ctx.moveTo(pq,pq);"
"ctx.lineTo(pq,y-pq);"
"ctx.lineWidth=lineW;"
"ctx.strokeStyle = 'black';"
"ctx.stroke();"

"ctx.beginPath();"
"ctx.moveTo(pq,y-pq);"
"ctx.lineTo(x-pq, y-pq);"
"ctx.lineWidth=lineW;"
"ctx.strokeStyle = 'black';"
"ctx.stroke();"

"ctx.beginPath();"
"gridNum=xGridNumStart;"
"for(var num=pq+xGrid;num<x-pq;num=num+xGrid){"
"ctx.moveTo(num,y-pq);"
"ctx.lineTo(num,pq);"
"ctx.fillText(gridNum.toString(),num-(xGrid/3),y-pq/2);"
"gridNum += xGridNumInc;"
"}"
"gridNum=yGridNumStart;"
"for(var num=pq+yGrid;num<y-pq;num=num+yGrid){"
"ctx.moveTo(pq,y-num);"
"ctx.lineTo(x-pq,y-num);"
"ctx.fillText(gridNum.toString(),2,y-num);"
"gridNum += yGridNumInc;"
"}"
"ctx.lineWidth=1;"
"ctx.strokeStyle = 'grey';"
"ctx.stroke();"
//End draw draph
//Start draw data
"ctx.beginPath();"
"ctx.moveTo(pq,y-pq);"
  "ctx.lineTo(pq+30,37);"
  "ctx.lineTo(pq+50,49);"
  "ctx.lineTo(pq+70,86);"
  "ctx.lineTo(pq+90,103);"
  "ctx.lineTo(pq+110,67);"
  "ctx.lineTo(pq+130,97);"
//  "ctx.lineTo(pq+150,37);"
//  "ctx.lineTo(pq+170,49);"
//  "ctx.lineTo(pq+190,124);"
//  "ctx.lineTo(pq+200,235);"
),x,y,pq,xGrid,yGrid,lineWidth,xGridNumStart,xGridNumInc,yGridNumStart,yGridNumInc,fontSize);

bfill.emit_p(PSTR(
"ctx.lineWidth=3;"
"ctx.strokeStyle = 'green';"
"ctx.stroke();"
""
//CLOSE PAGE
"</script>"
""
"</body>"
"</html>"));

;
  return bfill.position();
}

void loop () {
  word len = ether.packetReceive();
  word pos = ether.packetLoop(len);
 
  if (pos)  // check if valid tcp data is received
    ether.httpServerReply(homePage()); // send web page data
}
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Any problem has n+1 solutions
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

In an anwser to what problems there are with the W5100. See this http://forum.arduino.cc/index.php?PHPSESSID=1rofnfq1og574oappn0l5r5bv1&topic=13555.msg101111#msg101111 About pins not in tri-state while SS is not active.
And this one http://www.elecrow.com/blog/tag/w5200-vs-w5100-ethernet-shield/ about why the W5100 is so slow.

It seem a good idea to upgrade to w5200.
Logged

Offline Offline
Edison Member
*
Karma: 36
Posts: 1219
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the links with explanation.
Logged

Offline Offline
Sr. Member
****
Karma: 4
Posts: 329
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

....and the ENC28J60 is for those who like to get into trouble by being cheap.

The Ethercard uses a buffer to load the webpage in. So it is only for small webpages.

The UIPethernet is new:
https://github.com/ntruchsess/arduino_uip
heh-heh, "Guilty your Honour" !! smiley-razz
although i also read (belatedly) that "it's for advanced users" - so; NOT for beginners.


...
...
And this one http://www.elecrow.com/blog/tag/w5200-vs-w5100-ethernet-shield/ about why the W5100 is so slow.

It seem a good idea to upgrade to w5200.
yes, i saw that elecrow blog too; there are some Arduino-compatible shields out there that already use the W5200, and then there's also the WIZ820IO board which looks nice !
Logged

Pages: [1]   Go Up
Jump to: