Go Down

Topic: Help with Power Supply problem (Read 936 times) previous topic - next topic

Hey,

I've built a stand alone board around a pre-programmed Atmega328 (Uno) chip.  My oscilloscope shows that my power supply runs clean (i.e. no noise/AC/etc.) until I plug in the Atmega328.  As soon as I plug in the Atmega328 (powered off first, of course) I see somewhere between 10 and 15mv AC on my power bus.  The Atmega does work (i.e. runs the 'Blink' demo fine), but when I plug in a DS1307 Real Time Clock chip the DS1307 just sits there.  Power is good (albiet noisy) at the clock chip power pins, but the sketch I'm using to read the RTC just returns all zeros.

I've tried replacing the DS1307 chip (a couple of times) to no avail.  I'm left suspecting that the AC component on my power bus might be the culprit, but I'm at a loss to explain where that AC component might be coming from.  I've reduced my Atmega328 connections to nothing more than +5v (VCC + AVCC), GND, XTAL1 & XTAL2 (at 16Mhz, with 18pF filter caps), PB5/D13 to run the Blink demo and PC4 (SDA) and PC5 (SCL) (i.e. the two I2C pins) to talk to the DS1307.

I have confirmed from the DS1307 data sheet that the I2C address is indeed 0x68.  One question I do have is whether I need external pull up resistors on SDA/SCL.  The data sheet says yes, but I guess I assumed that the Atmega328 would provide those.  Is this an invalid assumption?

Any help would be greatly appreciated.

TIA
-Mitch


DVDdoug

15mV of ripple shouldn't be a problem for a digital circuit.    There''s plenty of safety-margin between what's considered a logic '1' and a logic '0', and things have to get fairly noisy before there's a problem. 

I've never used a real time clock chip, so I can't help with that...


Quote
...but I'm at a loss to explain where that AC component might be coming from.
If it's 50/60Hz, from the AC power into your power supply? ;)  If it's higher frequency noise, it can come from the processor clock, or from other processor/digital switching.

Power supplies have capacitors to smooth the rectified DC.   With little or no load, the capacitors stay fully-charged and there is no ripple.   When there is a load, the power is supplied by the capacitors during the low-voltage parts of the AC cycle.  With more load (more current), the capacitors discharge faster and you get more ripple.

A regulated power supply uses electronics to hold the voltage more-constant, and with a good regulated supply, you may not be able to measure the AC ripple or you may not be able to distinguish the line-ripple from other noise on the DC power line.

Duckie58

Hi Mitch,
The purity of your power supply would be one of the later things I would look at.

Hardware (wiring) issues or software issues could cause your issue.  Please post your code and we can see what might be going on.
The pullup resistors are needed.  Check the wiring of analog pins 4 and 5  -->  SDA and SCL (respectively)

You mention that the RTC reads all 0's - when the RTC first powers up, it is in a hold state, and it will read all 0's.  You need some code to a) set the time, and b) to start the clock.  Once set and running, the starting code does not need to be rerun.  Check out the playground for the 1307 library and page - and also the Adafruit.com tutorials on the RTC. 

Duckie

dc42

What frequency is the AC component: 100/120Hz, or high frequency? Do you have a ceramic decoupling capacitor connected between the atmega328 Vcc and Gnd pins?

The Wire code does appear to activate the internal pullups on the two pins, however they are quite high value and you might need to use external, lower value pullup resistors.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

winner10920

Try looking for the start code, I had made the same mistake on another rtc chip, I thought it wasn't working, but after thorough inspection of the datasheet I realized in the second registor was an oscillator start stop bit which solvwd my problem
maybe its that simple

Jack Christensen

Hey! Another Christensen! Spelled correctly, too XD

Be sure to have a 100nF bypass capacitor on every chip, and a 10uF electrolytic or two somewhere on the power rail never hurts, either. What's the power supply? If the capacitors don't fix it, or if the circuit already has them, I'd try a different supply.

I'm unclear on the TWI pullups, the ATmega328 datasheet (quote below) seems to indicate external pullups, so I always use them. Maybe the internal pullups aren't enough, people seem to use 2.2K or 4.7K a lot. I've used 10K without a problem as well.

Quote
22.2 2-wire Serial Interface Bus Definition
The 2-wire Serial Interface (TWI) is ideally suited for typical microcontroller applications. The
TWI protocol allows the systems designer to interconnect up to 128 different devices using only
two bi-directional bus lines, one for clock (SCL) and one for data (SDA). The only external hardware
needed to implement the bus is a single pull-up resistor for each of the TWI bus lines. All
devices connected to the bus have individual addresses, and mechanisms for resolving bus
contention are inherent in the TWI protocol.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

winner10920

How long are the wires to the rtc? Is there any nearby sources of electrical noise that the wires. Can pick up?

Wow...thanks everyone for the responses.  My problem is solved!

The root cause turned out to be...software. :)

Once I uncommented the line of code that sets the date & time and starts the RTC keeping time the clock started working fine.  I had commented this line of code out so long ago I had forgotten all about it (thanks Duckie and Winner10920).

Thanks so much for everyone's responses.

Here are some follow-up comments and questions in response to some of the other posts (OPTIONAL READING)...

The frequency of the 'ripple current' was much higher than 60hz, somewhere in the range of 180khz (if memory serves).  I am using a regulated +5v supply based on a combination of a TL783 and an LM7805 (my own design).

I will add 2.2k pull up resistors to the SDA/SCL lines (to be safe).

While I do have the recommended filter caps around the voltage regulators, I don't have a 'ceramic decoupling capacitor' between VCC & GND on the Atmega.  What purpose does this serve, and do you have a recommended value?

The power supply is my own design (which explains why I initially suspected that :) ).  I am rectifying an incoming 24vac, and then stepping the resulting 34v down to +5v DC using a sequence of voltage regulators (+34v -> +9v -> +5v).  This weekend I plan on converting to a BUCK (step down) regulator circuit that should take me straight from 34v down to +5v.  I'm making this change because the TL783 regulator I'm using to drop the 34v DC down to +9v is only ~80% efficient and runs so hot that the largest heat sink I could fit in my project gets too hot to touch in about 15 minutes (with only 50-70ma consumed by my circuit).

Thanks again everyone for your help.

-Mitch


dc42


While I do have the recommended filter caps around the voltage regulators, I don't have a 'ceramic decoupling capacitor' between VCC & GND on the Atmega.  What purpose does this serve, and do you have a recommended value?


It serves to prevent the high frequency switching currents generated by the Atmega from generating noise on the Vcc line, which could affect the operation of the Atmega itself any anything else running from +5v. A typical value is 0.1uF.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

winner10920

For the relative ease of use its always worth it to toss it in there,
I usually solder it to the bottom of the board right at to vcc,gnd pins,
doesn't take much space, you'll forget its even there

Go Up