# Need help with understanding transistors

Discussion in 'The Projects Forum' started by MikeJewski, Dec 1, 2015.

1. ### MikeJewski Thread Starter New Member

Dec 1, 2015
9
0
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?

2. ### #12 Expert

Nov 30, 2010
16,703
7,341
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: Dec 1, 2015
3. ### MikeJewski Thread Starter New Member

Dec 1, 2015
9
0
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.

4. ### MikeML AAC Fanatic!

Oct 2, 2009
5,451
1,066
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...

File size:
2.4 KB
Views:
3
5. ### MikeJewski Thread Starter New Member

Dec 1, 2015
9
0
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.

6. ### spinnaker AAC Fanatic!

Oct 29, 2009
5,078
1,179
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.

7. ### MikeML AAC Fanatic!

Oct 2, 2009
5,451
1,066
That is the most trivial coding change in the Arduino code possible...
Otherwise, add another NPN or cmos logic inverter.

8. ### MikeJewski Thread Starter New Member

Dec 1, 2015
9
0
But wouldn't applying 0V not allow the current to go through the battery?

9. ### MikeML AAC Fanatic!

Oct 2, 2009
5,451
1,066
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?

10. ### ISB123 Well-Known Member

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

11. ### MikeJewski Thread Starter New Member

Dec 1, 2015
9
0
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.

12. ### ISB123 Well-Known Member

May 21, 2014
1,240
531
Are you using a relay to switch off the battery charging?
And do you have schematics for the circuit?

Last edited: Dec 1, 2015
13. ### MikeJewski Thread Starter New Member

Dec 1, 2015
9
0
I just read up on relays and made this circuit design, I'm not sure if this makes sense at all. The switch on the left just symbolizes the arduino powering both pins at the same time.

http://tinyurl.com/ht34dcn

14. ### ISB123 Well-Known Member

May 21, 2014
1,240
531
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.

MikeJewski likes this.
15. ### MikeJewski Thread Starter New Member

Dec 1, 2015
9
0
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?

16. ### ISB123 Well-Known Member

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

17. ### MikeJewski Thread Starter New Member

Dec 1, 2015
9
0
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!

Dec 6, 2010
12
0
19. ### MikeJewski Thread Starter New Member

Dec 1, 2015
9
0
Asked a peer, and he recommended using XOR gates. Will post a new circuit, hopefully will be the last revision