Pages: 1 2 [3]   Go Down
Author Topic: Ethernet Dhcp  (Read 2169 times)
0 Members and 1 Guest are viewing this topic.
Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 150
Posts: 6130
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The w5100 has a tcp/udp stack built-in, but does not have the sensor to detect the the physical state of the device. If the physical device becomes disconnected, the w5100 does not have a way to detect if the cable is disconnected.

You can file a complaint with Wiznet, but I almost guarantee they will say "get a W5200".

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

a lot of reactions thnx:)

i got a standaard ethernet shield with the W5100.
So i need an other shield with the W5200 to detect the cable?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It also depends on setting the proper MAC address, but I assume it is properly configured.
This the code i use for my mac:

Code:
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
Ethernet.begin(mac)

I don't know how else i can doe this. it is like in the example code

i use the Ethernet.maintain(); in the begin of my void loop()
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 150
Posts: 6130
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ethernet.maintain() does nothing but return until the lease is half expired. If the dhcp lease was 2 days, then for the first 24 hours, Ethernet.maintain() returns "no action taken".
Logged

Rome, Italy
Offline Offline
Sr. Member
****
Karma: 20
Posts: 442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It also depends on setting the proper MAC address, but I assume it is properly configured.
This the code i use for my mac:

Code:
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
Ethernet.begin(mac)

I don't know how else i can doe this. it is like in the example code

Not exactly the best choice, but it may work. The mac address is a unique identifier for network devices, and by using the example configuration you can be sure that many other devices will use it. However, most other devices in your network will use their true, unique mac address, so you can get along with it... until some of your colleagues connect their Arduinos using the sample configuration.

Look if you can find the mac address printed somewhere on the shield or the box. At the moment, however, this doesn't seem to be a problem.

i use the Ethernet.maintain(); in the begin of my void loop()

Not a perfect solution (but it seems there are none, apart from resetting the Arduino), but that would reduce the risk of reusing an invalid address. Just remember to check whether the function really returns 0 and use Ethernet.localIP() if it doesn't.
Logged

Rome, Italy
Offline Offline
Sr. Member
****
Karma: 20
Posts: 442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

a lot of reactions thnx:)

i got a standaard ethernet shield with the W5100.
So i need an other shield with the W5200 to detect the cable?

The main difference is that the W5200 has a status register that keeps track of the link state (whether the cable is attached or not). But this also requires a different version of the Ethernet library, specific for the W5200. I don't know the status of this library, whether it's complete and provides the required functionality (you can always inspect the status register within your code, but a library should give you something more, such as interrupts when the link is down).
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I will change that when i know how to get always a good ip and detecting when my cable is connected:)

Do you know how i can change the lease time in my arduino.
On my desktop is is 4h, on my labtop is 1h (cmd -> ipconfig/all)
with arduino it is about half houre. (waited that long)

And it is not possible with de ethernetshield based on th W5100 to detect if there is a physical connection?
i think there is becaus when i connect my cable LED's start to work. and those led are connected to the W5100 if you look at the schematic of the ethernet shield.
sow i think it is possible but i don't know how. does someone know this?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

second question.
when you use Ethernet.maintain();
what is de the diffrents betweem renew and rebind?
The time they check is that the same and how can i change this?
Logged

Rome, Italy
Offline Offline
Sr. Member
****
Karma: 20
Posts: 442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And it is not possible with de ethernetshield based on th W5100 to detect if there is a physical connection?
i think there is becaus when i connect my cable LED's start to work. and those led are connected to the W5100 if you look at the schematic of the ethernet shield.
sow i think it is possible but i don't know how. does someone know this?

You may attach something to pin 66 of the chip to see if it's down, or a light sensor to the LED. It seems is an output-only pin, not something you can inspect through a register. There may be some hidden API, but if there is one, it's well hidden.

Renew, rebind... Not sure about this, but I think not all calls to maintain() are actually sent to the DHCP server. Some (most) are resolved 'internally' by checking a timeout. So, if you just got your lease the next time you call maintain() it will simply return with a Nothing happened code.
Renew means you asked the DHCP server to keep your leased address, and the request was granted. Rebind means that your DHCP server did not accept your request OR did not respond, you went on asking for a while, addressing your requests to the same DHCP server, and finally broadcasted your request to whomever could give you an answer (possibly a different DHCP server).
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You may attach something to pin 66 of the chip to see if it's down, or a light sensor to the LED. It seems is an output-only pin, not something you can inspect through a register. There may be some hidden API, but if there is one, it's well hidden.

I see it is an output pun of the w5100. that i the reason i think he can detect the connection because he needs to turn on the leds when my cable is connected. How does he know when he must turn on this led? and how can i found out with the arduino?

I also tried to send a mail to arduino support but can't find the mail adres. :s
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I contacted the arduino support. I hope they can give me some tips.
when i use dhcp (ethernet.begin(mac)smiley-wink and i have no cable connection, it takes a while before he notice that there is no connection to the router/server. how can i reduce that time? then i can ask a dhcp in beginning of my loop. it is a solution, if it good i don't know:)
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 150
Posts: 6130
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
...and i have no cable connection, it takes a while before he notice that there is no connection to the router/server. how can i reduce that time?
Plug the cable in
or
use a static ip
or
modify the ethernet dhcp library
or
get a W5200 shield
otherwise
it takes a couple minutes to determine there is no dhcp server available.
Logged

Pages: 1 2 [3]   Go Up
Jump to: