Commit to Copper

Go To Last Post
24 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have just finished my first circuit board design and want to confirm a couple of things so I can avoid designing myself into a corner.

Question 1:
Regarding the Schottky diodes. My intent is to run with +5 and switch to battery when +5 is lost. Are the diodes wired correctly and what value diode should I use. I know that this is a very basic question but I could not find an example anywhere online.

Question 2:
When +5 is lost, pin D2 will go high and I will put the the MEGA16 to sleep. I plan to use the Watchdog timer to monitor pin D2 and when it is pulled low by +5, wake the MEGA16 up. I have never worked withe the watchdog before and only have a rudimentary understanding of it. So I want to confirm that what I want to do can be done. Am I on the right track?

Thanks

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It might be that there are other comments on this, but I think I see one thing. A current limiting resistor between the 2N3904 and GND seems to be required so that you wont pull to much current from PORTD.2 when the transistor is sinking that pin.

I spotted this after redrawing what you had. I'm not any master when it comes to either analogue electronics or drawing circuit diagrams, but I have had good help by these guidelines that I learned partially here at 'freaks

- Draw supply rails as horizontal lines at the top and bottom of the diagram
- Strive after having as few lines cross as possible
- Try to make signal flows go from left to right when possible

I got quite interested in your circuit, and sure am curious about what the seasoned analogue guys here will saay about it. To understand it I did redraw it using these giudelines, and came up with the image below. I hope I got it right (did I rotate the battery 180 degrees?), and that it might help others diving into this thread.

Attachment(s): 

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh, yes. I got the battery backwards. Here's how it looks now, and with that current limiting resistor in place.

Attachment(s): 

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
A current limiting resistor between the 2N3904 and GND seems to be required so that you wont pull to much current from PORTD.2 when the transistor is sinking that pin.

I had anticipated using an internal pullup resister on PORT D2, is that a problem?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In fact, I had anticipated using internal pullup resistors everywhere in my circuit. Are there advantages to using external vs internal pullups? How do most of you do it?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I had anticipated using an internal pullup resister on PORT D2, is that a problem?


A pull-up is effectively a resistor between the pin and VCC. This will not stop the risk of a too large current from the pin to GND when the transistor is sinking the pin. New picture with your pull-up in dotted lines below. Notice how this does not limit the current coming from PD.2 and going through the transistor to ground.

(I'm still not sure if this is a problem. I'm a software guy primarily. Hoping that some analogue guy will come by here to concur or declare my thought rubbish..)

Attachment(s): 

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lack of a current limit resistor should NOT be a problem if that pin can NEVER be an output AND logic-high. To be safe, I would add a resistor, say 470 ohms between the port pin and the transistor. When it is configured as an input and the internal pull-up is on, the transistor will pull the port pin to logic-low.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ah! Just as I was hoping. Jim to the rescue!

Is it a bird? Is it a plane? No....

It's the....ANALOGUE MAN!

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the help. I am still interested in recommended diode values... Any ideas?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hmmm.....

Not quite rescue, yet. I missed that 4K emitter resistor in Johan's schematic. I would ground the emitter of the transistor and put that resistor in series with the base. Otherwise, the port pin will never be pulled low enough to be recognized as a logic low. The standard value of 3.9K is good enough. Actually. that could be larger, say 39K. That will give about 100uA of base current. With the transistor full-on, it will sink up to 1mA. That is more than enough to make the suggested collector circuit work.

Actually, now, thinking of things a bit more clearly (ahh, good coffee!), with that base resistor, you need no collector resistor. The collector current will be limited to around 1mA and that will prevent Bad Things (tm) from happening at the port pin, even if it happens to be an output.

So, forget the recommendation of a collector resistor. Simply ground the transistor emitter and use around 39K between the base and +5V. You will be in.

But, now, a little "warning". If this will ever be used at elevated temperatures (say, above 30C or so), transistor leakage can cause it to turn on when it should NOT be on. To fix this, add 100K from base to ground. That will drain off the leakage current that has no where else to go if +5 is absent.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay, think I got it. I reworked the circuit and posted it below. Are we on target now?

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You are on target.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You didn't mention which AVR you are using. If it is one of those with an ADC and analog comparator you could use that, with a resistive divider, to detect the loss of the 5 V, and skip the transistor.

Stealing Proteus doesn't make you an engineer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That final circuit looks good.

Just as a FYI, this post has nothing to do with GCC, so it should be moved to one of the other forums... General Electronics in this case.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are the batteries rechargeable? If so you can get a small part max1555 which actually recharges the battery. It also has a logic output which you can read from your avr.. so you can do everything with a single part rather than a bunch.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

One other point comes to mind - when you are running off of 5V, VCC will be 5V - Vfs(forward Shottky voltage - 0.3V? 0.1V? been too long). When you are running from the battery, VCC will be 4V - Vfs.

So, you have a 1 volt difference between running from 5V and the battery. While the AVR will work fine (depending on what you are using for your clock - the internal RC clock is definitely voltage dependent), the other circuits may not.

One BF&I (Brute Force and Ignorance) approach to solving this problem would be to use a standard silicon diode (Vf = 0.7V) from the 5V source while maintaining the Shottky from the 4V battery. Your final VCC will still see a voltage difference, but it should be less that with both Shottkys.

Not sure if this makes a difference, just pointing it out.

Stu

Engineering seems to boil down to: Cheap. Fast. Good. Choose two. Sometimes choose only one.

Newbie? Be sure to read the thread Newbie? Start here!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Although my memory is dynamic, and lacks of refresh cycles lately, I can't remember of any batery chemistry that delivers 4V. The best approach that may faulty brain finds are two Pb-acid cells in series (about 4.8V full charged, perhaps?). Can you give us more information about this batery, please?

Perhaps StuSan had find a relevant point here. BTW, depending on the schottky diode and forward current, Vf uses to be in the 0.1 to 0.7V, being 0.3V the most usual values that I had measured for similar circuits. Stu's suggestion seem to be quite appropiate, but this depends on your target clock speed. Probably you want to slow things down when battery supplied.

From my point of view, I would put, if available, the 5V and 4V supplies connected through resistor dividers to ADC inputs, instead to any IRQ pin, but this is only a different and nerd approach.

Guillem.
"Common sense is the least common of the senses" Anonymous.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lithium-Ion output is in the range of 3.9 to 4.3V. One MIGHT call this "4".

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think you can leave out the 100k resistor.
You'd need 20uA of current to drop an internal pullup of 50k one volt. The cutoff-current is only 0.1uA at 125 degrees C so that's way below.

For bullet-proofing against software mistakes you could still put a 1k resistor between the collector and the port, so it'll never draw more than 5mA from the port if you accidentally switch it to output.

But as the 5V supply is failing, why not just put a 100k resistor between the 5V supply and the port pin? (disable the internal pullup) Then you wouldn't need any transistor at all.
Assuming here that the 5V supply will fall below 1V when it is not available. If it gets stuck at a voltage equal to the battery because of a power supply capacitor, maybe you can help it by draining it through a resistor between 5V and ground.

And for a real nasty low power implementation you could abuse the protection diodes of your port pins and you wouldn't need any external diodes. But let's not go there yet :-)

Igor

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And we forgot to answer your diode question.
Just look at the maximum current you circuit is consuming, and pick any schottky diode rated at a higher current.
If you want to spend more time on it you could search for the nice ones that drop only 0.1-0.2V but I doubt you would need those.

Igor

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

BAV70

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I agree ikdor and Jim. Add a resistor between the port pin and the transistor collector. That way no problem if set port pin as an output.

A minor thing but you could probably steer the port input a little better with the voltage divider also. 39k / 100k will still steer that port pin low when the 5V rail is at 0.9V or so. (you probably don't want this happening unless it really is in 5V power mode).

oddbudman

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Li-ion have about 4V full charged, but drop down to 3V at 5% charge, more or less. Under normal conditions they exhibit a fairly linear curve between that points. Been there, done that. The most stable batteries are NiMH, with about 1.2V per cell from 10 to 90% charge. Be aware that working from batteries is not that simple.

Guillem.
"Common sense is the least common of the senses" Anonymous.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have been away for a while and was really pleased to return and find all this help. Thanks.

Quote:
Although my memory is dynamic, and lacks of refresh cycles lately, I can't remember of any batery chemistry that delivers 4V.

I am planning to use a 3.9 VDC Lithium.