Using the Arduino Ethernet shield with AMICUS18 (Joint forum project?)


Results 1 to 40 of 63

Threaded View

  1. #11
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,622

    Default Re: Using the Arduino Ethernet shield with AMICUS18 (Joint forum project?)

    Hi everyone,
    Time for an update. As I wrote in the previous post I've had DHCP working nicely and today I thought it was time to show you how it can be used. However, for this to work nicely, there had to be some changes made to the overall structure of the package of files used. It gets easier to USE but a tad more complicated to maintain. I won't go into specific details, just give you the overall picture.


    First of all, the code now requires PBP3. This is beacuse I've added a bunch of conditional debug statements in the code making use of the wonderful conditional compilation feature of PBP3. For example, you can add #W5100_DEBUG_LEVEL 1 to the top of the code and you'll get a whole bunch of data sent over the USART, if you want even more details do #W5100_DEBUG_LEVEL 2. Do note though that these takes up a lot of program space so if the application grows they might not fit when "activated".


    The main include file for using the W5100 is called W5100.pbp and that's what you should included from the main program/application. It is also in THIS file that you may need to make some changes to match your project:

    1) BufferLenght CON 256 - This is the length of the local buffer (array) that gets declared, you can change this to match your needs. Don't make it too small though, the DHCP routines - if you're going to use those, requires a lenght of ~48 minimum.

    2) MAC-adress - This is the hardware adress of the device, change as needed - and please DO change it, don't use mine! As can be seen the MAC adress is defined as constants and can therefor currently not be changed at runtime - this MAY change or you can change it yourself.

    3) W5100_Select VAR PortB.5 - this is the PIC-pin to which ChipSelect pin of the W5100 is connected. My modified Arduino Ethernet Shield uses PortB.5

    This file (W5100.pbp) then includes two more files - W5100_defs.pbp (which we've looked at before) and W5100_subs.pbp which contains several of the routines discussed in earlier posts as well as others. Neither of these files 'should' need to be edited.


    In previous "exercises" we've hardcoded the IP-adress, netmask and gateway address of the W5100 - for DHCP to work properly this can't be done. So I've declared three arrays (in W5100_subs.pbp) called W5100_IP, W5100_Netmask and W5100_Gateway - all 4 bytes long. To set the network parameters of the W5100 we can now do something like:
    Code:
    W5100_IP[0] = 192
    W5100_IP[1] = 168
    W5100_IP[2] = 1
    W5100_IP[3] = 100
    
    W5100_NetMask[0] = 255
    W5100_NetMask[1] = 255
    W5100_NetMask[2] = 255
    W5100_NetMask[3] = 0
    
    W5100_Gateway[0] = 192
    W5100_Gateway[1] = 168
    W5100_Gateway[2] = 1
    W5100_Gateway[3] = 254
    
    GOSUB Init_W5100
    The Init_W5100 subroutine uses the above arrays and sets the parameters of the W5100 accordingly.

    To be continued in the next post....
    Last edited by mackrackit; - 2nd October 2011 at 18:11.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts