Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Arduino and w5100

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO
View previous topic :: View next topic  
Author Message
krolikbest

Bascom Member



Joined: 02 Jan 2017
Posts: 71

poland.gif
PostPosted: Sun Apr 05, 2020 8:42 pm    Post subject: Arduino and w5100 Reply with quote

Hello,
below my code
Code:

$regfile = "m328pdef.dat"
$crystal = 16000000
$baud = 19200                                               ' use baud rate
$hwstack = 128                                              ' default use 32 for the hardware stack
$swstack = 128                                              ' default use 10 for the SW stack
$framesize = 128                                            ' default use 40 for the frame space

config portd.3 = output : W5100rst Alias portd.3

 Config Spi = Hard , Interrupt = Off , Data_order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 4 , Noss = 0
'Init the spi pins
Spiinit


wait 500
reset w5100rst
Waitms 500
Set W5100rst

Print "Init TCP"
Enable Interrupts
Config Tcpip = Int1 , Mac = 0.128.12.34.56.78 , Ip = 192.168.1.70 , Submask = 255.255.255.0 , Gateway = 192.168.1.1 , Localport = 5000 , Tx = $55 , Rx = $55 , Chip = W5100 , Spi = 1
Print "Init done"

do
loop
 

Something i'm doing wrong , because I can't ping arduino shield W5100 from my pc-machine. Can someone explaint what is wrong?
Do I think correctly that Int1 for 328 is portd.3, so reset it and then set it as I do is correct?
When i ping this shield i see that diode rx is blinking but nothing seen in the prompt window of pc-machine.
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5070
Location: Holland

blank.gif
PostPosted: Mon Apr 06, 2020 1:28 pm    Post subject: Reply with quote

you best have a look at the samples from the W5100 folder.

Code:


Config Spi = Hard , Interrupt = Off , Data_order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 4 , Noss = 0
'Init the spi pins
Spiinit

Config Tcpip = Noint , Mac = 12.128.12.34.56.78 , Ip = 192.168.1.70 , Submask = 255.255.255.0 , Gateway = 192.168.1.1 , Localport = 1000 , Tx = $55 , Rx = $55 , Chip = W5100 , Spi = 1 , Cs = Portb.2
 


noint is used.


then, when you connect to your network you must pay attention : is your gateway actually 192.168.1.1 as in the example?
or does it have a different IP ?

then also check if the IP you assign to your w5100 does not exist already.
and last. do not start MAC address with a zero.

_________________
Mark
Back to top
View user's profile Visit poster's website
krolikbest

Bascom Member



Joined: 02 Jan 2017
Posts: 71

poland.gif
PostPosted: Mon Apr 06, 2020 1:57 pm    Post subject: Reply with quote

Thanks for your reply, in few hours will test it.
Back to top
View user's profile
krolikbest

Bascom Member



Joined: 02 Jan 2017
Posts: 71

poland.gif
PostPosted: Tue Apr 07, 2020 9:14 am    Post subject: Reply with quote

Hello
definitely something is wrong with w5100. checked examples from directory /samples/w5100/ping_spi.bas (changed regfile and crystal - Arduino and
Code:
Config Tcpip = Noint

) and couldn't get it to work .My suspicion is that perhaps some internal registry of W5100 should be changed? I see this IP's device in scanning program but ping try return that is blocked or time elapsed. If someone has any idea according this subject...

Afret some time:

i left only this code:

Code:

$regfile = "m328pdef.dat"
$crystal = 16000000                                   ' used crystal frequency
$baud = 19200                                               ' use baud rate
$hwstack = 128                                              ' default use 64 for the hardware stack
$swstack = 128                                              ' default use 64 for the SW stack
$framesize = 128                                            ' default use 80 for the frame space


Const Cdebug = 1

Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0


'Configuration Of The SPI bus
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 4 , Noss = 0
'Init the spi pins
Spiinit


'we do the usual
Print "Init TCP"                                            ' display a message
Enable Interrupts                                           ' before we use config tcpip , we need to enable the interrupts
Config Tcpip = Noint , Mac = 12.128.12.34.56.78 , Ip = 192.168.115.170 , Submask = 255.255.255.0 , Gateway = 192.168.115.200 , Localport = 1000 , Tx = $55 , _
         Rx = $55 , Chip = W5100 , Spi = 1 , Cs = Portb.2
Print "Init done"
 

and it started ping-ing, but some ping are lost.
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5070
Location: Holland

blank.gif
PostPosted: Tue Apr 07, 2020 1:56 pm    Post subject: Reply with quote

you best start with checking the circuit. maybe a buffer is used or the CS pin is not connected to the SPI CS pin?
Or there is some reset line connected.

i have no idea if you checked my earlier comments and what your knowledge about IP is.

i used w5100 for a long time but not especial with arduino. so at least post a circuit of the shield you use. and info about your gateway. using IPCONFIG /ALL will give info about thegateway. that should match the gateway in the config tcpip.

_________________
Mark
Back to top
View user's profile Visit poster's website
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 694

poland.gif
PostPosted: Tue Apr 07, 2020 4:16 pm    Post subject: Reply with quote

I can tell that there is no problem for me to ping in my home network my two currently online devices like W5100 and Wiz850io.
Look at the screens. They both appear in the WNetWatcher from Nirsoft and PING straight from Windows console so I think problem is not in the Wizznet registers Very Happy Even MAC can start with zeros Very Happy





My Wizznets working with parameter "NOINIT" in the TCPIP CONFIG so I can compile one soft for all my devices like W5100 and after programming I set them (IP, GATE, MASK, PORT etc.) with my software and store config in the eeprom.



So at the end -> to the point.
Try use Noinit and then config Wizz with SETTCP

I think I will share my API for Bascom that work together with that PC software if I find some time...
Back to top
View user's profile Visit poster's website
krolikbest

Bascom Member



Joined: 02 Jan 2017
Posts: 71

poland.gif
PostPosted: Tue Apr 07, 2020 4:43 pm    Post subject: Reply with quote

shield: https://allegro.pl/oferta/modul-sieciowy-arduino-w5100-mikrosd-avr-ethernet-8877580603?utm_feed=aa34192d-eee2-4419-9a9a-de66b9dfae24&utm_source=google&utm_medium=cpc&utm_campaign=_ELKTRK_PLA_RTV+i+AGD&ev_adgr=Sprz%C4%99t+satelitarny&gclid=Cj0KCQjwybD0BRDyARIsACyS8msXV24u3zUMjxEKkEPrP-TJcusqNiE1LJJ5JUvoQ2744WUV8l94-BUaAvM8EALw_wcB

I've noticed that $hwstack = 192 gives a better reliability in ping-ing Wink, so testing this stuff in my office at work gives good result - all 4 packet received . At work I use -ip : 192.168.115.170 and gateway : 192.168.115.200 whareaas at home use ip : 192.168.1.70 and gateway : 192.168.1.1 and I can't run it at home.
Back to top
View user's profile
krolikbest

Bascom Member



Joined: 02 Jan 2017
Posts: 71

poland.gif
PostPosted: Wed Apr 08, 2020 7:47 pm    Post subject: Reply with quote

Ok, have found the cause why doesn't it work at home - ethernet cable. Despite other devices work on this one, my Uno with W5100 didn't. After changing to brand new is fine Smile it took me only 20 hours to discover that Wink
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5070
Location: Holland

blank.gif
PostPosted: Wed Apr 08, 2020 7:52 pm    Post subject: Reply with quote

ha, yes that happened to me too. crazy.

also had broken wire inside new connector cables. but that was relatively simple to find.
while i do a lot of analyzing of problems, once in a while there is a problem that eats time. and often i feel stupid when i find the cause. Embarassed

glad you found the problem Very Happy

_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum