Offline
Newbie
Karma: 0
Posts: 4
|
 |
« on: April 12, 2012, 03:32:44 pm » |
I'm curious how easy/difficult it would be to do something (I'm a novice with electronics and arduino), I'll do my best to explain. I want to get 2 different colors out of my RGB LED, doesn't matter which colors, but I want to be able to do it with 1 PWM pin, instead of 1 pin per color. PWM: 50 - Illuminate only blue led (using the full amount of power provided) PWM: 150 - illuminate blue led with 1/3 the power, and the red led with the remainder. Or if there's a better way to go about this, I'm all ears  Thx
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 4
Posts: 1131
If you're not living on the Edge, you're taking up too much space!
|
 |
« Reply #1 on: April 12, 2012, 04:22:02 pm » |
You could do this by changing the frequency, and some caps, OR
If you design the matching circuit for red only, not blue, the red will ignore short pulses and only light when they get much longer. In effect changing the color and the brightness together as you increase the duty cycle. You just need to choose an appropriate time constant. I will leave this as an exercise for the reader.
|
|
|
|
|
Logged
|
If you fall... I'll be there for you! -Floor
Skype Brighteyes3333 (262) 696-9619
|
|
|
|
Manchester (England England)
Online
Brattain Member
Karma: 276
Posts: 25494
Solder is electric glue
|
 |
« Reply #2 on: April 12, 2012, 04:27:17 pm » |
You could do this by changing the frequency, and some caps, Yes. But the problem is the peak current into the capacitors will exceed the maximum allowable current from the pin if you are not careful. Remember a discharged capacitor looks like a dead short when you put a logic high signal on it at first. However changing the duty cycle will have no effect on a capacitor's reactance.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 4
|
 |
« Reply #3 on: April 12, 2012, 11:49:40 pm » |
I did a little reading on the phases at the Arduino, and at the present time, way over my head. Trying to think of an easy alternative, and had one idea..
I've got a relay module, and if I understand right, the coil activates at ~3v. So, maybe it's possible to hook the relay up to just 1 color of the led, this way when the pwm output is at low power, the relay doesn't have enough power to trigger; but at full pwm power, the relay will trigger and both colors on the rgb led will fire, instead of 1.
Before I screw up something though, I should ask, would it be safe to try use the pwm for relay control in this way?
edit: guess that wont' work.. after looking more closely, the rgb led uses all negative leads for the colors, so I can't use the relay to control that, bummer.
|
|
|
|
« Last Edit: April 13, 2012, 12:21:01 am by corpse »
|
Logged
|
|
|
|
|
Manchester (England England)
Online
Brattain Member
Karma: 276
Posts: 25494
Solder is electric glue
|
 |
« Reply #4 on: April 13, 2012, 01:53:44 am » |
Yes that would work although you have to drive a relay through a transistor. rgb led uses all negative leads for the colors No problem, just connect the anode to +5V, the red cathode through a resistor to the PWM pin. Then connect the relay contacts to the green cathode via a resistor and the other contact to ground.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 4
|
 |
« Reply #5 on: April 13, 2012, 09:19:36 am » |
Yes that would work although you have to drive a relay through a transistor.
This is the path I'm going down http://www.csgnetwork.com/transistorcalc.htmlThis is my first time looking/trying to understand this schematic.. I entered values: VCC=5 R1=100 R2=500 I presume the connections mean (and how I'd use them in my scenario): VCC - 5v VB - pin 9 PWM VEE - GND VC - first led VE - second led As VB increases, once it hits almost 1v is when ve starts to output power (ie: to my second led) Is that kinda how that circuit works? If my understanding is more or less right, how do I know which transistor in this case to get when I head to radio shack?
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Online
Brattain Member
Karma: 276
Posts: 25494
Solder is electric glue
|
 |
« Reply #6 on: April 13, 2012, 11:20:02 am » |
That is not quite how you want to use it. R2 should be zero ohms, that is it should not be in the circuit, replace it with a short. R1 is your load, this is where the relay coil should go. You need a resistor from the base to your arduino PWM output. This will explain what PWM actually does. http://www.thebox.myzen.co.uk/Tutorial/PWM.htmlThis shows you how to wire up a relay:- http://www.thebox.myzen.co.uk/Workshop/Motors_1.htmlAny general purpose NPN transistor will do, I am assuming your relay doesn't take current, less that 100mA anyway. If it is more you need a transistor that can handle the current your relay requests.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #7 on: April 13, 2012, 10:35:59 pm » |
...would it be safe to try use the pwm for relay control in this way?
You'll want to use a capacitor to smooth out the voltage being applied to the relay coil. Otherwise, the sharp edges of the pulses will cause all sorts of transients on that pin. I wouldn't be surprised if it caused problems in other parts of the circuit as well. Depending on the current requirements of the relay, you may not be able to supply it directly from the pin, and would likely need a transistor as well.
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Online
Brattain Member
Karma: 276
Posts: 25494
Solder is electric glue
|
 |
« Reply #8 on: April 14, 2012, 02:00:20 am » |
You'll want to use a capacitor to smooth out the voltage being applied to the relay coil. Otherwise, the sharp edges of the pulses will cause all sorts of transients on that pin. No you don't, no it won't.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #9 on: April 14, 2012, 11:21:35 am » |
You'll want to use a capacitor to smooth out the voltage being applied to the relay coil. Otherwise, the sharp edges of the pulses will cause all sorts of transients on that pin. No you don't, no it won't. Mike, Are you saying that the rapid on-off of PWM on the relay coil won't cause inductive responses?
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Online
Brattain Member
Karma: 276
Posts: 25494
Solder is electric glue
|
 |
« Reply #10 on: April 14, 2012, 02:26:19 pm » |
I am saying it will not cause you trouble, there is no need to smooth it. The inductor has its own time constant, so current will not be switching as rapidly as you might think.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #11 on: April 14, 2012, 02:52:26 pm » |
Where things won't hurt, and may help, I generally prefer to do them unless there are extenuating circumstances.
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Online
Brattain Member
Karma: 276
Posts: 25494
Solder is electric glue
|
 |
« Reply #12 on: April 14, 2012, 03:20:44 pm » |
Where things won't hurt, and may help, I generally prefer to do them Yes but this will hurt and won't help. The output dissipation of the driver will increase when it is operated in the linear region.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #13 on: April 14, 2012, 04:04:53 pm » |
Then it comes down to whether the extra heat in the transistor or the noise generated are worse.
Honestly, at low levels, neither is likely to be a problem.
|
|
|
|
|
Logged
|
|
|
|
|
|