Help with Arduini-based setup

Hi all. I used an Arduino for my project. Wanting to use my Arduino further, I designed and had a PCB made with the ATmega, crystal, caps, etc needed to run the Arduino, as well as everything else for my project. It worked 100% in the breadboard, but now that it’s assembled on the PCB I’m having issues.

Basically when the computer is turned on, 12v and 5v goes into the board. The arduino uses the 5v as a sense to know when the computer is on. The 12v then runs into a 5v regulator, and out to a pair of 5v 10F caps in series. The Arduino takes a reading from a temp sensor, and runs a servo accordingly. When the computer is shut off, the 10F caps provide power to set the servo to its closed position (the Arduino does the when the 5v is taken away from the sense pin = computer off).

The problem I’m having is that on first startup when the caps are drained, it doesn’t do anything. You can freely move the servo by hand. Now if I unplug and plug it back in a couple times it’ll work fine. It works as long as there’s a small charge in the caps. If I let them drain completely, it won’t work again. Now this worked 100% in the breadboard setup, but for some reason doesn’t want to work now lol. Any ideas? Am I missing something? I designed the PCB directly from the breadboard setup.

Link to original design thread:

http://www.thebestcasescenario.com/foru … 932&page=3

Link to project this is used in:

http://www.thebestcasescenario.com/foru … post289709

the Eagle layout:

http://i92.photobucket.com/albums/l11/s … _rev_2.png

The boards:

http://i92.photobucket.com/albums/l11/s … uino-1.png

http://i92.photobucket.com/albums/l11/s … uino-2.png

http://i92.photobucket.com/albums/l11/s … uino-3.png

Assembled:

http://i92.photobucket.com/albums/l11/s … uino-4.png

http://i92.photobucket.com/albums/l11/s … uino-5.png

SXRguyinMA,

I didn’t see a schematic and I’m not sufficiently motivated to draw one from your board layout, but if you post one, it might help.

In the meantime, how long have you waited before declaring failure? The [time constant of 5 farads and 15 ohms is 75 seconds.

The initial current is I = (Vsource-Vcap)/R = (5-0) V/15 ohm = 333 mA. I looked, but couldn’t identify your voltage regulator. How happy is it at 333 mA? If you were to overload it substantially, it might well shut down to cool off, then switch itself back on. That would further delay charging.

Here are a few questions/suggestions for investigating this:

  • - If you monitor the voltage at the capacitors during cold startup, what, roughly, is the shape of the voltage vs. time curve?
  • - If you monitor the voltage at the regulator output during cold startup, what, roughly, is the shape of the voltage vs. time curve?
  • - If you monitor the voltage at the servo power pin (both with and without a servo attached) during cold startup, what, roughly, is the shape of the voltage vs. time curve?
  • - If you monitor the voltage at the ATmega power pin (both with and without a servo attached) during cold startup, what, roughly, is the shape of the voltage vs. time curve?
  • - Check to make sure the diode is facing the right way.
  • - Check to make sure the capacitors are facing the right way.
  • - What, if any, components are not exact matches between the breadboard that worked and the PCB that doesn't?
  • - Check your soldering. Look for cold or loose joints, solder bridges, and thermal damage to the board.
  • - Have you changed what is wired to the servo's 5V pin? It appears from a brief look at the two generations of boards that you have.
  • - Without referring to previous schematics, sketches, or notes, draw a schematic of your circuit by analyzing the PCB. Go do something else for, at least, a couple of hours. Then draw (without referring to any documentation or memory) a schematic by analyzing your breadboard. Post both schematics so we can compare them. (Unlike yours, the eyeballs on this forum aren't conditioned to see the circuit a certain way.
  • Out of curiosity, why did you decide to store 5 V, rather than 12 V? That is, why put the capacitance after the regulator rather than before it?

    Happy Hunting,

    Eric ](RC time constant - Wikipedia)

    Well I put the caps after the power as they’re 2.5V 10F caps, so in series I get 5F @ 5v, which is what the arduino and servo need to run. From a cold start it takes approx 4 mins for the caps to fully charge (4.98v according to my meter). When the 5v and 12v is takena way, the caps are used to move the servo, then they just drain out, which takes about 10 mins to fully discharge.

    I’m at work right now, but I’ll get the schematic(s) and cold stat-up voltages for you this evening. Thanks so far for your help!

    Also, nothing is different from the breadboard setup. The components in thes PCB are the exact components I used in the breadboard. I know the 5v reg is [this one from Radio Shack. It does get fairly warm at first (until the caps are charged), which is why I have the heatsink on it. I used it for quite some time in the breadboard without the heatsink with no problems though.

    The diode and capacitors are facing the right way.

    I’ve gone through and triple-checked the sodlering, all is good. I noticed a trace I forgot to put on the board, so I soldered a jumper, but it didn’t change anything. I’ve also tried several different ATMega chips that I have, all with the same results.

    The servo’s 5v pin hasn’t changed at all. It shares the 5v input that goes to the temp sensor. And once it starts working, it works 100%. Another strange thing I found is that when it’s first powered up and not working properly, the reset button seems to have no effect at all. Once it’s working properly, the button works as intended. I’ve left it plugged in for over an hour (in it’s non-working state) with no change.](http://www.radioshack.com/product/index.jsp?productId=2062599)

    here is the schematic: Note the labeled ports on the vreg are wrong on the schematic

    http://i92.photobucket.com/albums/l11/s … ematic.png

    ok so the results:

    #1: Measured + and - of caps in series

    start at 13.9mV

    2V in 39s

    2.5V in 55s

    3.5V in 1:48

    4V in 2:36

    4.5V in 4:05

    4.65V in 5:00

    I could hit the reset button and get it to function @ 1min, so roughly 2.5V

    #2: 140mV at start, went to 4.98V in <1s

    #3: (w/o servo)

    .523V at start

    4.66V <1s

    4.7V 10s

    4.75v 2:15

    #3 (with servo)

    .935V start

    4.9V <1s

    #4 I couldn’t measure because I couldn’t get a good test grip on the ATMega’s 5v pin.

    It would seem from test #1 that the ATMega simply isnt getting enough voltage. But the 5v out from the regulator goes into the caps, the ATMega, and then on to the temp sensor and servo. maybe the traces need to be bigger?

    I think I might have found it. For giggles I decided to see what zener was in there. Turns out is a 12v zener (4742) instead of a 5v zener (4733). Think this might be it? I’ll unsolder the 12v and put in a 5v later on and see if this fixes it

    nope no change at all, still same problem :evil:

    Previously, I suggested that you:

    “Without referring to previous schematics, sketches, or notes, draw a schematic of your circuit by analyzing the PCB. Go do something else for, at least, a couple of hours. Then draw (without referring to any documentation or memory) a schematic by analyzing your breadboard. Post both schematics so we can compare them. (Unlike yours, the eyeballs on this forum aren’t conditioned to see the circuit a certain way.”

    You have posted one schematic, but didn’t identify the source. Furthermore, the schematic presents some difficulty. Not only are the voltage regulator leads confused, it’s not clear whether the zener diode is in parallel with the 15 ohm resistor between the voltage regulator output and the capacitors or whether the zener diode is the only path between the voltage regulator output and the capacitors and the 15 ohm resistor is between the positive side of the capacitors and (JP1-2, JP2-2, and IC2-7). The former appears consistent with the reported behavior, but the latter is consistent with the schematic.

    What is the intended function of the zener diode?

    Which connection do you believe was missing from the board. How did you replace it by wire?

    Eric

    the schematic is from the Eagle layout, and I did mention that they’ve got the pins on the vreg wrong in the schemtic. I layed it out, then looked at the board and nothing was right, so I had to figure out what was what and rewire it that way. “Out” on the schematic is “GND” on the actual part, “GND” on the schematic is actually “IN” and “IN” on the schematic is actually “OUT”. Don’t know why it’s that way but it is.

    I haven’t done a redraw of the schematic from the breadboard because my breadboard is currently in use testing an unrelated project.

    The 15 Ohm resistor and the diode are in series between the vreg output and the positive side of the caps. The purpose of the diode I have no idea. A guy on another forum (the one I linked to with the project) had told me to set it up that way. [Here is the original thread for this setup. You’ll need [this site for the circuit simulator app so make sense of the code. If you go to file->import (in the java applet) it’ll load the code and you can see where this setup originated from.

    The missing connection was one of the VCC pins to the ATMega. The schematic and board view show it there, but the boards didnt come from Batch PCB with them. The board’s trace went into the AREF pin, but not the VCC pin next to it.](Circuit Simulator Applet)](General question about powering an arduino)

    SXRguyinMA:
    the schematic is from the Eagle layout, and I did mention that they’ve

    Who is “they”?

    SXRguyinMA:
    got the pins on the vreg wrong in the schemtic. I layed it out, then looked at the board and nothing was right, so I had to figure out what was what and rewire it that way. “Out” on the schematic is “GND” on the actual part, “GND” on the schematic is actually “IN” and “IN” on the schematic is actually “OUT”. Don’t know why it’s that way but it is.

    Do the part number of the Eagle component and the physical component match (both the silicon and the package)? If not, why would you expect the lead arrangement to match?

    SXRguyinMA:
    I haven’t done a redraw of the schematic from the breadboard because my breadboard is currently in use testing an unrelated project.

    You also, as far as I can tell, have not redrawn the schematic from the assembled PCB. Given the discrepancies among your description of the PCB, the photographs of the PCB, the schematic you posted, and your description of the behavior, I’m not inclined to spend time figuring out why something that isn’t the circuit you’ve assembled would behave the way the circuit you have assembled behaves. If you can reconstruct a working breadboard of this and provide schematics that are drawn from the PCB which doesn’t work and from the breadboard which does, we can try to find the critical difference.

    SXRguyinMA:
    The 15 Ohm resistor and the diode are in series between the vreg output and the positive side of the caps. The purpose of the diode I have no idea. A guy on another forum (the one I linked to with the project) had told me to set it up that way.

    If you are referring to the schematic on [this page, it shows the 100 ohm resistor and zener diode in parallel. It appears that the intention was that the capacitor charge through the resistor (to protect the regulator from trying to provide “near-infinite” current at startup), but discharge through the zener diode (to provide a path from the capacitor to the board that has a fixed voltage drop, rather than relying on a path that has a voltage drop that increases with current). However, the schematic you posted shows the resistor and diode connected to each other at only one end. The lines on the other ends cross, but that crossing is not drawn as being an electrical junction.

    SXRguyinMA:
    The missing connection was one of the VCC pins to the ATMega. The schematic and board view show it there, but the boards didnt come from Batch PCB with them. The board’s trace went into the AREF pin, but not the VCC pin next to it.

    How did you generate the board drawing you sent to BatchPCB? Specifically, did you draw the board manually or have Eagle generate it from the schematic?

    Eric](General question about powering an arduino - Page 4)

    esklar81:
    Who is “they”?

    Whoever designed that part for eagle.

    esklar81:
    Do the part number of the Eagle component and the physical component match (both the silicon and the package)? If not, why would you expect the lead arrangement to match?

    I used a standard 5v regulator from the sparkfun library that they provide, thinking it would be the same as the part that they sell.

    esklar81:
    You also, as far as I can tell, have not redrawn the schematic from the assembled PCB. Given the discrepancies among your description of the PCB, the photographs of the PCB, the schematic you posted, and your description of the behavior, I’m not inclined to spend time figuring out why something that isn’t the circuit you’ve assembled would behave the way the circuit you have assembled behaves. If you can reconstruct a working breadboard of this and provide schematics that are drawn from the PCB which doesn’t work and from the breadboard which does, we can try to find the critical difference.

    The schematic of the assembled PCB is the same as the schematic I posted. The photographs I posted are the same as the schematic, which are the same as the Eagle board layout. I will breadboard this back up tonight and post with the results.

    esklar81:
    If you are referring to the schematic on [this page, it shows the 100 ohm resistor and zener diode in parallel. It appears that the intention was that the capacitor charge through the resistor (to protect the regulator from trying to provide “near-infinite” current at startup), but discharge through the zener diode (to provide a path from the capacitor to the board that has a fixed voltage drop, rather than relying on a path that has a voltage drop that increases with current). However, the schematic you posted shows the resistor and diode connected to each other at only one end. The lines on the other ends cross, but that crossing is not drawn as being an electrical junction.[/quote]
    The schematic I posted shows the resistor and diode in parallel, and the board is the same. I typed that wrong, I apologize. They are in parallel. The output from the regulator goes to one end of the resistor and one end of the diode, and from the other end of the resistor and diode it goes out to the capacitors.

    esklar81:
    How did you generate the board drawing you sent to BatchPCB? Specifically, did you draw the board manually or have Eagle generate it from the schematic?

    I used the autoroute in Eagle, and I triple-checked the routing because I didn't want to waste money on board that were wrong, which is how I found the improper pin arrangement for the 5v regulator.

    I also got the voltage measurement at the ATMega’s VCC pin, and as soon as you plug it in it shoots right to 4.96v. So the IC is getting voltage, the temp sensor is getting voltage, the servo is getting voltage, but nothing happens until the caps charge to 2.5v, at which point it automatically starts working. The caps are just there to provide power when the computer is shut off for the servo to close. The charge state of the caps should be unrelated to the functionality of the system.](General question about powering an arduino - Page 4)

    SXRguyinMA:

    esklar81:
    Do the part number of the Eagle component and the physical component match (both the silicon and the package)? If not, why would you expect the lead arrangement to match?

    I used a standard 5v regulator from the sparkfun library that they provide, thinking it would be the same as the part that they sell.

    According to their datasheets, the [7805 (the regulator you said you used, IIRC) and the [1117 (the low dropout regulator shown on your schematic) have different pin assignments: In-Gnd-Out and Gnd-Out-In, respectively, both in TO-220 packages.

    In your schematic, you show In-Gnd-Out as the labels, but appear to have it wired as if it were Out-In-Gnd.

    Eric](http://www.st.com/stonline/books/pdf/docs/2572.pdf)](http://www.national.com/ds/LM/LM340.pdf)

    esklar81:
    According to their datasheets, the [7805 (the regulator you said you used, IIRC) and the [1117 (the low dropout regulator shown on your schematic) have different pin assignments: In-Gnd-Out and Gnd-Out-In, respectively, both in TO-220 packages.

    In your schematic, you show In-Gnd-Out as the labels, but appear to have it wired as if it were Out-In-Gnd.

    Eric[/quote]

    But the fact remains that it’s hooked up correctly in the PCB. I’ve got 12v going into it’s input pin, ground to its ground pin, and 5v coming out of it’s output pin. I’m working on breadboarding this up now.](http://www.st.com/stonline/books/pdf/docs/2572.pdf)](http://www.national.com/ds/LM/LM340.pdf)

    ok so I breadboarded it up and things changed. It works at the start, meaning it doesn’t take until the caps hit 2.5v for it to work. But on the other hand, when power is removed, the servo doesn’t smoothly move to it’s “off” position. It’s whines and chirps and eventually gets there, but that’s it. I’ll draw up the schematic exactly how I have it in the breadboard and post it.

    ok so I swapped the regulator for the correct one, and this is exactly how its setup on the breadboard

    http://i92.photobucket.com/albums/l11/s … atic_2.png

    SXRguyinMA,

    Two questions, one tactical and one strategic:

    Tactical: Have you watched the voltage on the Arduino’s RESET pin (pin 1) during startup. That pin is pulled up through a 10K resistor and it may be that it’s pulling up very slowly when the capacitors are drawing a large charging current. (If the pull up is slow, I’d try changing the pullup resistor to 1 K. One thing you might do to see if it’s the Arduino or the servo that won’t respond until you’re at about half charge is to put a “heartbeat” LED on a spare DO of the Arduino and have your code flash it ~5-10 Hz. That way, it would be easy to see if the Arduino is alive during the first couple of minutes.

    Strategic: Why use a 12 V line from the PC’s power supply for your power, but a 5 V line to determine when to have the circuit operate? Put another way, under what circumstances is the 12 V live, but the 5 V not, and in which you do not want the louvers to operate? Alternatively, why not just run the whole louver subsystem on the 5 V power from the power supply?

    Eric

    PS: I’ve been trying for several hours to send this, but have been having web problems.

    I have not checked the voltage at the reset pin on startup, but I will check it. The only reason for the 10k was when I originally learned how to integrate the ATMega into a final project, that’s what was showed to me. That, the crystal and the 2 22uF caps. And of course the power LED just to be sure it’s getting power.

    The reason for needing the 5v and 12v is that the 5v goes to the sense pin only, to tell the arduino when the computer is on or off. The 12v line is used to charge that caps and power the system. When I had it powered with the 5v line, it would backfeed from that caps through the 5v and into the input of the Arduino and it wouldn’t close the louvers. So the only way to keep it set up properly was to have the 5v line dedicated to the sense pin. If I were to use the 12v line instead (with voltage dividers) it would backfeed through the ground and do the same thing. The 12v is off when the 5v is (as always with a standard computer power supply) and this is the reason for needing the caps. The caps allow sufficient power for the Arduino to move the servo to close the vents, otherwise when you shut the computer off they wouldn’t close.

    Thanks a ton for your help so far, I really appreciate it. :smiley:

    do you think maybe the 15Ohm is too low? Maybe it’s drawing too much current away from the IC? Maybe if I put in a ~150 or something instead?

    So, which type(s) of regulator are you using on the breadboard and on the PCB?

    Increasing the resistance through which you charge the capacitors would lower the charging current, but at the cost of extending the charging time. As a rule of thumb, a capacitor is “pretty much fully charged” after three times the circuit’s time constant: τ = R * C

    For 15 Ω, 5 F: τ = R * C = 15 Ω * 5 F = 75 seconds

    For 150 Ω, 5 F: τ = R * C = 150 Ω * 5 F = 750 seconds = 12.5 minutes

    So, you’d be looking at most of an hour of running before being able to have the louvers shut at power down.

    Reducing the capacitance would also reduce the charging time, but until you get this working, it will be hard to determine just how much capacitance you really need.

    The increase in startup time is why I’d try reducing the resistance of the pull-up resistor on the RESET pin first. The considerations for choosing the pull-up resistor include protecting the microcontroller pin from current spikes and limiting the current through the reset switch.

    For 10 KΩ, I = V / R = 5 V / 10 000 Ω = 0.0005 A = 0.5 mA

    For 1 KΩ, I = V / R = 5 V / 1000 Ω = 0.005 A = 5 mA

    For 100 Ω, I = V / R = 5 V / 100 Ω = 0.05 A = 50 mA (a bit higher than the pin’s spec, but I doubt if it would be a problem)

    It’s probably worth a try on the breadboard, particularly if the reset pin is being pulled up slowly.

    Another consideration is that, IIRC, the threshold for the RESET pin is very loosely specified (20-90% of Vcc). You may just have a chip at the high end of this range on your board.

    Happy Hunting,

    Eric

    I’ll try it with a 1k and a 100 tonight and let you know what happens, thanks again!

    Will