few questions on opti isolator

I'm busy designing, or trying to design a battery charger. I have run into a problem now though. I am trying to measure the voltage of a battery with one of my arduino uno analog pins connected to a voltage dividing circuit. But when I connect the analog pin and ground to the voltage dividing circuit the ground pin causes one of my transistors to switch on even though it's switched off. This will cause my charger to permanently be switched on which is not what I want.

My question, is an opti isolator a dirty fix for a bad designed circuit? Or do some circuits just require ground loops to not be connected?

Can you post the schematic of that?

Yes I can, here it is. When the wire from the voltage divider is connected to the atmega ground then it drives the NPN transistor high

charger.jpg|522x486

From what I can see on my diagram is that the two grounds going to the ATMEGA ground are causing the collector and emitter to be "shorted" or basically bridged with a wire if I can say that.. is that the cause of my problem?

Yes, you've taken the PNP transistor out of the control loop doing that. Why wouldn't you have the PNP collector to LM317 output, and emitter to Battery+ ? Then Battery - to Arduino Gnd. If LM317 out is > 5V, you will need pullup on base to LM317 out to turn it off, and NPN driven by Arduino to pull base low to turn PNP on.

CrossRoads: Yes, you've taken the PNP transistor out of the control loop doing that. Why wouldn't you have the PNP collector to LM317 output, and emitter to Battery+ ? Then Battery - to Arduino Gnd. If LM317 out is > 5V, you will need pullup on base to LM317 out to turn it off, and NPN driven by Arduino to pull base low to turn PNP on.

Well I was trying to avoid complication so I avoided high side switching. With high side switching my PNP base resistors got very hot without the battery connected. With NPN transistors I don't have that problem anymore

Perhaps if you post your PNP circuit diagram we can see what you got wrong...

High side switching is usually far simpler for charging circuits.

Ok I sorted out the problem of the circuit being perminantly on when my transistors were off, I was shorting the collector and emitter with my voltage dividing circuit. So now I have a new problem. What the idea here is I want to switch from constant current source to constant voltage. But if I try switch I only get constant current source, here is a diagram of how it looks. I forgot to draw in the resistors for the transistor bases but just pretend they there

switching from constant current to constant voltage.jpg|610x406

You really need to learn how to draw circuit diagrams, I'm going to have to redraw that to understand it.

+ve rail at the top, ground rail below it, general signal flow left to right....

[ well I've figured out what the circuit is, and its very confused... ]

You should perhaps explain exactly what you want to achieve, so we can figure out a plausible approach.

BTW why use a 32V supply to charge a 12V battery?

I'm sorry I'm new to this. What happens if you have two grounds and two V+ rails like my situation?

Ok it's basically two separate circuits put together. The one circuit is a constant current source. The other one is a constant voltage source. They are both connected to the battery. The transistors there to select which circuit I want to connect to the battery, either constant current or constant voltage. But my problem is the transistors some how connect both constant voltage and constant current circuits at the same time, even though one of the transistors are LOW

But the two transistors are connected in parallel.

You can't simultaneously have constant voltage and constant voltage at the same point in a circuit! The load determines the relationship between current and voltage.

You probably want a circuit that has a programmable current limit, but which is otherwise constant voltage (in other words one circuit in which the normal constant voltage control is overridden by a current limit as necessary. In other words one circuit with two modes of operation.

Ok I think this could be the problem but I'm not sure, so if someone could please help me, I struggle to understand some high end technical electronic language so maybe please explain like you explaining to a child?

I do want 1 circuit with two modes like you say so do you get what I am trying to do now? How can I fix this? Must I incorporate high side switching as well?

problem.jpg|839x506

In the last diagram I posted the left transistor is on and the right one is off

Take MarkT's advice to heart, learn how to properly draw schematics. Often, just redrawing it will cause the fault to jump out at you.

http://opencircuitdesign.com/xcircuit/goodschem/goodschem.html

Your basic problem is that you are trying to switch the low side of the battery to select between sources that have a common ground (the 32V power supply). And PNP are absolutely the wrong transistors to use in a low side switch.

You have enough charger voltage headroom to simply connect the two CC and CV circuits in series. Put the constant current first, then constant voltage. Then you have a current limited, voltage limited charger. It will never put out more current than the setpoint, and never put out more voltage than the setpoint.

polymorph: Take MarkT's advice to heart, learn how to properly draw schematics. Often, just redrawing it will cause the fault to jump out at you.

http://opencircuitdesign.com/xcircuit/goodschem/goodschem.html

Your basic problem is that you are trying to switch the low side of the battery to select between sources that have a common ground (the 32V power supply). And PNP are absolutely the wrong transistors to use in a low side switch.

You have enough charger voltage headroom to simply connect the two CC and CV circuits in series. Put the constant current first, then constant voltage. Then you have a current limited, voltage limited charger. It will never put out more current than the setpoint, and never put out more voltage than the setpoint.

Oh look it's Mr grumpy. Dude in my other post u just said it wouldn't work, so now I try something else and now u say I must do it the other way again. All you do is give negative feedback. It's such a hassle for me to keep asking questions so someone can help me then u came along and give demotivating feedback. BY THE way I have not used PNP transistors for the low side switching. I have used NPN transistors for the low side switching. And I got my circuit to basically work. What pisses me off is you also always recommend your way instead of helping me understand what is wrong with my way. If I ask a question u completely ignore it as well. I am trying my best to read and learn all day but then guys like you just make as if I'm not trying at all. Sorry we not all as bright as you ok

What the heck are you talking about?

You have clearly drawn PNP transistors.

All that I've said is meant to be helpful.

Tell you what... you are a good boy who is doing everything exactly right. There, does that help?

The arrow is the collector.

I am still learning a lot of stuff, but this is a 12V sealed lead acid battery charge circuit I put together. I have yet to build or test it. But I am pretty sure in theory it should work. I figured it may help to just put it up hear since it accomplishes what you are trying to do. I am not saying you have to use it, but maybe it will help.

3/4 of the circuit it just power management, regulation, and a basic ATTINY setup.

The charging portion is simple I think. It is simply a 15V power source that goes through a high side P channel MOSFET, a current sensing resistor setup, and then through a diode and battery.

To control the high side MOSFET with the arduino I am using a PWM signal to control an NPN transistor. By varying my duty cycle I can control how much the transistor is On/Off In effect changing the voltage in between the pull up resistor and the transistor. Then I just put a low pass filter to turn the PWM into a pseudo analog signal to control voltage at MOSFET gate. Doing so allows me to turn MOSFET all the way on (voltage limited charging circuit) or turn MOSFET partially on (current limited circuit). I can also completely shut off transistor and MOSFET gate gets pulled up to 15V effectively shutting off charging.

charging.PNG|1399x721