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

Post by Tom Stefanou »

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-n ... lpc-150604.

If somebody can help i would really appreciate.

Best regards,

Tom

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

Re: ENC28J60 Ethernet LAN

Post by Benj »

Hi Tom,

Looks do-able, I'll have a play and see how far I get.

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

Post by Tom Stefanou »

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: 23
Joined: Fri Jun 08, 2012 10:54 am
Location: India
Has thanked: 10 times
Been thanked: 3 times
Contact:

Re: ENC28J60 Ethernet LAN

Post by Sanjay Singh »

Any updates on ENC28J60 Ethernet LAN BenJ ?

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

Re: ENC28J60 Ethernet LAN

Post by conroydp »

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

Post by conroydp »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ENC28J60 Ethernet LAN

Post by Benj »

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.

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

Re: ENC28J60 Ethernet LAN

Post by Benj »

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 686 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 31754 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 31754 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.

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: ENC28J60 Ethernet LAN

Post by kersing »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ENC28J60 Ethernet LAN

Post by Benj »

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: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: ENC28J60 Ethernet LAN

Post by kersing »

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
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

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

Re: ENC28J60 Ethernet LAN

Post by Benj »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ENC28J60 Ethernet LAN

Post by Benj »

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 609 times
Proof it works :) HTML needs changing though :roll:
SS3.jpg
SS3.jpg (78.89 KiB) Viewed 31742 times
Right now it's working I'll have a play and add some polish.

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: ENC28J60 Ethernet LAN

Post by Rudi »

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

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: ENC28J60 Ethernet LAN

Post by Rudi »

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

Post by hyperion007 »

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!

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: ENC28J60 Ethernet LAN

Post by Rudi »

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: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: ENC28J60 Ethernet LAN

Post by kersing »

To avoid confusion, Ben did everything. So all praise should be directed his way.
“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

Post by hyperion007 »

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.

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

Re: ENC28J60 Ethernet LAN

Post by Benj »

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.

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

Post by hyperion007 »

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.

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: ENC28J60 Ethernet LAN

Post by Rudi »

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.

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: ENC28J60 Ethernet LAN

Post by Rudi »

@benj

Thank You!

http://youtu.be/epbqWxFqIV0

Best wishes
Rudi
;-)

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

Re: ENC28J60 Ethernet LAN

Post by Benj »

Cheers Rudi,

Like the video and all the ways you are accessing the interface. Great work!

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

Post by hyperion007 »

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.

Post Reply