ethernet interface

lbenson

Senior Member

hippy

Ex-Staff (retired)
The ENC28J60 just grabs raw packets from the LAN and allows raw packets to be put on it; the PICAXE would have to handle those raw packets to make the data usable.

For network level and management protocols (ARP, RARP, ICMP/Ping), probably even UDP, that should be possible but anything at a higher level (TCP) gets more complicated. There are some tricks to create a limited but usable TCP/IP stack which could work with a PICAXE and ENC28J60 to create a PICAXE web server etc.

I would guess there's no PICAXE code primarily because no one has put effort into doing that or even trying it. It's quite a niche field and needs a reasonably good understanding of TCP/IP protocols and how they are layered. It's not too hard to understand but can be a challenge to implement; as Ibenson says, non-trivial.
 

lbenson

Senior Member
The Bascom implementation is well documented--step by step--and could be translated to picaxe basic. It implements ARP, Ping, UDP, and TCP. I would suspect that it would take several days to make a translation.

I'd love to see a $3US picaxe-to-Ethernet solution, which the ENC28J60 modules could provide if the code were available.
 

hippy

Ex-Staff (retired)
The Bascom project does look like a good reference design and step-by-step guide to implementation.

I had done similar with a 3com NIC and an MS-DOS Basic program but what stopped me doing anything with the ENC28J60 those years ago was lack of pre-built modules including mag-jack and limited reference code. The required mag-jacks were difficult to obtain and far more expensive than the ENC28J60 back then! Having to understand the ENC28J60 from the ground up was something I didn't relish spending time on so just put it to the side.

Should be easier these days and an ENC28J60 Shield should simply 'just work' with an AXE401 Shield Base. An SPI module shouldn't be too hard to interface. Which just leaves the coding.

With the Bascom code base I would venture ICMP (ping) and UDP could be working within a few days then everything else should come quite quickly. One doesn't need much more than being able to read and write a packet to be able pass data between PICAXE's or PC so perhaps not as hard as I thought it was.
 

lbenson

Senior Member

buntay

Senior Member
I have been playing with networking and picaxe for about a year now and have had success with

http://www.ebay.com/itm/Embedded-TTL-wifi-module-RS232-evaluation-board-Antenna-for-data-transmission-/221366984638?pt=US_Wireless_Access_Points&hash=item338a801fbe

and http://www.ebay.com/itm/RS232-TTL-to-Ethernet-TCPIP-RJ45-Converter-Module-e-/251338018097?pt=LH_DefaultDomain_0&hash=item3a84e9cd31

once setup, both easily done, they work well when used in conjunction with windows hyper terminal or home brew windows software.

The wifi version seems to hold a small buffer when you log into it before stabilizing where the lan cable version is clean input at login but both work very well.

here is the picaxe code I tested with
Code:
setfreq m8

pause 1000
serout c.4,t9600,("System Reset",cr,lf)
pause 3000

main:
serout c.4,t9600, ("sending data!",cr,lf)
serin  [2000], c.7,t9600, ("dat"),b1
if b1 = "a" then step1
goto main



step1:
serout c.4,t9600,("ok",cr,lf) 
pause 2000

b1=0
serout c.4,t9600, ("awaiting command",cr,lf)
serin [60000],c.7,t9600,b8


if b8="1" then main 
if b8="2" then shutdown
if b8="3" then planb 
if b8="4" then planc
if b8="5" then pland
if b8="6" then plane
if b8="7" then planf
if b8="8" then plang
if b8="9" then reset
endif
goto main

shutdown:
serout c.4,t9600, ("system will now shut down",cr,lf)
pause 3000
goto waiting


planb:

serout c.4,t9600, ("now in plan B mode",cr,lf)
pause 3000
bmain:
serout c.4,t9600, ("sending *B* data",cr,lf)
serin  [1000], c.7,t9600, ("dat"),b1
if b1 = "a" then step1
goto bmain



planc:

serout c.4,t9600, ("now in plan C mode",cr,lf)
pause 3000
cmain:
serout c.4,t9600, ("sending *C* data",cr,lf)
serin  [1000], c.7,t9600, ("dat"),b1
if b1 = "a" then step1
goto cmain


pland:

serout c.4,t9600, ("now in plan D mode",cr,lf)
pause 3000
dmain:
serout c.4,t9600, ("sending *D* data",cr,lf)
serin  [1000], c.7,t9600, ("dat"),b1
if b1 = "a" then step1
goto dmain

plane:

serout c.4,t9600, ("now in plan E mode",cr,lf)
pause 3000
emain:
serout c.4,t9600, ("sending *E* data",cr,lf)
serin  [1000], c.7,t9600, ("dat"),b1
if b1 = "a" then step1
goto emain

planf:

serout c.4,t9600, ("now in plan F mode",cr,lf)
fmain:
serout c.4,t9600, ("sending *F* data",cr,lf)
serin  [1000], c.7,t9600, ("dat"),b1
if b1 = "a" then step1
goto fmain


plang:

serout c.4,t9600, ("now in plan G mode",cr,lf)
gmain:
serout c.4,t9600, ("sending *G* data",cr,lf)
serin  [1000], c.7,t9600, ("dat"),b1
if b1 = "a" then step1
goto gmain

waiting:
b8=0
serout c.4,t9600, ("System is Shut Down",cr,lf)
serout c.4,t9600, ("awaiting command",cr,lf)
serin [60000],c.7,t9600,b8


if b8="1" then main 
if b8="2" then shutdown
if b8="3" then planb 
if b8="4" then planc
if b8="5" then pland
if b8="6" then plane
if b8="7" then planf
if b8="8" then plang
if b8="9" then reset
endif
goto waiting
I use VB6 for my programming needs.
screen shot:
screen.JPG

VB6 code:
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub cmdConnect_Click()
sockMain.RemoteHost = txtHost.Text
sockMain.RemotePort = txtPort.Text
sockMain.Connect
End Sub

Private Sub cmdSend_Click()
txtStatus.Text = ""
sockMain.SendData "data"
End Sub

Private Sub Command1_Click()
sockMain.SendData "1"
txtStatus.Text = ""
End Sub

Private Sub Command10_Click()
sockMain.Close
End Sub

Private Sub Command11_Click()
txtStatus.Text = ""
End Sub

Private Sub Command2_Click()
sockMain.SendData "2"
txtStatus.Text = ""
End Sub

Private Sub Command3_Click()
sockMain.SendData "3"
txtStatus.Text = ""
End Sub

Private Sub Command4_Click()
sockMain.SendData "4"
txtStatus.Text = ""
End Sub

Private Sub Command5_Click()
sockMain.SendData "5"
txtStatus.Text = ""
End Sub

Private Sub Command6_Click()
sockMain.SendData "6"
txtStatus.Text = ""
End Sub

Private Sub Command7_Click()
sockMain.SendData "7"
txtStatus.Text = ""
End Sub

Private Sub Command8_Click()
sockMain.SendData "8"
txtStatus.Text = ""
End Sub

Private Sub Command9_Click()
sockMain.SendData "9"
txtStatus.Text = ""
End Sub

Private Sub Form_Load()
txtHost.Text = "192.168.1.124"
txtPort.Text = "2433"
txtStatus.Text = ""
End Sub

Private Sub sockMain_DataArrival(ByVal bytesTotal As Long)
Dim strData As String

sockMain.GetData strData, vbString
txtStatus.Text = txtStatus.Text + strData

End Sub


works flawlessly on a 20x2.
 
I have been playing with networking and picaxe for about a year now and have had success with

http://www.ebay.com/itm/Embedded-TTL-wifi-module-RS232-evaluation-board-Antenna-for-data-transmission-/221366984638?pt=US_Wireless_Access_Points&hash=item338a801fbe

and http://www.ebay.com/itm/RS232-TTL-to-Ethernet-TCPIP-RJ45-Converter-Module-e-/251338018097?pt=LH_DefaultDomain_0&hash=item3a84e9cd31

once setup, both easily done, they work well when used in conjunction with windows hyper terminal or home brew windows software.

The wifi version seems to hold a small buffer when you log into it before stabilizing where the lan cable version is clean input at login but both work very well.

here is the picaxe code I tested with
Code:
setfreq m8

pause 1000
serout c.4,t9600,("System Reset",cr,lf)
pause 3000

main:
serout c.4,t9600, ("sending data!",cr,lf)
serin  [2000], c.7,t9600, ("dat"),b1
if b1 = "a" then step1
goto main



step1:
serout c.4,t9600,("ok",cr,lf) 
pause 2000

b1=0
serout c.4,t9600, ("awaiting command",cr,lf)
serin [60000],c.7,t9600,b8


if b8="1" then main 
if b8="2" then shutdown
if b8="3" then planb 
if b8="4" then planc
if b8="5" then pland
if b8="6" then plane
if b8="7" then planf
if b8="8" then plang
if b8="9" then reset
endif
goto main

shutdown:
serout c.4,t9600, ("system will now shut down",cr,lf)
pause 3000
goto waiting


planb:

serout c.4,t9600, ("now in plan B mode",cr,lf)
pause 3000
bmain:
serout c.4,t9600, ("sending *B* data",cr,lf)
serin  [1000], c.7,t9600, ("dat"),b1
if b1 = "a" then step1
goto bmain



planc:

serout c.4,t9600, ("now in plan C mode",cr,lf)
pause 3000
cmain:
serout c.4,t9600, ("sending *C* data",cr,lf)
serin  [1000], c.7,t9600, ("dat"),b1
if b1 = "a" then step1
goto cmain


pland:

serout c.4,t9600, ("now in plan D mode",cr,lf)
pause 3000
dmain:
serout c.4,t9600, ("sending *D* data",cr,lf)
serin  [1000], c.7,t9600, ("dat"),b1
if b1 = "a" then step1
goto dmain

plane:

serout c.4,t9600, ("now in plan E mode",cr,lf)
pause 3000
emain:
serout c.4,t9600, ("sending *E* data",cr,lf)
serin  [1000], c.7,t9600, ("dat"),b1
if b1 = "a" then step1
goto emain

planf:

serout c.4,t9600, ("now in plan F mode",cr,lf)
fmain:
serout c.4,t9600, ("sending *F* data",cr,lf)
serin  [1000], c.7,t9600, ("dat"),b1
if b1 = "a" then step1
goto fmain


plang:

serout c.4,t9600, ("now in plan G mode",cr,lf)
gmain:
serout c.4,t9600, ("sending *G* data",cr,lf)
serin  [1000], c.7,t9600, ("dat"),b1
if b1 = "a" then step1
goto gmain

waiting:
b8=0
serout c.4,t9600, ("System is Shut Down",cr,lf)
serout c.4,t9600, ("awaiting command",cr,lf)
serin [60000],c.7,t9600,b8


if b8="1" then main 
if b8="2" then shutdown
if b8="3" then planb 
if b8="4" then planc
if b8="5" then pland
if b8="6" then plane
if b8="7" then planf
if b8="8" then plang
if b8="9" then reset
endif
goto waiting
I use VB6 for my programming needs.
screen shot:
View attachment 15861

VB6 code:
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub cmdConnect_Click()
sockMain.RemoteHost = txtHost.Text
sockMain.RemotePort = txtPort.Text
sockMain.Connect
End Sub

Private Sub cmdSend_Click()
txtStatus.Text = ""
sockMain.SendData "data"
End Sub

Private Sub Command1_Click()
sockMain.SendData "1"
txtStatus.Text = ""
End Sub

Private Sub Command10_Click()
sockMain.Close
End Sub

Private Sub Command11_Click()
txtStatus.Text = ""
End Sub

Private Sub Command2_Click()
sockMain.SendData "2"
txtStatus.Text = ""
End Sub

Private Sub Command3_Click()
sockMain.SendData "3"
txtStatus.Text = ""
End Sub

Private Sub Command4_Click()
sockMain.SendData "4"
txtStatus.Text = ""
End Sub

Private Sub Command5_Click()
sockMain.SendData "5"
txtStatus.Text = ""
End Sub

Private Sub Command6_Click()
sockMain.SendData "6"
txtStatus.Text = ""
End Sub

Private Sub Command7_Click()
sockMain.SendData "7"
txtStatus.Text = ""
End Sub

Private Sub Command8_Click()
sockMain.SendData "8"
txtStatus.Text = ""
End Sub

Private Sub Command9_Click()
sockMain.SendData "9"
txtStatus.Text = ""
End Sub

Private Sub Form_Load()
txtHost.Text = "192.168.1.124"
txtPort.Text = "2433"
txtStatus.Text = ""
End Sub

Private Sub sockMain_DataArrival(ByVal bytesTotal As Long)
Dim strData As String

sockMain.GetData strData, vbString
txtStatus.Text = txtStatus.Text + strData

End Sub


works flawlessly on a 20x2.

cherrs for that i might invest :)
 
Top