Pages: [1] 2   Go Down
Author Topic: Using 5v To switch 12v supply? (ATtiny in car use)  (Read 4577 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys, This is a tricky one that has me confused!

Basically I have used my arduino to program a little ATtiny85 that turns On/off Supply to a pin (LED's to be attached) With the function of being able to adjust the brightness by holding the button down (As explained in getting started with arduino book example 5).

I have it all working to the stage where I can turn on and off and vary brightness of some 3v led's without the use of resistors, BUT I designed the circuit for use in my car where I wanted to use 12v LED strips. The input voltage for the ATtiny is 3.2 - 5.5 V so I will have to use a voltage regulator to limit that (I forgot how to do this exactly to what I need! smiley-razz) . The problem arises where I am not sure if it is possible to effectively Upscale the voltage from the pin to 12v (Whilst still being able to adjust voltage to vary brightness) Or to use the ATtiny's output to effectively switch on and alter the 12v supply seperately.
I think it may be possible with some kind of transistor but this one truly has me confused!

That probably sounded like a load of nonsense so I professionally made up a BS8888 Standard Engineeirng drawing for you below smiley-wink (The wonders of paint! smiley-razz)



I would greatly appreciate any help you could give me... I'm truly stuck! smiley-grin

Thankyou and happy modding!
¬Al

EDIT: I just noticed I forgot to connect the other pin of the Button to the +VCC on my expert diagram hahaha, assume it is connected smiley-razz
Logged

Canada
Offline Offline
God Member
*****
Karma: 7
Posts: 602
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

First off, you should never be using an component LED without a resistor.

Yes, you can use a transistor to switch on and off the LED strip, but the strip would still be powered of the 12V, not the 5V supply of the MCU.  The specific transistor and how to bias it would depend on the current the LED strip draws.  So you need the specs of the particular LED strip.

For your regulator dilemma, look up the datasheet for a LM78L05.
Logged

Facts just don't care if you ignore them.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 34567
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You also need capacitors across the input and output of the regulator, that middle pin goes to ground.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the replies,
The Forward Voltage is 12v
The Forward Current 20mA
More info here : http://www.phenoptix.com/index.php/led-tape/blue-12v-led-strip-5cm-smd-leds-flexible-tape.html
I believe That If I use an LM317 Voltage Regulator with Resistor values of R1= 330 Ohms And R2 = 1kOhm I can get a moderately accurate 5.04v Supply to the ATtiny.

As for the transistor, I'm still confused But I have been told I can use an NPN 2N3904 General Purpose tranistor with specific resistors to do this, not entirely sure how though as I effectively need two inputs (12v Supply for the LED Strips, and 0 - 5V Variable supply from the ATTiny ouput pin) with one output to the LED's that varies relatively to the ATTiny.
I know this is possible due to a transistor obviously being and acting as a transforming resistor; effectively raising the voltage but keeping the proportions.. A bit more help would be appreciated! smiley-grin

And as for the Resistors on the LED's, the 12v Strips I am using have built in SMD resistors.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 34567
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Driving an LED strip is just like driving a motor, or a relay. Look at the first two circuits here:-
http://www.thebox.myzen.co.uk/Workshop/Motors_1.html

Quote
If I use an LM317 Voltage Regulator
But if you used a fixed voltage regulator then you would not have to bother. There are hundreds to choose from here:-
http://uk.farnell.com/jsp/search/browse.jsp?N=2031+204250+110197572&Ntk=gensearch&Ntt=voltage+regulator&Ntx=mode+matchallpartial&No=0&getResults=true&appliedparametrics=true&locale=en_UK&divisionLocale=en_UK&catalogId=&skipManufacturer=false&skipParametricAttributeId=&prevNValues=2031+204250&mm=1001850||,&filtersHidden=false&appliedHidden=false&autoApply=true&originalQueryURL=%2Fjsp%2Fsearch%2Fbrowse.jsp%3FN%3D2031%2B204250%26Ntk%3Dgensearch%26Ntt%3Dvoltage%2Bregulator%26Ntx%3Dmode%2Bmatchallpartial%26No%3D0%26getResults%3Dtrue%26appliedparametrics%3Dtrue%26locale%3Den_UK%26divisionLocale%3Den_UK%26catalogId%3D%26skipManufacturer%3Dfalse%26skipParametricAttributeId%3D%26prevNValues%3D2031%2B204250

Quote
effectively raising the voltage but keeping the proportions
No that is not how transistors work, see:-
http://www.kpsec.freeuk.com/trancirc.htm

Quote
and 0 - 5V Variable supply from the ATTiny ouput pin)
No you don't which is just as well as you can't get such a thing. Do you want to dim the LEDs?
If so they might respond to a PWM output, this is not a variable voltage output but a digital signal:-
http://www.thebox.myzen.co.uk/Tutorial/PWM.html

Logged

Canada
Offline Offline
God Member
*****
Karma: 7
Posts: 602
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have a look at the attached schematic.  This should work for you.


* LED switch.jpg (58.54 KB, 1213x500 - viewed 273 times.)
Logged

Facts just don't care if you ignore them.

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey guys, Thanks for all the help...
BillO that looks like a KI cad shcematic!? smiley-razz
I was hoping to get a couple of mini pcb's produced to make the finish more professional and tidy, I was wandering if you could send me the KI cad files for that schematic so I can convert it to a PCB layout?
That would be awesome! smiley-grin
I have just ordered the specific components you stated, so I'll breadboard a circuit when I get them in the post and If it all works I'll send off for a pcb or two! (I could send you one if you like, as a thankyou for helping?)
Anyway... let me know! smiley-grin
¬Al
Logged

Canada
Offline Offline
God Member
*****
Karma: 7
Posts: 602
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It was drawn with DipTrace, but I only retained in JPEG form, sorry.  It should take not take much time to enter it into some other application though.

If you're stuck and can wait till next week I can re-do it and even do a lay-out and produce the Gerber files.  But I'm pretty busy until next Monday.
Logged

Facts just don't care if you ignore them.

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Finally got the last of the components for this today, and I just built a breadboard circuit. It works... BUT It's working as if it's reading the reverse of the button, eg it thinks its being pressed when its not, and when its not being pressed it thinks it is!
Because I have it set to a momentary press to turn on/off, that bit is not affected due to a simple state change in the program, But what it does is it stays on and changes brightness as if you are holding the button! :S I think I have wired it up correctly... Here's a photo of my breadboard circuit... Can you spot anything i've done wrong? I have double checked! :L
And as regards to the circuit schematic, thanks for the offer that is very kind of you, but i'll have an attempt at it in KiCad then post it here for you guys to double check smiley-razz

Cheers again,
Al
Logged

California
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's a photo of my breadboard circuit...
Where?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oops! Forgot to paste the links! :L Sorry!

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If I were you I'd ditch the transistor and use a relay. Relays are simpler to wire, they already come made for auto use, and they generally can handle more current than a transistor. That is unless you are looking to dim the leds with pwm, because relays aren't that fast at switching.
Logged

Canada
Offline Offline
God Member
*****
Karma: 7
Posts: 602
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You'd need a transistor to drive the relay, so no, do not ditch the transistor.  It's just fine.

In this circuit, the input at pin2 goes low when the button is pressed, and from what I can see that looks correct.  Does the code expect the input to be active low or high?
Logged

Facts just don't care if you ignore them.

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You'd need a transistor to drive the relay, so no, do not ditch the transistor.  It's just fine.

In this circuit, the input at pin2 goes low when the button is pressed, and from what I can see that looks correct.  Does the code expect the input to be active low or high?

Right, The code waits for the button input to be high, so I think that's where the problem could be... I can paste the code if you need?
And I really appreciate your help on this by the way! smiley-grin
Logged

Canada
Offline Offline
God Member
*****
Karma: 7
Posts: 602
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sure, post the code and lets have a look.
Logged

Facts just don't care if you ignore them.

Pages: [1] 2   Go Up
Jump to: