Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

My first circuit design (battery charger relay)

Status
Not open for further replies.

LB3

New Member
Howdy,

I'm an aerospace engineer by education which means basically a mechanical degree with a fluid specialty. And I'm a biotech engineer by work experience. In other words, I don't know the first thing about electronics, but I'm pretty good with Google so I can get in over my head real quick.

TLDR: This is my first circuit design and I may be in over my head. I have a logic circuit that requires the output of one nand gate for the input of a preceding nand gate and when I initially bread boarded it up, it didn't do what my truth table says it should. I've since fixed it but could use someone with a bit more experience telling me wether this looks like a viable solution.

Problem:
I installed a big Lithium battery bank in my RV. It's great, it will run my roof air conditioner for a few hours and with solar, I can stay in the woods indefinitely. But my brand new 200A Bosch alternator died shortly after I did the Lithium install and alternator upgrade. My wife does several solo trips cross country for business so getting stranded in the middle of nowhere is not a great outcome. When I took the alternator to a repair shop, it had a failed pulley clutch.

Root Cause Hypothesis:
It could be that I got a bad alternator and I'm just on the unlucky side of small number statistics, or more likely, I have a design problem. The charge controller charges at full rate all the way to full, then pulses the charging current for a fraction of a second several times per minute to keep the batteries topped off. This works well on solar power but when the RV is charging from the 60A DC-DC converter feeding from my alternator, it's slamming the alternator pretty hard for thousands of cycles which I believe is leading to the mechanical failure of the pulley clutch.

Solutions:
Option 1.) Install a second alternator on the RV.
Pros: This provides redundancy and isolates the RV house battery from the van's chassis battery so if it fails again, we at least don't get stranded anywhere.
Cons: Nobody manufactures a second alternator kit for our van so procuring a custom alternator bracket will be expensive, as will another heavy duty alternator. And it still doesn't address the root cause of our problem.

Option 2a.) Turn off the alternator charging before the battery reaches full charge.
Pros: We already have a relay separating the house and chassis systems so adding a manual switch to turn off the alternator charging would be cheap and easy to install.
Cons: It takes some mental overhead to keep track of and estimate the state of charge of our lithium battery and then remember to turn off the switch to the relay. Failing to do so in time would result in dozens or hundreds of extra charging cycles on the alternator.

Option 2b.) Design a controller to turn on the battery relay off when the State of charge is 95% or greater.
Pros: The charge controller has several programmable I/O pins so it's pretty easy to get a 3.3v signal to feed a logic circuit and since there is already a relay in place, it shouldn't be difficult to integrate this circuit into the system. This should reduce the cycles to approximately 2 on/off events per day when driving in the south during summer when the roof AC is needed at lunch breaks. This also gives me the opportunity to learn about digital circuits or micro controllers.
Cons: Adding complexity and additional failure modes to an otherwise simple system. Since I don't have a background in electronics, there is a pretty steep learning curve involved.

My design:
I decided to go the digital circuit route since I believe this, if designed well, will be more reliable than an arduino based solution.
It can't be as simple at turning off the relay when hitting 95% SOC because it would come back on at 94.99% and I would have the same cycling issue. I need the relay off when the state of charge reaches 95% and stay off until it reaches 70% SOC, then turn on again. This lead me to create the following truth table:

A= 1 when >95% SOC
B=1 when >70% SOC
C=1 when the relay is on:
X= undefined states since the SOC can't be above 95% and below 70% at the same time.

ABC | Y
000 | 1
00 1 | 1
0 1 0| 0
0 1 1 | 1
1 00 | X
1 0 1 | X
1 1 0 | 0
1 1 1 | 0

With a little help from http://www.32x8.com/var3.html I created the following logic diagram which I converted to all NAND gates to allow the use of a 74HC00 logic IC:

XGX2qlG.png


Awsome! That looks simple enough.

So then I Google the data sheets on the 7400 ICs and learn that they don't operate at 12 volts and that they won't drive a 200mA relay. Next I Google voltage regulators and watch youtube videos on NPN transistors and come up with this design:
GKQQfwC.jpg


I probably should have labeled my schematic, but it's late and I've been up all night, so you've just have to trust that I can accurately look up data sheets and calculate the resistor sizes needed for a given gain for the NPN. ( Note, the 74HC00 is a wimp so I chose a transistors with pretty large gains). I don't understand all this stuff but the 74HC00 data sheet recommended the capacitor and not letting unused inputs float so added a .1uF capacitor and diode to the voltage regulator. This really feels like overkill but I saw somewhere that is was a good design practice. It makes more sense with the high inductance load of the relay coil so you will see a smaller capacitor and diode there.

I bread board it all up and immediately smoke my 100 mA voltage regulator. The 5v circuit shouldn't draw more than maybe 20mA so I'm suspecting I either installed it backwards or perhaps the .1uF capacitor was too large? I replace the regulator with a larger 700mA (1.5 A peak) 5v regulator from my local electronics shop and it's stable and stays cool. Unfortunately, in the scenarios when the logic is depending on the feedback from the last NAND gate, the output to the small motor that I'm using for a load warbles a bit as if the output isn't entirely stable. If I remove the feedback loop between 3Y and 2B and feed the 2B input directly from the 5v or ground busses, the output is much more stable.

ABC | Y
000 | 1
00 1 | 1
0 1 0| 0 These are the conditions that falter a bit
0 1 1 | 1These are the conditions that falter a bit
1 00 | X
1 0 1 | X
1 1 0 | 0
1 1 1 | 0

Is this just an issue of me not changing the input lead wires fast enough and the IC inputs float too long or is there a bigger issue with this feedback concept in general? If so, what's the solution to this issue? Do I try to slow down the voltage decay in that feedback loop long enough to keep the circuit from changing states? Given that that leg is also feeding the transistor, I suspect it decays pretty quick. I've started reading up on latching circuits but I can't make much sense of it. Maybe I'm out of my depth or just need some sleep.

Any advice on this main question or feedback on the rest of the circuit design would be greatly appreciated.
-lb
 
Last edited:
Welcome to ETO!
Is this just an issue of me not changing the input lead wires fast enough and the IC inputs float too long
Could well be. It is a no-no to let CMOS inputs float. The IC behaviour becomes unpredictable. If you are going to swap leads around manually while breadboarding (and be aware that CMOS ICs are static-sensitive), at least connect those inputs permanently to one or other power rail by a high value resistor (say 1 MegOhm).
 
Welcome to ETO!

Could well be. It is a no-no to let CMOS inputs float. The IC behaviour becomes unpredictable. If you are going to swap leads around manually while breadboarding (and be aware that CMOS ICs are static-sensitive), at least connect those inputs permanently to one or other power rail by a high value resistor (say 1 MegOhm).
That’s kinda clever. Thanks for taking the time to read my small dissertation.

Do you think I should move on to a prototype board and connect it to my charge controller to have a more flight-like testing environment or should try to refine my testing a bit more on the breadboard?
 
I'd carry on breadboarding, at least until you hit another snag :)
 
Feedback in circuits can cause circuits to become unstable. It's just the nature of the beast. If it's warbling it might mean it is riding the line between stable and unstable. I'm not really sure how you would deal with it in a digital circuit though. In analog circuits it usually means throwing in resistors and capacitors here and there to mess around with the phase of the circuit. In the case of a digital circuit that would be the delays of the signals running around the circuit and race conditions.

Adding delays to the feedback loop usually makes stability worse, not better. Your feedback loop is just a wire so you can't really get faster than that. But the flip side is you can delay the speed at which the output reacts so the slow feedback loop runs faster relative to it. A latch seems like an overblown solution. Maybe try a schmidt trigger like the SN74LVC1G17? Or wire a pairs of of end-to-end NOT gates (or NANDs wired as inverting gates) between the T-point of the feedback loop and the base resistor to add some delay to the output relative to the feedback loop. Use more than one end-to-end pair for more delay. These are all kind of a shot in the dark.

I don't think you need the capacitor across the NPN's source-drain since the diode across the inductive load should be enough. Make sure to use a fast diode.

Stay on the breadboard until you're confident you know you won't need more changes (or until the breadboard reliablity becomes too much of a PITA to stick with during refinement).

For floating inputs and such, you can connect a resistor between each input to ground (or the voltage supply rail of the chip). Just make it a high resistance so when the active device tries to drive the line, it doesn't have to work too hard to overpower the resistor. 10K-20K is probably okay for a CMOS device which the 74HC00 should be. Or even 1Mohm as alec_t suggested (that seems really high to me though).

Don't forget to decouple the ICs. You place a 0.1uF ceramic capacitor as close as possible to the power and ground pins of the IC. I would use the X7R ceramic since this is for something like an RV that won't always be indoors. The actual value and type aren't too critical since it's meant to just provide a momentary reserve charge supply close to the chips when they suddenly draw a spike of current since the battery/power source is slow and usually far away separate by wire inductance which prevents it from providing current fast enough to keep up with the IC.
 
Last edited:
Thanks for the ceramic suggestion. I’ll go read up some more. I grabbed Mylar capacitors because I didn’t like the lifespan of electrolytes but was scratching my head when trying to chose a style.

I hadn’t given packaging and integration much thought yet. Since the relay is about 10 ft away (may require a 20 ft run under the van to get into the driver seat pedestal where the relay is located.

I’m either going to need to run a long 3.3v signal wire to this control circuit or a long wire between the relay and the transistor collector. With the signal wires, I will need to use existing conduits and risk inducing currents/voltage in those wires making my shaky circuit less stable.

With the long run to the transistor collector, I’ll be significantly increasing the impedance and the risk of ‘water hammer’. (I don’t know what term you sparkys use for that phenomenon.

I’m feeling that the long run from the relay to the collector makes the most sense but will it require additional circuit protection?
 
Thanks for the ceramic suggestion. I’ll go read up some more. I grabbed Mylar capacitors because I didn’t like the lifespan of electrolytes but was scratching my head when trying to chose a style.


Electrolytic (so-called wet) is what you use when you need more capacitance than any other type can reasonably offer. There are now polymer electrolytics that are both hybrid and dry. They both have longer lifetime than the normal wet electrolytics. Dry has the longest lifetime since nothing to dry out, but they cannot withstand overvoltage as well as the wet or hybrid since the wetness allows some degree of self-healing.

For common, undemanding, applications that requires high frequency response (like decoupling), ceramics are what are normally used. X5R is the worst kind I will use. X7R is what I normally use. These are most common under 1uF, but you can get find them up to 10uF. Don't use C0G because those are only available at a reasonable cost (0.1uF is available but very large for C0G) in very small capacitances and they are very stable both with temperature and DC bias voltage, no piezo effects, and very precise capacitances. They are therefore meant for timing and signal path applications. They might even be detrimental when used for decoupling since they can cause oscillations due to their low internal resistance (which is normally a good thing).

The Y ceramics like Y5V are crap.

With the long run to the transistor collector, I’ll be significantly increasing the impedance and the risk of ‘water hammer’. (I don’t know what term you sparkys use for that phenomenon.

Our inductive flyback/kick/spike is your water hammer. The voltage spike produced by an inductor when you interrupt current to it. It will dump the energy stored in it's magnetic field to try and maintain the same current level (because that's just what inductors try to do) and the voltage spike produced is made to be high enough to force that same current level past whatever obstacles lie in the way. It's inductance that causes electrical water hammer.

I’m either going to need to run a long 3.3v signal wire to this control circuit or a long wire between the relay and the transistor collector. With the signal wires, I will need to use existing conduits and risk inducing currents/voltage in those wires making my shaky circuit less stable.

With the long run to the transistor collector, I’ll be significantly increasing the impedance and the risk of ‘water hammer’. (I don’t know what term you sparkys use for that phenomenon.

I’m feeling that the long run from the relay to the collector makes the most sense but will it require additional circuit protection?

10 feet is long but not so long I'd worry about inductive flyback at such a low signal current. But I would still stick wire that long onto my breadboard and test it to make sure nothing funny happens from other effects like capacitance, transmission line effects (signal reflection), or acting as an antenna. I would stick TVS diodes on there for static protection (and will also help deal with your inductive flyback if there is any).

Your circuit is unipolar so get unipolar TVS diodes and connect them in between the line being protected and ground. You could use bipolar TVS diodes and then it doesn't matter what direction you put them in, but if your circuit is unipolar then one of the direction doesn't have as much protection as it could have. Place the unipolar TVS diode between the line and ground and make the triangle point from ground to the protected line. Placing it the other way will cause a short-circuit all the time. Placed this way, if the ground line ever drops below the voltage of the protected line, the TVS diode forward conducts like a normal diode and prevents the voltage difference from getting any more negative. If the protected line rises too high, the TVS diode reverse breaks down and conducts preventing the protected line from rising too high above ground.

For static protection, place them as far away from the component being protected as possible but not so far that it's past the point where a zap could be expected to entire the wire. Having wire inductance between the component and the TVS diode helps because it buffers the component from the zap event while the TVS does it's job clamping the line, but you don't want it so far away that a zap could enter the wire between the component and TVS diode, bypassing it the TVS diode.

Also, the base resistor kinda helps protect whatever component it's closest to, especially if it's a high enough value. You might want to split it in half and have one on both ends of the long line to help protect the NPN and the chip.
 
Last edited:
The 74HC00 input H switching threshold voltage is almost the same as your 3.3V input signal when the supply is 5V. Then the switching will be erratic.
Then use a higher input signal voltage (maybe 4V) or a lower supply voltage (maybe 4V).

With the 5V supply, an output H current from the 74HC00 is easily the 25mA maximum allowed current.

Why do you talk about the gain (hFE) of the transistor? The hFE is used for a linear amplifier transistor that is never saturated. But you want your transistor to be a saturated switch and the datasheet for most transistors show the base current is 1/10th the collector current regardless of the hFE.

Hint: you show the 74HC00 as a box instead of as four 2-inputs NAND gates. I think your gates are a cross-coupled set/reset circuit.
 
Thanks dknguyen and audioguru!:)
The 74HC00 input H switching threshold voltage is almost the same as your 3.3V input signal when the supply is 5V. Then the switching will be erratic.
Then use a higher input signal voltage (maybe 4V) or a lower supply voltage (maybe 4V).
48 hours ago I wouldn’t have understood this but it makes sense now. I’ll try to lower my Vcc to 4v.
With the 5V supply, an output H current from the 74HC00 is easily the 25mA maximum allowed current.

Why do you talk about the gain (hFE) of the transistor? The hFE is used for a linear amplifier transistor that is never saturated. But you want your transistor to be a saturated switch and the datasheet for most transistors show the base current is 1/10th the collector current regardless of the hFE.
I’ll need to study up on this. I’m not trying to say I don’t believe you, just saying I don’t fully comprehend what you’re saying. I thought saturating electronics would be a bad thing. I’m used to adding margin into the systems I work with, or as an operator, trying to eat as much margin as I can get away with without compromising our crews, vehicles, or missions.

I thought the 74HC00 was limited to an output of 4mA so I tried to pick a high gain transistor to keep my output current down to about 3mA. If it’s good to 25 mA and I can safely saturate the transistor, then a 10x gain should be much more stable than the 400x-800x gain I have in there now.

Later in the week I’ll label my components so you can tell me why more of the components I cobbled together are crap.

I really do appreciate all the good feedback I’m receiving as a noob on this site. I’m learning more from y’all than I could in a month of intro electrical lectures.
Hint: you show the 74HC00 as a box instead of as four 2-inputs NAND gates. I think your gates are a cross-coupled set/reset circuit.
That helps explain why I was having trouble grafting on a latching circuit. I had inadvertently already built one.:cool:
 
Does the coil of your relay use 200mA at 12V? Then it uses more at the 14.4V from a charging car battery.
What transistor do you use that has an hFE of 400 to 800 at 200mA or more? What is its saturation voltage and recommended hFE when saturated?
You are using the transistor as a saturated switch then you must use the base current shown on the datasheet when saturated.

Here is the datasheet of the 74HC00 high current Cmos gate IC:
 

Attachments

  • 74HC00.png
    74HC00.png
    28.6 KB · Views: 176
I measured the relay current with the engine running and saw 209 mA so it’s probably close to its max but adding in some margin to account for voltage fluctuations sounds smart.

Since I misread the limits on the 74HC00 IC and didn’t understand the need to saturate the transistors, I’ve probably not made very good selections. I currently have a NTE 16006 in the breadboard but I also picked a NTE 13 off the shelf at Fry’s that I have played with.

If you have a favorite transistor (or voltage regulator) that would work for this application I would love to hear what they are. Otherwise I guess I’ll just head over to Digi-Key or Mouser and sort through the thousands of options and try to pick one that doesn’t suck.

Something like this looks promising:
**broken link removed**

I’m not sure what kind of heat these things produce. Maybe something in this form factor would work better?
www.digikey.com/product-detail/en/2SC4495/2SC4495SK-ND
 
Last edited:
I do not think that NTE manufactures transistors. I think they buy them and re-mark them as replacements. In Google, NTE Electronics is called a distributor not a manufacturer.
The NTE 16006 datasheet has unbelieveably high hFE and has no graphs to show it. Buy Name-Brand transistors instead.

The datasheets show the maximum allowed heating but you must derate depending on the heat of the ambient and derate a little more for reliability. Heating= Volts across it times the Amps though it. A saturation voltage of 0.5V x 209mA= 100mW and most little 625mW rated transistors will only get warm. You do not need a huge power transistor.

Do you understand how the flip-flop 74HC00 works? When one input goes low then the flip-flop flips.
Do you know what the input logic does? I ask because you show gate 1ABY wired as an inverter but the other gate 3ABY input has no inverter.
 
Sorry I haven't gotten back to this thread. I got swamped at work .

I'll ditch the NTE stuff in the next iteration.

I read up on the flip-flops after your post.

220px-SR_Flip-flop_Diagram.svg.png


The NAND gate Flip Flop triggers on a low voltage set and reset and the way I had my charge controller programmed it was sending a high voltage output when the State of Charge was >70 & >95%. To make the flip-flop circuit, the >95% would need to be <95% which is why my circuit had the inverter on the >95% input.

Not knowing about flip-flops, I still came up with the same circuit. :) And the output of the test circuit matches my truth table so I was happy because it used fewer than the 4 NANDs on the 74hc00.

If you look at my first logic diagram, that essentially came from entering the truth table into the 32x8.com here. The second simplified logic diagram is the result of converting all the logic gates in the first diagram into all NAND gates and then deleting all the back to back inverters.

And replacing the original block schematic version of the 74hc00 with the NAND gate version looked like this:
WdzvRue.jpg

Where the >95% input is on 1A & 1B and the >70% input is on 3B

Having a better knowledge of basic logic circuits would have made things a bit easier for me but I still got where I needed to go. But all that may become obsolete as I've decided to alter the circuit a bit by ditching the voltage regulator and will now run the circuit off of the <95% 3.3v input. This means the circuit will always be powered when the battery is below 95% full so I need to make this a very low power circuit so it doesn't run down the batteries if the RV is parked for a couple months.

I'm therefore going to swap out the single transistor switch with a darlington pair so I can drive the logic and relay on less than 3 mA of input current. Or that's the plan for now.

And since I'm inverting the 95% input, I'll now only need two of the NAND gates and will have the true flip-flop circuit:
1549870248475.png


And here is the updated circuit:
1549872748903.png

What I'm worried about is the capacitor on the Vcc of the 74HC00 IC drawing too much current. If I add a resistor(110 ohm) to the Vcc before the capacitor I would slow the inrush current on the <95% input to less than 30 mA but I would also drop the Vcc to 3.1 volts (assuming I keep my transistor saturation current <2mA). The Vcc would then be under the >70% input signal so I would need to add diodes to the 4B and 3A pins to keep them below Vcc.

Is this more trouble than it's worth and should I go back to using a 4v or 5v voltage regulator?
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top