Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

arduino mega (2560) + ethernet shield(Wiz5500) @ bascom 2.0.

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

Bascom Member



Joined: 15 Sep 2005
Posts: 60
Location: Donauwoerth

germany.gif
PostPosted: Wed Mar 29, 2017 11:11 am    Post subject: arduino mega (2560) + ethernet shield(Wiz5500) @ bascom 2.0. Reply with quote

Hi bascom colleagues,

....recently i came in contact with arduino "ready to use" modules , previous i was used to design myself hardware by pcb and atmega chips.
the target is, to realize a small webserver with this arduino mega and an arduino ethernet shield 2, which contains the Wiz5500 chip.

after many many hours of troubleshooting, reading and also trying all relevant posts in bascom and arduino forums, which often are contradictionary statements,
i never have successful established this hardware combination.

regarding bascom, i used the wiz5200 lib..... have dealt the hardware in various configs as in forums discussed, but none of these variations has worked.

in general, it is alway possible to download and the devices run itself, the megaboard always runs and the ethernet shield acts ( led indication ) on pings,
( but never the ping was successful responsed...) typical message is : "antwort von 10.100.10.1: Zielhost nicht erreichbar" ( 10.100.10.1 is my PC IP, may be unusual but
necessary because of other industrial ethernet based test components... ) the arduino IP i have set to be in same range of adress and submask....

i checked the 6-pole SPI socket of the ethernet shield and the of the arduino mega and as literature says, there will be no conflict of using the ISP for programming the Arduino mega
by Bascom+STK500 and using the SPI as chain between ethernet shield and Arduino mega. But where is the broken part of that ensemble? Library and Pin enumeration problem? I do not know...



so.. the two units till do never walk together, even simply added via connector or, with separate spi wires and ports lowered as in forums often described. I stuck here...
with arduino IDE, i have played only one two examples, because (sorry..it may not bad but i do not prefer that..) i do not like the rudimentary IDE and the language as well.
As a feeling for me it ist a backstep of level comparing to bascom im my view.

after all fiddling around and hair-stand-up experience Smile , my simple question is: does anybody (hopefully) of you have successful run an arduino mega with ethernet2 shield on bascom?
If yes, any hints how to make it, are highly appreciated.

thanks a lot for any comment, advice or lightening the way i should proceed...
Ingolf
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5920
Location: Holland

blank.gif
PostPosted: Wed Mar 29, 2017 2:03 pm    Post subject: Reply with quote

i think the samples folder contains samples using arduino hardware.
using w3100,w5100,w5200,w5300 and w5500 chips i never had a problem. i also made a converter board for the wiz810mj module.

using some of the tcp shields i did had problems. for example because of a buffer that had to be switched. or because of bad contacts in the headers.
i found arduino hardware nice for proto but not for production.
There is also a lot of variation between the arduino boards and the shields.

I advise to start very simple. Just pick a simple sample from bascom and get the PING working.
I do not know if w5500 has echo enabled by default (some wiz chips have the option to turn off ping).

post the circuit of the shield you want to use.

for w5500 an init like this is required:
Config Tcpip = Noint , Mac = 12.128.12.34.56.78 , Ip = 192.168.1.88 , Submask = 255.255.255.0 , Gateway = 192.168.1.1 , Localport = 1000 , Chip = W5500 , Spi = Spie , Cs = Porte.4
Print "Init Done"

The gateway is important. and the submask too.

while a web server is relatively simple, you should have the ping going first.

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

Bascom Member



Joined: 15 Sep 2005
Posts: 60
Location: Donauwoerth

germany.gif
PostPosted: Thu Mar 30, 2017 8:04 am    Post subject: arduinomega(2560)+ethernetshield2(Wiz5500)@bascom 2.0.7.8 Reply with quote

- this stuff i work with and how : ----------------------------------------------------------------------------------
used Bascom Version: 2.0.7.8.001
used Hardware: ArduinoMega 2560 PCB Revision V3E
Arduino Ethernetshield2, PCB Revision ETH11 V2

used programming method: STK500 and ISP header of arduino board / no bootloader
------------------------------------------------------------------------------------------------------------




Hi Marc, thank you for fast response, i am going to workout now step by step....



from the Bascom examples ping_WS5300.bas i simply derived the code and changed the config TCPIP:

Config Tcpip = Noint , Mac = 12.128.12.34.56.78 , Ip = 192.168.1.88 , Submask = 255.255.255.0 , Gateway = 192.168.1.1 , Localport = 1000 , Chip = W5500 , Spi = Spie , Cs = Porte.4


compiler complaints "Invalid parameter for CONFIG parameter or Value [WS5500] in C:\\path\ping_ardumega2560_ethernetshiled2_V0.1.bas"
i checked then updates to bascom 2.0.7.9 ( having the valid lic file for 2.0.7.9 in directory ) but update wizard found nothing to do.

so whats the reason why compiler complains about the W5500?



add: attached the schematic of the used arduino ethernet shield
Back to top
View user's profile Visit poster's website
uhrmacher

Bascom Member



Joined: 15 Sep 2005
Posts: 60
Location: Donauwoerth

germany.gif
PostPosted: Thu Mar 30, 2017 8:11 am    Post subject: added the ethernet shield schematic... Reply with quote

i added the schematic of ethernet shield
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5920
Location: Holland

blank.gif
PostPosted: Thu Mar 30, 2017 9:14 am    Post subject: Reply with quote

for w5500 you should update. download the full setup from register.mcselec.com (see help topic move to new pc)

the circuit : there is an sd card intreface on it. so you use 2 SS signals.
Just make sure you use the correct spi signal for the w5500. which means you must measure between the micro port pin you use as SS and the w5500 IO10*/SS to see if they match/are connected.

here is a sample for w5500 and xmega. you need to change the spi for normal xmega. but you can grab that from a w5100 sample.
Code:

'-----------------------------------------------------------------------------------------
'name                     : sntp_W5500.bas   RFC 2030
'copyright                : (c) 1995-2015, MCS Electronics
'purpose                  : test SNTP() function
'micro                    : xMega128A1
'suited for demo          : no, needs library only included in the full version
'commercial addon needed  : no
'-----------------------------------------------------------------------------------------

$regfile = "xm64a3def.dat"
$crystal = 32000000
$hwstack = 64                                               ' default use 32 for the hardware stack
$swstack = 128                                              'default use 10 for the SW stack
$framesize = 64                                             'default use 40 for the frame space

'First Enable The Osc Of Your Choice
Config Osc = Enabled , 32mhzosc = Enabled
'configure the systemclock
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1
'configure UART
Config Com1 = 19200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8


Config Spie = Hard , Master = Yes , Mode = 0 , Clockdiv = Clk32 , Data_order = Msb , Ss = Auto
 'SPI on Port E is used
 'portx.7 - SCK
 'portx.6 - MISO
 'portx.5 - MOSI
 'portx.4 - SS

Waitms 1000
Print "Init , set IP to 192.168.1.88"                       ' display a message
Config Tcpip = Noint , Mac = 12.128.12.34.56.78 , Ip = 192.168.1.88 , Submask = 255.255.255.0 , Gateway = 192.168.1.1 , Localport = 1000 , Chip = W5500 , Spi = Spie , Cs = Porte.4
Print "Init Done"


$lib "datetime.lbx"                                         'this example uses date time routines


Dim Ip As Long                                              ' IP number of time server
Dim Idx As Byte                                             ' socket number
Dim Lsntp As Long                                           ' long SNTP time

Print "SNTP demo"

'assign the IP number of a SNTP server
Ip = Maketcp(129.6.15.30 )                                  'assign IP num NIST time.nist.gov  port 37
Print "Connecting to : " ; Ip2str(ip)


'we will use Dutch format
Config Date = Dmy , Separator = Minus


'we need to get a socket first
'note that for UDP we specify sock_dgram
Idx = Getsocket(idx , Sock_dgram , 5000 , 0)                ' get socket for UDP mode, specify port 5000
Print "Socket " ; Idx

'UDP is a connection less protocol which means that you can not listen, connect or can get the status
'You can just use send and receive the same way as for TCP/IP.
'But since there is no connection protocol, you need to specify the destination IP address and port
'So compare to TCP/IP you send exactly the same, but with the addition of the IP and PORT
'The SNTP uses port 37 which is fixed in the tcp asm code


Do


   Waitms 5000

   Lsntp = Sntp(idx , Ip)                                   ' get time from SNTP server
 '  Print Idx ; Lsntp
   'notice that it is not recommended to get the time every sec
   'the time server might ban your IP
   'it is better to sync once or to run your own SNTP server and update that once a day

   'what happens is that IP number of timer server is send a diagram too
   'it will put the time into a variable lsntp and this is converted to BASCOM date/time format
   'in case of a problem the variable is 0
   Print Date(lsntp) ; Spc(3) ; Time(lsntp)
Loop



End



like this :


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


'we specify IP 0.0.0.0  and gateway 255.255.255.255. Really important is to use local port 68 !
Config Tcpip = Noint , Mac = Mac_add(1) , Ip = 0.0.0.0 , Submask = 255.255.255.0 , Gateway = 255.255.255.255 , Localport = 68 , Tx = $55 , Rx = $55 , Chip = W5100 , Spi = 1
Print "Init"

 


above sample was from a dhcp so do fill in IP , mac

optional you can check with a led on the SS pin if it is selected.

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

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Thu Mar 30, 2017 1:30 pm    Post subject: Reply with quote

Hello uhrmacher
You can find working webservers in the blog section that I have written
you should only need to change the config for the W5500 instead of the W5100
Regards Paul
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5920
Location: Holland

blank.gif
PostPosted: Thu Mar 30, 2017 1:36 pm    Post subject: Reply with quote

uhrmacher

please update your email address in the forum account settings. if you have no idea, please write to support.

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

Bascom Member



Joined: 15 Sep 2005
Posts: 60
Location: Donauwoerth

germany.gif
PostPosted: Mon Apr 03, 2017 10:05 am    Post subject: SPI between Arduino mega and ethernet shield Reply with quote

Hello, good morning Smile

@marc - my email is now updated, sorry for leaving it "old"


-> i have updated successful to 2.0.8.0 and retried to compile with the "chip = W5500" in line Config TCPIP but this option will still be denied by compiler
with message : Error 86, invalid parameter for config parameter or value [w5500]

config Tcpip = noint , MAC = 12.128.12.34.56.78 , Ip = 192.168.1.88 , submask = 255.255.255.0 , Gateway = 192.168.1.1 , localport = 68 , [b]Chip = W5500[/b] , Spi = 1





while i believe, that the communication between the Arduino mega and the Arduino shield may work not properly,
i checked out these interconnection between and i have found this connections between the ATmega2560 and the W5500 chip over all connectors, from Pin to Pin.

what confuses me, the "ss" of Atmega refers not to anything of the ethernet shield.
the /res ends to the reset circuit on the shield.

sck and mosi are provided via 74LVC1G125, ok, these are only buffers, so should not cause problems...

please see table below:


' SIG------2560-----Port---------header #nr-----ISP on----------ISP--------------------------------------------------W5500
' _________________________arduino board_arduino mega_arduino eth shield2

' SS------- Pin 19---PortB.0-----header #53----no
' MISO---- Pin 22---PortB.3-----header #50----Pin 1------------ Pin 1 MISO -------- direct ------------------------- Pin 34
' SCK----- Pin 20---PortB.1-----header #52----Pin 3-------------Pin 3 SCK --------- via 74LVC1G125 ------------- as SCK3 --- Pin 33
' MOSI---- Pin 21---PortB.2-----header #51----Pin 4------------ Pin 4 MOSI ------- via 74LVC1G125 -------------- as MOSI3 -- Pin 35
' Reset---- Pin 30---/res----------reset-----------Pin 5------------ Pin 5 reset ---------to reset circuit on shield.. not to W5500


at the hardware i have no clue how to connect "alternatively" the "ss" to the ethernet shield.


@Paulvk , thank you for the hint, i will check the SPI enumeration of webserver examples


Ingolf
Back to top
View user's profile Visit poster's website
uhrmacher

Bascom Member



Joined: 15 Sep 2005
Posts: 60
Location: Donauwoerth

germany.gif
PostPosted: Tue Apr 11, 2017 8:11 am    Post subject: Arduino megaand ethernet shield ping solved.... Reply with quote

remembering.....my problem was, not having a response while ping the arduino....

on my first used hardware, consisting of an arduino mega + ethernet shield2, i have found that the ethernet shield hardware is fault, i never have got a proper function of it.

after many retries, while i was in the believe, something with my program code/configuration may be wrong, i found the conclusion to order two more arduino devices, but not the types i already have from arduino.org, i ordered 3.party clones, in my case from the supplier "eckstein-komponente.de". They delivered me as a bundle two "arduino mega compatible" + two ethernet shield with the W5100 chip .

Tested with an arduino code example, both units worked well, the ping was successful responsed which gaves me the confidence that my pc network/switch IP config, cables etc. was already fine. Then i tested my "old" arduino+ethernetshield and it has gone failed, "....as expected". With the new modules, i call it "eckstein ethernet shield" i tested the arduino.org arduino mega and it was fine, so the arduino.org ethernet shield2 was isolated to be defective.

then, next step, confident im my hardware now, i began to check bascom code on the eckstein arduino mega+ ethshield. First try runs bad, then i took an unedited example, edit only the IP and runs again, and it has worked.

As far, no w i have worked out two pieces of bascom code, the one worked, the other not, and i stripped all of the code what was not necessary only to get the ping response.
Only few lines has been left.


this small code is enough for getting a ping response:


this code works............................

--------------------------------------------------------------------------------------------------------------------------------------------------
$regfile = "m328pdef.dat"
$crystal = 16000000 '16MHz
$hwstack = 100
$swstack = 100
$framesize = 400


Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 4 , Noss = 0
Spiinit

Enable Interrupts

Config Tcpip = Noint , _
Mac = 1.1.94.127.1.255 , _
Ip = 192.168.80.10 , _
Submask = 255.255.255.0 , _
Gateway = 192.168.80.254 , _
Localport = 1000 , _
Tx = $55 , Rx = $55 , _
Chip = W5100 , _
Spi = 1

--------------------------------------------------------------------------------------------------------------------------------------------------------------

... and this code works not, means, NO ping response:


$regfile = "m328pdef.dat" ' specify the used micro
$crystal = 16000000 ' used crystal frequency
$hwstack = 100 ' default use 32 for the hardware stack
$swstack = 100 ' default use 10 for the SW stack
$framesize = 400 ' default use 40 for the frame space


Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 4 , Noss = 0
Spiinit


Enable Interrupts
' before we use config tcpip , we need to enable the interrupts
Config Tcpip = Noint , Mac = 1.23.45.67.89.01 , Ip = 192.168.80.10 , Submask = 255.255.255.0 , Gateway = 192.168.80.254, Localport = 1000 , Tx = $55 , Rx = $55 , Chip = W5100 , Spi = 1


Print "Init done"

------------------------------------------------------------------------------------------------------------------------------------------------------------

the codes, independent from the format, are the same until this last line in the second code snippet:

[b] Print "Init done"[/b]

surprisingly, i found that as i have deleted the print command, this code snippet responses also the ping. But i do not know why............




Conclusion overall:

it seems to be that arduino devices have a variety in product quality of the boards, the last examples i ordered from a 3rd party manufacturers was much much better in quality than the parts from arduino itself. Specially the press-to-fit pins seems to be a problem, i soldered all and i found that some vias on the pcd was damaged by the press-fit pins while inserted. I stuck lot of time on a defectice board while i never really believed that a new piece could be dead.

second reason, obviously, the print command after config tcpip does something, preventing the board from responsing the ping.



About ISP @ mega2560 module+ethernet shield:

last but not least: arduino uses a most a bootloader, but for my hardware, an arduino mega2560 + ethernetshield, i prefer to upload code via ISP, although for that reason to have the USB free for serial application. on the hardware you will see, that if shield is plugged onto the 2560 module, the ISP connector of the 2560 is occupied.
As a simple solution, i soldered a 3x2 2,54 pin header on the upper side of the shield, top on the solder pads where the ISP socket of the shield is mounted. This way i have the ISP interface "extended" and i can reconnect it to my STK500 again......business as usual can run once more.





i must say, i worked a lot with bascom on my own designed PCB hardware, not so much with prefabricated modules and ethernet applications where new....i was a newbie on that.
I hope my short story helps others to ship around the obstacles.... Smile
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5920
Location: Holland

blank.gif
PostPosted: Tue Apr 11, 2017 9:43 am    Post subject: Reply with quote

is there an END after the code?
it appears the MAC address is different.
There are a number of examples in the samples\tcpip\w5100 folder. you best check them.

i think i mentioned it before ; arduino is nice for proto but because of bad connectors, it is not usable for a production. at least IMO. do not assume that something you buy new is good. it can be fake or just badly tested.

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

Bascom Member



Joined: 22 Jun 2004
Posts: 1161
Location: France

france.gif
PostPosted: Tue Apr 11, 2017 10:31 am    Post subject: Reply with quote

hi Ingolf
Thanks for having us explain your approach.
Indeed the "shield" and the ready to serve modules requires lots of connections, wires ...
and, therefore, increases the risk of failure. unfortunately I know Crying or Very sad ! Like you I use them for proto, but after, I realize my own C I.
JP
Wink
Back to top
View user's profile Visit poster's website
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Tue Apr 11, 2017 11:32 am    Post subject: Reply with quote

Hello uhrmacher

Having worked with making a web-server with the AVRs I found most too limiting
So I designed my own board to take the Mega 1284P and the Arduino shield
The reason for the 1284P board
20Mhz clock
10Mhz SPI
16K of ram <very important for buffers
Need real time clock with battery
3Amp switching power supply with polarity protection and screw terminals
Buffered RS232 with cable headers
Proper cable header for cables to ports
Resistors and cable header for I2C port
Small board same size as shield
Able to disconnect SPI from shield
second SPI header for programmer
all parts big enough that I can solder by hand

I posted here the files to get boards made https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=13658
cost me $40 US to get boards 10 made including shipping
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Tue Apr 11, 2017 11:55 pm    Post subject: Removing programming cable? Reply with quote

My two cents...

Do you remove your programming cable after flashing?

I read that you are using the STK500 icsp cable. That is connected to Mosi / Miso and CLK.

Ben Zijlstra
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