Need help with understanding transistors

Thread Starter

MikeJewski

Joined Dec 1, 2015
9
I was wondering if anyone would be able to help me. I have recently been given the task of making a circuit design when I have no electrical experience, so I have been stumbling my way through and hit a roadblock. I am trying to make a circuit in which there is a switch which will be turned on at all times, until an arduino gives an output and turns it off. The circuit needs to be like this, as it will be in the on state for most of its life, but I will have certain times when I need to turn the switch off for a short period of time. Any ideas?
 

#12

Joined Nov 30, 2010
18,224
Which polarity does the arduino deliver when it wants the switch, "off"?
How much current does the switch need to conduct?
Is the switch working with 3.3 volts, 5 volts, or some other voltage?
How fast does it need to be?

Really, it's dead simple, right after we know how big and how fast it needs to be.
 
Last edited:

Thread Starter

MikeJewski

Joined Dec 1, 2015
9
Which polarity does the arduino deliver when it wants the switch, "off"?
How much current does the switch need to conduct?
Is the switch working with 3.3 volts, 5 volts, or some other voltage?
How fast does it need to be?

Really, it's dead simple, right after we know how big and how fast it needs to be.
I'm not even sure if I am going about this the right way, but basically the circuit is a solar panel charging a battery. When the battery has a certain voltage coming off of it, as measured by the Arduino's ADC input pin, I want the Arduino to send an output of 3.3V to a transistor to turn off the connection to the battery. The voltage coming into the battery will be 4.2V, but will have varying current, while the Arduino supplies I believe 3.3V and 20ma. And the off state might need to be held for up to 30 mins - 1 hour. Here is a rough idea, but using an NPN transistor would mean I would have to keep the base saturated, which would drain power.
Arduino.png
 

MikeML

Joined Oct 2, 2009
5,444
This sim shows what needs to be done. I created a rudimentary model of a panel that puts out ~7V O.C., and a short circuit current of 50mA. I created a "battery" using a 10Farad capacitor. I created a model of the Arduino, using an AD input pin and a single port pin.
The simulated Arduino code reads the AD input, and sets a port pin low if V(ad)>2.857V with a bit of hysteresis.

I scale the battery voltage by ~2/3 to put 4.2V within the range of the Arduino's AD whose full scale input is 3.3V. R2 and R3 do that. C2 provides the requisite low input impedance for the Arduino's AD input pin.

Q1 and Q2 are a high-side switch that either connects the panel to the battery or not, controlled by the port pin.

The simulation shows the charging sequence. The battery is initially at 3.8V, the panel is connected, so it charges toward 4.2V as shown by V(bat). When V(ad) exceeds 2.857V, the port pin V(port) switches from 3.3V to oV, turning off Q1/Q2. The panel voltage V(pan) jumps to the panel's open circuit voltage. V(bat) coasts, being discharged only slightly by the voltage sensing resistors R2/R3. I(Cbat) shows the battery charging current.

Not shown is how low does the battery have to sag before the cycle repeats.

The time scale in the sim is arbitrary. You only build the stuff that is not in dashed boxes...

154.gif
 

Attachments

Thread Starter

MikeJewski

Joined Dec 1, 2015
9
This sim shows what needs to be done. I created a rudimentary model of a panel that puts out ~7V O.C., and a short circuit current of 50mA. I created a "battery" using a 10Farad capacitor. I created a model of the Arduino, using an AD input pin and a single port pin.
The simulated Arduino code reads the AD input, and sets a port pin low if V(ad)>2.857V with a bit of hysteresis.

I scale the battery voltage by ~2/3 to put 4.2V within the range of the Arduino's AD whose full scale input is 3.3V. R2 and R3 do that. C2 provides the requisite low input impedance for the Arduino's AD input pin.

Q1 and Q2 are a high-side switch that either connects the panel to the battery or not, controlled by the port pin.

The simulation shows the charging sequence. The battery is initially at 3.8V, the panel is connected, so it charges toward 4.2V as shown by V(bat). When V(ad) exceeds 2.857V, the port pin V(port) switches from 3.3V to oV, turning off Q1/Q2. The panel voltage V(pan) jumps to the panel's open circuit voltage. V(bat) coasts, being discharged only slightly by the voltage sensing resistors R2/R3. I(Cbat) shows the battery charging current.

Not shown is how low does the battery have to sag before the cycle repeats.

The time scale in the sim is arbitrary. You only build the stuff that is not in dashed boxes...

View attachment 95640
Thank you for spending the time making a sim! I was wondering though if it was possible to make the 0V state allow power from the panel to charge the battery, and the 3.3V state cut off power to the battery. I'm not sure if this is possible though.
 

spinnaker

Joined Oct 29, 2009
7,830
If it is a charge controller you want, you cannot possibly do better than the experts. There is a whole science to safe and efficient battery charging. Take a look at an off the shelf solution. Sunguard has some excellent products but there are plenty of other solutions.
 

MikeML

Joined Oct 2, 2009
5,444
I was wondering though if it was possible to make the 0V state allow power from the panel to charge the battery, and the 3.3V state cut off power to the battery. I'm not sure if this is possible though.
That is the most trivial coding change in the Arduino code possible...
Otherwise, add another NPN or cmos logic inverter.
 

MikeML

Joined Oct 2, 2009
5,444
But wouldn't applying 0V not allow the current to go through the battery?
Huh?

Are you disconnecting the Arduino from the battery so that the Arduino is unpowered at the same time you are expecting the battery to charge?

Isn't the Arduino always monitoring the charging process?
 

ISB123

Joined May 21, 2014
1,236
Are you just using Arduino to detect certain voltage and when that certain voltage is reached it sends out a signal to the switch?
 

Thread Starter

MikeJewski

Joined Dec 1, 2015
9
Are you just using Arduino to detect certain voltage and when that certain voltage is reached it sends out a signal to the switch?
Yes! But since the off state will only be used for short periods of time, I wanted something that would be able to switch off when the voltage is applied from the arduino. Sorry if the things I say don't make sense, this is the first time I am working with circuits.
 

ISB123

Joined May 21, 2014
1,236
Are you using a relay to switch off the battery charging?
And do you have schematics for the circuit?
 
Last edited:

ISB123

Joined May 21, 2014
1,236
Do you want to stick with just using arduino? This can be done using much simpler components and be cheaper.In
case you do not want to stick with Arduini i'll post a circuit tomorrow.
 

Thread Starter

MikeJewski

Joined Dec 1, 2015
9
the final product will be using a microcontroller, I am just using an arduino right now as a mock up as it is easier to reprogram and change the circuit with. What else would you use?
 

ISB123

Joined May 21, 2014
1,236
I would have used a comparator and transistor. But since your design spec. say that it requires a MCU just stick with it then.
 

Thread Starter

MikeJewski

Joined Dec 1, 2015
9
the idea is actually to have 2 batteries in parallel, and the microcontroller would be checking the batteries to make sure their state of charge is within 5% of each other and if not, restricting flow to one of the batteries until it is charged. The reason why we need this is that we can't allow the batteries to microcharge each other, killing the life of the battery. if you can think of a way to do this without the use of a micro controller, I would appreciate anything you can think of!
 
Top