ENC28J60 Ethernet LAN

Please add any feature requests for Flowcode version 6 here

Moderator: Benj

Forum rules
Only feature requests will be considered here. General questions should not be posted in this forum.
Tom Stefanou
Posts: 32
Joined: Thu Nov 15, 2012 7:21 am
Has thanked: 7 times
Been thanked: 7 times
Contact:

ENC28J60 Ethernet LAN

Postby Tom Stefanou » Wed Sep 11, 2013 3:28 pm

Hello guys!,
Looking in the forums i found a few requests regarding the ENC28J60, but i saw no can/cannot be done answer.

Is it possible that a component is made by someone that will make it work?

I am using this one http://dx.com/p/enc28j60-ethernet-lan-network-module-for-51-avr-stm32-lpc-150604.

If somebody can help i would really appreciate.

Best regards,

Tom

User avatar
Benj
Matrix Staff
Posts: 14151
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4330 times
Been thanked: 4080 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby Benj » Thu Sep 26, 2013 5:25 pm

Hi Tom,

Looks do-able, I'll have a play and see how far I get.
These users thanked the author Benj for the post:
Rudi (Wed Sep 03, 2014 3:16 pm)
Rating: 5.56%
 

Tom Stefanou
Posts: 32
Joined: Thu Nov 15, 2012 7:21 am
Has thanked: 7 times
Been thanked: 7 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby Tom Stefanou » Thu Sep 26, 2013 8:09 pm

Thank you BenJ

You cannot imagine how :D :D :D :D :D :D i feel.
I hope you make all the way to the end!
Good luck with your effort

Sanjay Singh
Posts: 15
Joined: Fri Jun 08, 2012 10:54 am
Location: India
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby Sanjay Singh » Wed May 28, 2014 10:22 am

Any updates on ENC28J60 Ethernet LAN BenJ ?
These users thanked the author Sanjay Singh for the post:
Rudi (Wed May 28, 2014 1:55 pm)
Rating: 5.56%
 

conroydp
Posts: 20
Joined: Mon Apr 09, 2012 8:53 am
Been thanked: 3 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby conroydp » Sat Jun 14, 2014 8:07 pm

Hi BenJ,

Here's another Flowcode user that would be "over the moon" if we can get the ENC28J60 working with Flowcode V5.

:D :D :D

Regards
Conroy

conroydp
Posts: 20
Joined: Mon Apr 09, 2012 8:53 am
Been thanked: 3 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby conroydp » Wed Sep 03, 2014 8:23 am

Hi Benj,

It's been nearly a year since your comment above mentioning that "you'll have a play".

Have you perhaps had any progress? There are a large number of users waiting in anticipation wanting to add "affordable" Ethernet connectivity to their projects.

Please.... :roll: :roll: :roll: :D :D :D

Regards
Conroy

User avatar
Benj
Matrix Staff
Posts: 14151
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4330 times
Been thanked: 4080 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby Benj » Wed Sep 03, 2014 4:22 pm

Hello,

Sorry it's been so long we have been very busy with various projects. However I can confirm I ordered a set of these very same modules last week and am expecting them to arrive later this week so that should allow me to crack on and get a working component to drive this.

Same goes for a very low cost Wifi module which we are discussing on a separate topic.

If you don't hear back in a week or two then please bring this topic to my attention again and I will let you know my progress.
These users thanked the author Benj for the post:
Rudi (Wed Sep 03, 2014 5:50 pm)
Rating: 5.56%
 

User avatar
Benj
Matrix Staff
Posts: 14151
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4330 times
Been thanked: 4080 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby Benj » Sat Sep 06, 2014 4:50 pm

Hello,

Right my modules have arrived so I've made a start on a component. Currently no simulation but this should be fairly easy to plug in at a later stage.

ENC28J60.fcfx
(117.93 KiB) Downloaded 343 times


This has a lot of macros, don't worry I will try and simplify the interface a bit once I get to grips with how it all plugs together.

I'm using the main as my test routine for the component. The test routine is a very simple webpage server with Ping functionality.

The two main macros called from the Main are Initialise and Loop. The Initialise sets the module up as well as performing a Light flash sanity check so you know the SPI comms are working correctly. The LEDs on the module should flash even with the Ethernet cable removed so you can test this before connecting to the network.

The module needs to be powered from a 3V3 source but apparently the I/O is 5V tolerant. I've not tested this yet because i'm using a microcontroller device powered at 3V3 for my test bed.

Now the program seems to be working but my PC is not getting any data via ping or webpage so there is a problem somewhere.

If I do a ping test then it currently times out.
SS1.jpg
SS1.jpg (69.16 KiB) Viewed 12703 times


So I added a section of code whenever the ping is received by the module to toggle an LED on my dsPIC ECIO (due to be release in Oct), a standard ECIO or Arduino would also work well. When I send the ping the LED is flashing on and off so I know the module is reliably receiving the packets.

I then installed wireshark on my PC and this shows that the module is not only receiving the Ping message but is also replying as it should. 73 is my IP, 65 is the IP of my server PC and 90 is the IP of the module as set in the firmware.

SS2.jpg
SS2.jpg (345.03 KiB) Viewed 12703 times


I've got a few things left to check but I have a couple of routes to test out. The first being to check the validity of the IP header checksum (the data checksum uses the same routine and looks to be correct) and the second to play with the IP flags and get the response exactly as another PC returns it.

Hopefully once the ping starts working the webpage server will also spring into life. Not tested this on wireshark yet as want to try and keep things simple and get the ping working for now.
These users thanked the author Benj for the post (total 2):
kersing (Sat Sep 06, 2014 4:59 pm) • Rudi (Sat Sep 06, 2014 9:50 pm)
Rating: 11.11%
 

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby kersing » Sat Sep 06, 2014 5:02 pm

Hi Ben,

Did you base your code on existing sources?

Best regards,

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
Benj
Matrix Staff
Posts: 14151
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4330 times
Been thanked: 4080 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby Benj » Sat Sep 06, 2014 5:09 pm

Hi Jac,

Great question. I used this as my source.

http://s1.electrodragon.com/wp-content/ ... Shield.zip

The code refers to a lot of constants which I replaced for hard coded values in the Flowcode driver. Could be I have made a mistake here but checking through I haven't spotted one yet. In hindsight it might have been better to keep the constants.

The example is the webserver (I checked the ping example and it's handled in exactly the same way), the Ip routines are from ip_arp_udp_tcp.c, the Enc routines are from the enc28j60.c file. The definitions for the C files are in the net.h and end28j60.h header files.

I believe the problem may be checksum related as the example code uses 32-bit typecasting which is currently hard to force into Flowcode. This is why i'm currently using divides in the checksum routine rather than the shifts as shown in the post Medelec did a while back on >> 16 not working as it should.

I've made subtle changes on the way the buffer is managed which I don't think should be a problem but could potentially be something to do with the problem I'm seeing.

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby kersing » Sat Sep 06, 2014 5:31 pm

Hi Ben,

You did notice the code is licensed under GPL2? This might be something Flowcode users need to be aware of as it impacts their code (GPL requires distribution of the source to anyone that legally obtained the binary code if they ask for it). Or would your Flowcode component be considered a new implementation?

Regarding the shift issue, does that apply to the PIC16 series as well?

Best regards,

Jac
These users thanked the author kersing for the post:
Rudi (Sat Sep 06, 2014 9:51 pm)
Rating: 5.56%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
Benj
Matrix Staff
Posts: 14151
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4330 times
Been thanked: 4080 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby Benj » Sat Sep 06, 2014 5:44 pm

Hi Jac,

The way I see it ElectroDragon are using the code as a source to drive a module they are selling. I'm kinda assuming that they have contacted the original author and got the correct permissions. However it's a Chinese company so probably not.

Anyway I have already modded the code away from the source example so I hope it to be different enough to qualify as for us to use for our needs. As I progress the driver further I believe most of the underlying code will be abstract in the component and not available to the user which again provides a nice get out clause for us.

As a final helper I don't want to add this to the Pro version so it should be usable for the chip pack version. Saying this the SPI component currently requires pro status so this doesn't really work. I'll think on it.

As far as I know the 16-bit shift is also an issue on 16-bit PICs without specific typecasting embedded in the C. Think its seen as a feature for compilers to only use 16-bit values when shifting unless specifically told not to. Seem to remember Jonny knew something about why this was the case.

User avatar
Benj
Matrix Staff
Posts: 14151
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4330 times
Been thanked: 4080 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby Benj » Sat Sep 06, 2014 9:36 pm

Ok I found my bug and it's working now :)

The checksum variable for the IP header was a byte rather than a UINT.

ENC28J60.fcfx
(118.66 KiB) Downloaded 371 times


Proof it works :) HTML needs changing though :roll:

SS3.jpg
SS3.jpg (78.89 KiB) Viewed 12691 times


Right now it's working I'll have a play and add some polish.
These users thanked the author Benj for the post (total 3):
Rudi (Sat Sep 06, 2014 9:45 pm) • kersing (Sat Sep 06, 2014 9:56 pm) • hyperion007 (Sun Sep 07, 2014 8:33 am)
Rating: 16.67%
 

User avatar
Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 494 times
Been thanked: 188 times

Re: ENC28J60 Ethernet LAN

Postby Rudi » Sat Sep 06, 2014 9:47 pm

If you guys have done it - i will test it at the morning, where are you that i can embrace you ;-)
Best wishes!
rudi
;-)

User avatar
Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 494 times
Been thanked: 188 times

Re: ENC28J60 Ethernet LAN

Postby Rudi » Sun Sep 07, 2014 1:41 am

Sure - i can't wait until morning - because i can't sleep ;-)

Benj!

You did it!

Pic24FJ256GB106 Board with an ENC28J60 On Board Success!!!

I will test with PIC18F2550 and a ENC28J60 Shied too and let you know

Best wishes!
Rudi
;-)

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby hyperion007 » Sun Sep 07, 2014 8:36 am

THAT'S AWESOME Ben!

I just got my 5 modules so as soon as you have a component for it I would love to try it out!
Had a look at your program but I thought it would be best to wait for a component :)

Great work!

User avatar
Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 494 times
Been thanked: 188 times

Re: ENC28J60 Ethernet LAN

Postby Rudi » Sun Sep 07, 2014 1:23 pm

Dear Benj, and Jac too..
thank you so much! This work is teaching great how must go on in Flowcode and !
this example is showing in your many macros many many details how process and datasheets are must hold.
This work is our Pattern / Template for doing code in Flowcode.
I am sure, if many works like this is showing, the User will learn so much by read and doing with it and "identify himself" with the work.
Great! and my absolutly Respect.

I try the same with USB Serial, but my flowchart is a "Higgledy-piggledy" ( i hope this is the corect translation ) it runs but the flowchart "can you stand to mount the hair" ..
your Flowchart is so clear, understand and teach in processing ... whow!!
txs

speechless and flabbergasted

Thanks so much!
Best wishes
Rudi
;-)

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby kersing » Sun Sep 07, 2014 1:52 pm

To avoid confusion, Ben did everything. So all praise should be directed his way.
These users thanked the author kersing for the post:
Rudi (Sun Sep 07, 2014 1:54 pm)
Rating: 5.56%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby hyperion007 » Sun Sep 07, 2014 5:37 pm

Just quickly tried Ben's program from his latest post, changed the chip to PIC18F4550 and made the necessary changes to the config and tried to compile it but got this message:

ENC28J60_PIC18F4550.c(133): error: total number of array elements can not exceed 0x100 (use -idx 2 compiler command line argument to remove this restriction)
ENC28J60_PIC18F4550.c(689:26): warning: local variable 'FCL_OBJHANDLE' may be used uninitialized

Haven't seen that before so I thought I ask before trying the -idx 2 argument.
These users thanked the author hyperion007 for the post:
Benj (Mon Sep 08, 2014 10:08 am)
Rating: 5.56%
 

User avatar
Benj
Matrix Staff
Posts: 14151
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4330 times
Been thanked: 4080 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby Benj » Sun Sep 07, 2014 11:01 pm

Cheers for the comments everyone shouldnt take long for me to merge this with he current webserver code base and streamline the interface. Ideally it should refer to files on an sd card so we can do a proper embedded web server with images etc but we'll see how it goes and how much time i get.

As for the size of the buffer try changing the variable size to 256 and change the parameter size at the top of the loop macro and it should still work ok if your webpage is small or sent in multiple packets (not sure how to do this yet without looking back on my ip stack notes). The idx2 workaround should also work but puts a bit more more strain in the pics ram based stack.

Ill try to get this issue solved for the component.
These users thanked the author Benj for the post:
Rudi (Mon Sep 08, 2014 2:09 am)
Rating: 5.56%
 

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby hyperion007 » Mon Sep 08, 2014 7:23 am

Great!

I probably won't use it as a web server but I plan on using GET and POST to send data to a MySQL database just as I did with GPRS. Maybe there can be a component macro for GET and one for POST? Just a thought.
These users thanked the author hyperion007 for the post:
Benj (Mon Sep 08, 2014 10:08 am)
Rating: 5.56%
 

User avatar
Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 494 times
Been thanked: 188 times

Re: ENC28J60 Ethernet LAN

Postby Rudi » Mon Sep 08, 2014 11:03 am

Hi guys,

perfect!
I have play with the loop, and have inserted for pin sets simple.

Simple Testing..
after "/ "
i inserted a calc for the .CompString[0..2] and make two Compare$
"/1x"
simple output Pin B1=0
and
"/1o"
simple output Pin B1=1

This switched the LED at the Board in Browser
http://192.168.1.55/1x
http://192.168.1.55/1o

So i play with a little selfmade Http Server, and includ here https ;-)
and at the HomeServer (https) i have make a simple SwitchPage.in the index.htm. as a iframe.
that is for "me" the Best - that do not refresh the "Index.htm", but proccess the iframe..

<iframe src="Http://192.168.1.55/" width=100% name=_MCU></iframe>

added two links with

<a href="http://192.168.1.55/1x" target=_MCU> Led On </a><br>
<a href="http://192.168.1.55/1o" target=_MCU> Led Off </a><br>

this can browsed with
-> Arduino..Berry...IOS...Win...Linux... and so on

and switching the MCU ;-) over the ENC28J60 with all.

If connect the ENC28J60 with a Cross LAN direct to a WLAN Port, the Wlan will be transparent for the ENC28J60 ;-)

I make simple's App then for Android, Java App and so on, i will add a short video next time, just in time i do this and encode little smalle file format

btw:
I have make new properties too
Category: Webside
New: DefaultSide
VariableName:Homepage1
moreLineText: <html><head><title>MCU ENC28J60 by Benj</title><head><script Language="JavaScript">alert("Hello MCU");</script></head><body><br><h3> Welcome to ENC28J60 MCU Side </h3></body></html>
New:Side1
VariableName:MCUWeb1
..
..

in the Flow
.plen=IpFillTcpData(.plen,Homepage1)
thats all
:-)

Benj ;-) thank you!

Best wishes
Rudi
;-)

Edit:
in combinied with the Motorola VIP1710-F32 ( a little Linux Box with SCART, Video ect .. as WebServer and more ) this absolutly a fine Duo ;-) too.
These users thanked the author Rudi for the post:
Benj (Mon Sep 08, 2014 1:59 pm)
Rating: 5.56%
 

User avatar
Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 494 times
Been thanked: 188 times

Re: ENC28J60 Ethernet LAN

Postby Rudi » Mon Sep 08, 2014 4:23 pm

@benj

Thank You!

http://youtu.be/epbqWxFqIV0

Best wishes
Rudi
;-)
These users thanked the author Rudi for the post (total 2):
Benj (Mon Sep 08, 2014 5:36 pm) • dazz (Mon Sep 08, 2014 6:53 pm)
Rating: 11.11%
 

User avatar
Benj
Matrix Staff
Posts: 14151
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4330 times
Been thanked: 4080 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby Benj » Mon Sep 08, 2014 5:37 pm

Cheers Rudi,

Like the video and all the ways you are accessing the interface. Great work!
These users thanked the author Benj for the post:
Rudi (Mon Sep 08, 2014 5:47 pm)
Rating: 5.56%
 

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: ENC28J60 Ethernet LAN

Postby hyperion007 » Tue Sep 09, 2014 8:03 am

I did change the things you suggested Ben and it did compile but I couldn't get it to work. I am impatient I know :) but I'll wait until the component is done because I'm not even sure how to connect it. The switch didn't even notice that a cable was connected.