Problems with standalone 328 (Voltage maybe?)

I've been fooling with this all day:

I've since added a cap to the supply side of the VR on the top board. The top board is outlined in this thread:

http://arduino.cc/forum/index.php/topic,114057.0.html

The bottom board is just more breakout for the top board plus power input, a switch, power led and power for the servos.

It's supposed to be a board to run my little robot. I'm only using 5 I/O pins to run it. Everything worked fine on the breadboard and I've pretty much duplicated what was done earlier including pins used and power routing, power supply etc.

I'm using an 8XAA battery holder which is wired to the 2 7805 voltage regulators. One VR powers the servos and the other powers the top board with the chip. 7805 #1 just feeds the pos and ground for the servos plus a power led and 7805 #2 runs a 328P plus another led that indicates power to the IC.

When I loaded my sketch. (It worked fine on the breadboard) I just got some twitching and such. I then re grouped and tested all the pins using a modified blink sketch. All was well and I even hooked leds up to all the outputs and ran a little sequential blink deal which seemed to work well. So I don't think it's a problem with the pin wiring.

The strange thing is that it seems to run the blink stuff fine with 5V from the Arduino board powering the standalone deal but once I switch to the battery pack things get wonky. The next step is to see if I can power the servos with 5V that is separate from the line powering the chip. I did notice that I'm only getting about 3V at the chip so I'm wondering if the 2 7805s are dragging something down.

I even tried loading a simple sketch that would rotate one of the servos and tried it on several pins but still just got some slow stepper like motion from the motors.

Since all the pins check out by blinking I'm hopeful that my wiring isn't screwy and it's just a power issue.

I'm going to sit down and try to draw a schematic that may help some.

Any input would be great! I feel like I'm pretty close.

Funny, I REALLY need some female/female and male/female jumpers. I ordered some male/male jumpers last week and was thinking "WTF would I need any of those other kind for?" :cold_sweat:

Another thing I noticed: When I have it hooked up to a 12V power supply everything blinks as it should but when I try to run it from the 8XAA holder (It checks 12.5V) I just get one led fluttering.

How hot is your regulators? If they are too hot(probably from wasting so much power dropping from 12.5 to 5v) they automatically shut down and could cause things to go weird
Yout better off with a 4-5 battery holder with an ldo regulator, or a switching regulator and your current battery setup

You need a 0.1uF cap on both the input and output of the regulator. You also need one on the power input of the processor chip as well as one on the Aref input.
Finally you need a 10K pull up to +5V on the reset pin.

Thanks!

I'll have to check into those things. It's back to the grind for a few days so I don't want to get too deep this evening :stuck_out_tongue: The regulators aren't getting warm at all. And the one on the little Arduino board has been modified. I cut the heat sink lug off of it. I do strange things some times...

I'll look into the Ido regulator or a switching regulator. Not really sure what they are but it seems like something I should know about.

I have a 10 uF cap pretty close to the input of the chip and I tried another 10 uF on some different places without success. I'll try the 0.1 caps though.

I wasn't sure about the pullup resistor on the reset pin. Some said yea, some said nay so I left it out but I'll stick one on there. It seemed to program OK so I didn't worry about it.

I did break the Aref out but it's just floating right now. So, hook a cap up to it and ground?

Thanks for the input! I was REALLY glad all the pins seemed to work after it was soldered together!

UPDATE:

I noticed that the VR powering the chip (The one I cut the lug off of :fearful:) only puts out about 2.8-3V and the one that will power the servos puts out a solid 5V. Sooo, I pulled power from the servo VR and ran it to the power pins of the chip and it seems to be working off the battery now. Bad regulator maybe? Maybe I damaged it? I'm going to replace it as well as add the other components. Caps sure can't hurt especially when I throw those little motors in the mix. It's gonna be a bugger because I didn't really put it together with changes in mind so I may start over...

Sad Robot:

:stuck_out_tongue:

Sounds like cheap battery holder syndrome (or cheap battery syndrome). Cheap battery holders are riveted together and electrochemical corrosion can easily increase the resistance between rivets and springs until one stops working properly at higher current levels. Servo will be demanding high currents.

And yes add 0.1uF ceramic decoupling caps for both Vdd and AVdd - these are not optional components and they must be close to the chip. I personally would have used an IC socket. (If you can't get a narrow DIL28 socket, use two DIL14's end-to-end)

I thought the 10 uF cap was supposed to handle decoupling. I'm just trying to understand.

I branched off power and ran one leg to VCC and the other to AVCC and put the cap between the voltage "branch" and the ground "branch".

On future projects I plan on using sockets. I broke one of the legs on this chip and this is a salvage operation :stuck_out_tongue: Funny thing is I'm not even using that pin...

I thought the 10 uF cap was supposed to handle decoupling. I'm just trying to understand.

No you need a ceramic cap as well to handle the high frequency noise.

The real problem is the size of the capacitor and its distance from the chip - the stray inductance limits the ability of the capacitor to decouple at high frequencies (logic switching is in the 100MHz kind of range). Axial lead electrolytics are around 100nH stray inductance, small surface mount capacitors 5nH or so. At 100MHz that's 60 ohms and 3 ohms respectively.

The stray inductance must be small enough, the capacitance large enough and the ESR small enough - all 3 matter.

So for instance lets imagine a processor that switches up to 100mA at 100MHz speeds, and we want the supplies to remain within 0.5V of their average values during the switching. The decoupling impedance should be less than 0.5V/0.1A, less than 5 ohms. If the capacitor has 2 ohms ESR then the total reactance should be less than 4.6 ohms (pythagorus: impedance^2 = resistance^2+reactance^2).

0.1uF has a reactance of -0.016 ohms at 100MHz, plenty low enough - thus we just need the stray inductance to be less than 4.6 ohms, ie L < 7nH. Thus a small capacitor close to the supply pins is going to be more effective than any capacitor that's physically large (inductance too high).

At lower speeds decoupling is also required since the regulator chip cannot react fast enough, so we actually want the decoupling to span the range of about 1..100MHz (hence the cap is 0.1uF rather than 1nF). Indeed the regulator is probably slower than that, a 10uF electrolytic fills the gap and allows for a poor performance regulator and other lower speed devices. At these lower speeds stray inductance is not an issue.

The goal of good decoupling is to keep the impedance of the supply rails (as seen by the logic chips) to be low (a few ohms or less for a microcontroller) from DC through to the highest switching speed. Then the noise on the supply rails will not be large enough to cause logic malfunction.

I would also add a 1000 uF cap right where the battery/PSU connects to the board. Batteries are a constantly changing impedance/resistance as they become discharged, 100 to 220 uF caps will give you 20 - 30% more battery "life" before they need to be changed out.

Doc

Thanks for all the help! This goes a long way towards my understanding of the how/whys. The reason for different value caps (And the need for caps) now makes a LOT more sense.

I'm probably going to just start over with the additions mentioned.

@ Docedison: I don't really understand this: " Batteries are a constantly changing impedance/resistance as they become discharged, 100 to 220 uF caps will give you 20 - 30% more battery "life" before they need to be changed out." do the 100 to 220 uF caps go in the same place as the 1000 uF cap recmmended?

Also, does it make sense to run 2 voltage regulators? One for the IC and one for the motors? I figured it would be better to keep them isolated but they really aren't, are they? When I breadboarded the project I was using an UNO with the motors on a VR and the VR got pretty warm.

I think it helps separate it to a degree, better than none
A bigger cap on the servo 5v line will help keep the other clean too

I recommended a 100 to 220uF cap because I saw none on your Perf board layout. If you use a 1000uF cap that's great... use 2 one on the main board and one on the servo's. Remember to power the servo's separately IF at all possible. Batteries Make power by a chemical reaction in the battery (Primary cells) as this reaction proceeds the chemicals responsible for the power become depleted (discharged) and as this happens the internal resistance goes up... The electrolytic capacitors offset this change by 'storing' a little energy for the surges placed on the battery by the load, thus extending the life of the battery. If you have space and time put a 100uF cap on the proc 5V source... Just for insurance. Caps are Magic Bullets for a lot of Strange and otherwise Un-explainable behavior on the part of the Proc... Cheap insurance that is totally transparent to you in all except physical (you can see them) but never cause any weird behavior otherwise... They waste no power, use no power and insure that whatever power you are supplying is clean. IMO

Doc

Lol I liked the way you explained that, almost made them sound magical
Agree 100%

Amazing what those parts do for "Crosstalk"... , it's like magic when after installing a few on a Quirky board and having the board work... The main reason I call them magic bullets, I've made the same mistake many times and breadboards are the worst places to develop hardware... Many times I had issues on the PCB's I made from breadboards because I was "Tuning" the breadboard rather than the design. I do know I talk perhaps too much about "Proper" by-passing but the talk is based on experience rather than the textbooks I have read.

Doc