Go Down

Topic: Help with circuit idea. (Read 3465 times) previous topic - next topic

SargentSeven

Nov 24, 2013, 07:52 am Last Edit: Nov 24, 2013, 09:05 am by SargentSeven Reason: 1
Hi, I am trying to power two 12 volt automotive LED bulbs through a TIP127 transistor that is controlled by an arduino through 2 LTV-816 optoisolators.

Tip127 datasheet. http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/CD00000911.pdf
Optoisolator data sheet: https://www.sparkfun.com/datasheets/Components/LTV-8x6.pdf

The bulbs are 12 volt common cathode White/Amber switchbacks. this means a common - side and 2 positive sides. I want to PWM control the amber side on each bulb separately. each bulb only draws about 0.16 to 0.20 amps. I have a power supply that simulates vehicle power, it puts out about 13.3 volts at 5.8 amps. I have that connected to the barrel jack on the arduino.  

I dont know of a good way to illustrate the circuit, so i will try to describe it as best i can.
the arduino and the breadboard all share the Vin, Gnd, and 5v rails. the optos are connected pin 5 and 6 on the arduino uno to pin 1 on the opto (anode?) the cathode (pin 2?) is connected to ground through a 220 ohm resistor. the tip127's base is connected to pin 3 on the opto, collector is connected directly to the + on the amber led. emitter is connected directly to the 12 volt rail. pin 4 of the opto is connected to the 12 volt rail. i do not have anything else on the breadboard.  (Edit) And the LED 'bulb' is connected to common ground, all grounds are connected at the gnd pin on the arduino board.

Will this function as desired? if i make the pins high on the arduino the led should come on correct?

(Update: solution has been posted below. thanks. Any other info and advice is appreciated for anyone else looking for information)

here is the code used to test the circuit.
Code: [Select]
int L1Pin = 6;    // LED connected to digital pin 6
int L2Pin = 5;    // LED connected to digital pin 6

void setup()  {
  pinMode(L1Pin, OUTPUT);
  pinMode(L2Pin, OUTPUT);
}

void loop()  {
  // fade in from min to max in increments of 5 points:
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
    // sets the value (range from 0 to 255):
    analogWrite(L1Pin, fadeValue);
    analogWrite(L2Pin, fadeValue);   
    // wait for 30 milliseconds to see the dimming effect   
    delay(30);                           
  }

  // fade out from max to min in increments of 5 points:
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
    // sets the value (range from 0 to 255):
    analogWrite(L1Pin, fadeValue);
    analogWrite(L2Pin, fadeValue);   
    // wait for 30 milliseconds to see the dimming effect   
    delay(30);                           
  }
}
Motivation comes in the form of knowing the wife is going to hurt me if I don't follow through with my projects after spending our entertainment budget on parts. XD

TomGeorge

#1
Nov 24, 2013, 08:14 am Last Edit: Nov 24, 2013, 08:22 am by TomGeorge Reason: 1
Hi, sounds about right, you are using PNP to high side switch which is the correct approach.
But you need to connect a 4k7 or 10k resistor between pin 4 of the opto and TIP127 base, then pin 3 of the opto to ground,
This way when the opto is turned on the base is biased negative with respect to the emitter which will make it turn ON.
Make sure your bulb negative (cathode) is connected to ground to complete the 12v circuit.

You can just post a picture of a hand drawn diagram if  you like.

Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

crazypj

It would probably be a good idea to look at the 'Understanding Ground' thread in this section of forum and make sure everything is on common ground.
There is also a diagram showing similar circuit (using single LED)
I haven't used that particular 'bulb' but I have used common ground LED circuits on motorcycles.

SargentSeven


It would probably be a good idea to look at the 'Understanding Ground' thread in this section of forum and make sure everything is on common ground.
There is also a diagram showing similar circuit (using single LED)
I haven't used that particular 'bulb' but I have used common ground LED circuits on motorcycles.



I forgot to mention that the grounds are all right where they should be. everything is common ground too.
Motivation comes in the form of knowing the wife is going to hurt me if I don't follow through with my projects after spending our entertainment budget on parts. XD

CrossRoads

Sounds like this is what you are after. Drawn using expressPCB schematic software, easy to use & learn for discussions like this.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

SargentSeven

#5
Nov 24, 2013, 08:37 am Last Edit: Nov 24, 2013, 08:42 am by SargentSeven Reason: 1
Looks about right, except the optos i am using are a darlington pair rather then a single npn transistor (refer to datasheet linked)
I assume that won't matter in this situation?
What is the resistor between the base and collector for? is that needed? about what value should i use?

Thank you guys, I am going to test the new circuit out.

This is helping me understand PNP circuits a little better. when i searched around i couldn't find anything that was helpful.


UPDATE; i tested the circuit with the above mentioned changes, the bulbs now turn on and off but with one problem. the bulbs make a strange high pitched sound that increases and decreases with the PWM duty cycle. the brightness does not change, instead it turns on and off at about half way through the fade. i am assuming there is some sort of circuitry inside these that will prevent me from doing PWM like i want. any ideas?
Motivation comes in the form of knowing the wife is going to hurt me if I don't follow through with my projects after spending our entertainment budget on parts. XD

CrossRoads

Opto's, I don't see anything in the data sheet to show it is a darlington.
PNP, I didn't have the specific part, so I just used a PNP in its place.
Base resistor limits the current thru the Opto NPN when it turns on.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

SargentSeven


Opto's, I don't see anything in the data sheet to show it is a darlington.
PNP, I didn't have the specific part, so I just used a PNP in its place.
Base resistor limits the current thru the Opto NPN when it turns on.



here is the product page from where i purchased these https://www.sparkfun.com/products/314
Motivation comes in the form of knowing the wife is going to hurt me if I don't follow through with my projects after spending our entertainment budget on parts. XD

CrossRoads

The LiteOn datasheet that opens up does not show a darlington part.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

SargentSeven


The LiteOn datasheet that opens up does not show a darlington part.


you are correct, it does not. however the example schematic provided on the product page does. I am going to assume that it is correctly identified since no one has mentioned anything in the comments section.

I did not put current limiting resistors between the collector and base and it seemed to work fine.

I used another 12 volt LED that i have laying around that does not have a switchback circuit in it. the program and circuit worked fine on it. the white/amber switchback LED that I'm trying to use has some kind of circuit in it preventing me from doing what i wanted. oh well. I have other bulbs that will work with this.

thank you guys for your help. I greatly appreciate the quick responses. + karma for all of you. : )
Motivation comes in the form of knowing the wife is going to hurt me if I don't follow through with my projects after spending our entertainment budget on parts. XD

Go Up