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


Closed Thread
Results 1 to 40 of 63

Hybrid View

  1. #1
    Join Date
    Sep 2012
    Posts
    5

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

    - About dynamic variaables:
    What i did is not effective, but works. I converted the variables to strings and then i just added to the rest string, meaning the Str Buffer.
    Fore example:
    StrN Buffer = Str$(Dec variable_to_publish)
    GoSub PutStringInTXBuffer

    - About multisocket:
    I am also searching this. The issue here is that i need to also pass dynamic variables as well. So, this means i must control all sockets simultanously (and my microchip chip also does other task too). Anyway, i will make some test on this and tell you the results.

    - Publish your (modified for Proton+ compiler) code:
    Of course i will do that (inform you). By the way, i intent, for start, only to publish a simple code that makes a web page with dynamic variables only (without DHCP). And i found out that these two compilers have very little differences.


    - I would like to ask a little help for a snippet. Why you are doing this in DHCP code, because i couldn't convert it with easy way?

    ' Get second Bit in DHCP_LeaseTime And copy it To first Bit of Buffer And so On.

    For DHCP_i = 0 To 30
    Buffer.0[DHCP_i] = DHCP_LeaseTime.0[DHCP_i + 1]
    Next

    Thank you in advance.


    Vangelis

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,627

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

    Hi,
    Thanks! Actually I was more aiming at what format you used to "place" a variable in the actual HTML and how you detect that when the program parses the HTML page to replace the "dynamic variable identifier" with the actual variable value. Does that make sense?

    Anyway, regarding the DHCP code:
    The lease time received from the DHCP server is a 32bit variable stored in the DHCP_LeaseTime array (4 bytes). The IP-adress lease must to be renewed before the lease time expires. What I do is simply divide the actual lease time in half, when that time (half of the actual lease time) expires the code triggers a renew of the lease.

    The code snippet you ask about performs that divide by 2 operation by shifting the value one step to the right. It uses the Buffer array as a temporary storage for moving Bit1 in LeaseTime to Bit0 in Buffer and so on. Finally it copies the shifted result back to DHCP_LeaseTime.

    The reason for doing it this way is that I wanted to avoid using LONGs (32bit variables) in PBP because it adds quite a bit of overhead. Using a LONG for the lease time and doing LeaseTime=LeaseTime/2 or LeaseTime=LeaseTime >> 1 would result in the same thing.

    Looking at the code now I could probably do something like this instead of using Buffer as a temporary storage
    Code:
    For DHCP_i = 0 To 30
      DHCP_LeaseTime.0[DHCP_i] = DHCP_LeaseTime.0[DHCP_i + 1]
    Next
    DHCP_LeaseTime.0[31] = 0
    Anyway, I hope that explains the what and why.

    /Henrik.

  3. #3
    Join Date
    Sep 2012
    Posts
    5

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

    I think that i understood it (the issue about dividing the time by 2).

    What i will do is that i will simply rotate each byte by 2 to the right individually. So it will be divided by two. The DHCP_LeaseTime[3] by 2, then the DHCP_LeaseTime[2] by 2, ........ lastly the DHCP_LeaseTime[0].
    I think it will have the same result.


    For the dynamic variables:
    I am not sure that i understood correctly what you are saying, but what i exactly do is placing the following html command. With this, the web page gets refreshed each 5 seconds.

    Str Buffer="<meta http-equiv=\"refresh\" content=\"5\">",13,10,0 'refresh every 5 seconds
    GoSub PutStringInTXBuffer


    You could select other time too, if you wish.
    So, the client (the person who sees your web page) will load again all the web page with the new variables (every 5 seconds). This is not quite effective since, sometimes, it makes a flashing on the page. But the data get refreshed correctly.
    There is also an other (more effective) way to do that (in order to avoid the flashing), with xml requests, but i am yet enough familiar with it.
    Last edited by VaGyver; - 7th September 2012 at 09:12.

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,627

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

    Hi,
    I'm afraid it's not quite that simple. Here's an example...

    24h = 86400 seconds

    Code:
    86400 in binary:
    00000000 00000001 01010001 10000000
    If you actually rotate each byte (ie the LSB gets moved to MSB) individually the result becomes:
    Code:
    00000000 10000000 10101000 01000000
    Which in decimal is: 8431680 seconds or 2352h
    If you instead of rotate simply shift each byte individually (or divide each byte by 2 individually) the result becomes:
    Code:
    00000000 00000000 00101000 01000000
    Which in decimal would be 10304 seconds or 2.9h
    As you can see neither of the above results is the expected 43200 seconds or 12h.

    You need to make sure that the LSB of each significant byte get moved into the MSB of the less significant byte so that result with the above numbers becomes:
    Code:
    00000000 00000000 10101000 11000000
    Which in decimal is: 43200 seconds or 12h
    /Henrik.

  5. #5
    Join Date
    Sep 2012
    Posts
    5

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

    Well, i solved this problem (i created a large variable and shift it -all together- one position to the right).
    I also verified it. It works.

    Now i am doing some testing with the W5100 as client to be connected to servers.

    I'll be in touch!

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