Deploying on ATMega 328p with Ethernet Shield

Hi guys,

Since some weeks I am very interested in deploying my arduino project on an independent board/chip (so that I can power it up with a battery or sthng and use it without my arduino board), I chose therefore the 328p Atmega. After going through the pain of building its circuit and programming it with the Arduino and deploying a test blink program everything worked so far.
Now I am trying to connect an ethernet shield (Sparkfun PoE ethernet shield SparkFun PoEthernet Shield - DEV-10864 - SparkFun Electronics ) to the Atmega to connect it to the internet. The software and connections already worked on the Arduino board, but when I replicate it on the Atmega its not working and having very weird behaviour.

I connect the ATmega with the Shiled as follows :
Ethernet Shield Atmega 328
MISO 18 (Miso)
MOSI 17 (MOSI)
SCK 19 (SCK)
CS 16 (SS)
RESET 1 (RESET)

This configuration works sometime, and sometime not. The Program on the ATMega executes normally, (I set some LED sequence as physical prove) as for the Ethernet a continous ping shows it doesnt start or work properly. After random resets, restarts it works out of no reason. Later when I turn on the circuit again it doesnt work.

I am unfortunately no electronic expert and without the bildr, instructables and the nice people on this forum I would have never reached that far, but I have reason to believe its an electronic connection/resistors misplaced problem because it works sometimes and then as soon as I reset the circuit it doesnt work anymore. I think It has to do with the pullup/pulldown resitors on the Reset pins ? Do I need resisitors on the SPI pins ?
Is an SPI header here needed ? I am only connecting 1 SPI device therefore I connect the SPI pins directly. Could the Power supply of the circuit have to do anything with this ?

help in understanding this circuit would be really appreciated.
thanks have a nice day

You don't have to use pull-up or pull-down resistors for the SPI bus.

Does your reset have a pull-up of 10k or 4k7 ?

The W5100 ethernet chip requires a lot of current, how is your power supply ?

Could you upload a schematic and a photo of your standalone ATmega328p ?

1- No pull up on RESET , which reset from the Ethernet shield or the Atmega ? , what is a 4k 7 ?

Atmega circuit

nothing special, 22pf & a 20 Mhz clock on pins X1,X2 a 5V regulator connecting to VCC.
I think you are right powersupply has to do with it because I started with power supply from the Arduino board directly (connected to my pc via usb) , i used once 4x AA 1.5 V batteries (6v into the Regulator, and I tried the shield with output from the Regulator once and also directly the 6v) it didnt work, switching back to the Arduno 5v & GND Supply did not make it work instantly but it did sometimes as i said before, with the 4 AA it never worked.

I should conneck a 10k to the reset then to the 5v ? But other programs on the Atmega without Ethernet shield worked perfectly ?

The Ethernet Shield uses a lot of current, so your power circuit should be good to have the Ethernet Shield working.

Do you have Aref connected ? Please leave it open.
Vcc and AVcc to 5V.

Is that a normal 7805 voltage regulator ?
It needs 100nF on the input to ground and 100nF on the output to ground.
Without those 100nF, you are in luck if it is working at all. I hope the 100nF capacitors are on the back side. If not, you should add those 100nF before trying anything else.

The 7805 need an input voltage that is 2V higher than the output. So you need 7V at least. You can't use your 6V batteries with the Ethernet Shield.

I assumed that the reset of the ATmega and the Ethernet Shield are connected...
I don't know if the Ethernet Shield has a pullup resistor on the reset. Try adding a resistor of 10k (or 4k7) to the 5V.

"4k7" is a short notation for a resistor of 4.7 k ohm (that is 4700 ohm).
More examples:
"3V3" = 3.3 Volt
"1M8" = 1.8 Mega ohm
"1n5" = 1.5 nano Fahrad
and so on

Well first thanks a lot for taking the time to solve my problem and also explaining all the short meanings.
Yes its a 7805 5v Reg and No unfortunately the Regulator has no capacitors connected on it and I use the 4 AA batteries directly to it, thanks a lot for the info I will try the capacitors and choose a different power source that supplies at least 7v. I am really ignorant about circuit design I am a programmer but have a keen interest in getting my code to the physical graph but to come up on my own on what resistor or capacitor to add next to a regulator is near impossible (Do you happen to know good books/tutorials :slight_smile: ?).
Aref is not connected, and what do you mean by the 'rest' is connected ? as you can see on the picture I installed a pin header on the 4 SPI pins and the shield is connected to the Atmega through only those 4. Other connections are just Vcc and GND.

Ok following up the Power supply did not solve the problem. I added 2x 100uF Capacitors (the ones that were lying at home) between the In - GND and Out - GND of the Regulator. Took the Out of the Regulator to the Shield, RESET pins connected (the shield has a pulldown resistor), and wired in the input a 9v.
Same behaviour, circuit runs up, led sequence lights perfectly but shield is not communicating.
Noticable behaviour running this configuration for 5 min drew incredible current from the battery output went down to 7.5v in less than 5 min.
In an fatigued frustrated experiment connected weak 4 AAs directly, producing together around 5.3v to the Vcc and the 5v Pin of the Shield. Same behaviour and in 1 min the total output of the 4 AAs went down to 4.5 v.
Moreover the Regulator turned out not to be a 7805 rather a L4950v5 L4940V5 pdf, L4940V5 Description, L4940V5 Datasheet, L4940V5 view ::: ALLDATASHEET :::

Any new ideas ?

Your batteries are too weak for the Ethernet Shield.
I'm not sure if your voltage regulator is a L4950V5 or a L4940V5, it could be a voltage regulator could be for 8.5V
You say the ethernet shield has a pull-down at the reset line, is that really a pulldown to ground ?
I'm not sure how everything is connected at the moment.

To get a result, you have to make a good plan.
Forget about the batteries.
Check everything careful.

For example, start with the reset circuit.
Take a look at the schematic of the Uno, http://arduino.cc/en/Main/arduinoBoardUno
It has a pull-up of 10k and a diode (and a capacitor to DTR).

You need a good 5V.
Do you have a multimeter ?
Use the 5V for the ATmega328P and the ethernet shield.
If you connect the ethernet shield, the 5V should still be 5V.

You need 100nF capacitors.
The 7805 requires those, or it won't work.
The L4940V5 is a little different, see the datasheet.

The ATmega328P requires them too, at the GND and +5V near the chip.
Without them, you can expect everything, but not a good working ATmega328P.
They are called decoupling capacitors and prevent drops and spikes
Perhaps you have some old circuit boards, you might find some 100nF capacitors on it.

-The regulator is L4940V5, was a typo from me
-The Shield has a 1k resistor connected between Reset and 3.3v (i guess thats called a pullup)

-You were right i used a multimeter around the Atmega Vcc and GND is a solid 5v and around the same pins of the shield its 4.87 - 4.86 and drops 0.01v every 20sec!. The thing that drives me crazy is that the shield has status LED (PWR, SPD and TX) that always run, (PWR = stable Blue) and TX blinking now and then which gave me the impression it has enough power.
-I noticed the Ethernet schematic is all 3.3v, I thought I should regulate the 3.3v externally and provide the shield with only 3.3v ? (but then Ill need a 3.3v/5v bridge on the SPI lines for the shield and the Atmega to communicate correctly right ?)
-I will buy the 100 nf capacitors, the common 7805 regulator and study the Reset circuit and try again. Just a question to that , what do you mean by 'The ATmega328P requires them too, at the GND and +5V near the chip', the Vcc and Avcc need to be wired through a 100 nf capacitor to the GND ? I have never seen any circuit online that connects the Atmega like that ?

Thanks a lot for your help I will educate myself a little about decoupling capacitors and give it another shot, Ill post through my arduino if it succeeds :wink:

You can use the L4940V5.
According to the datasheet it needs 100nF at the input and at least 22uF at the output.

The reset of the W5100 on the shield is a different reset than the ATmega328P reset.
You should use 10k from reset to 5V at the ATmega328P.

A voltage of about 4.87 V on the shield seems okay to me.

The Ethernet Shield makes its own 3.3V.
The 74HC050 on the shield converts the Arduino 5V signals to 3.3V.
So normally the Ethernet Shield uses 5V and creates the 3.3V itself. I would try to make it work with 5V before changing anything.

Take a look at the schematic of the Arduino Uno.

Capacitor C1, C2, C6, C7 are decoupling capacitors of 100nF.
Capacitor C4 is 100nF at Aref. That is to reduce noise of the (internal) voltage reference, to improve reading an analog input.

The Vcc and Avcc should be tied to 5V.
And a 100nF should be connected between the Vcc/Avcc and GND.

The Avcc is the 'Vcc' for the analog section of the ATmega328P. Sometimes an inductor is used to filter the noise of the 5V. But many times it is simply connected to the 5V.