Adafruit 16-Channel 12-bit PWM/Servo Shield library and RGB

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
champagne
 
Posts: 30
Joined: Mon Nov 17, 2014 1:11 pm

Adafruit 16-Channel 12-bit PWM/Servo Shield library and RGB

Post by champagne »

I just received my Adafruit 16-Channel 12-bit PWM/Servo Shield and I wanted to try to connect my first RGB light - note: I did not solder everything so things are a little loose but the shield is powered and my LEDs get power from an external source)

anyway, back to my question:
I'm using pwmtest example as a starting point and commented out wpm.setPWMFreq(1500) and in the loop I added the following code:
pwm.setPWM(0, 50, 1500); //my understanding is this will ramp the freq on pin 0 from 50 to 1500 and then back down?
pwm.setPWM(1, 4096, 0); //turn off G value
pwm.setPWM(2, 4096, 0); //turn off B value

the part I dont get is the 3 less are turned on! Any idea what I screwed up? I have 3 cables going out from the shield from pin 0,1,2 to RGB - ground and V+ are not connected to anything on the shield but I suppose that's totally fine

Any idea what I'm doing wrong? I'll dig more on trying to understand better the setPWM but the docs seems to say it should work, maybe I"m not understanding correctly how LEDs and PWM work...

anywhow, thanks in advance for any help/info you may have,

X

User avatar
adafruit_support_bill
 
Posts: 88136
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit 16-Channel 12-bit PWM/Servo Shield library and

Post by adafruit_support_bill »

note: I did not solder everything so things are a little loose
That is likely the source of your problems. Solder everything completely before continuing.
http://learn.adafruit.com/adafruit-guid ... -soldering

User avatar
champagne
 
Posts: 30
Joined: Mon Nov 17, 2014 1:11 pm

Re: Adafruit 16-Channel 12-bit PWM/Servo Shield library and

Post by champagne »

ah - you were right: soldering everything made things work better (I tried just soldering the PWM pins but this was not enough) I can now turn on and off the rgb lights one by one (I'm surprised a newbie like myself was able to do this but I have part of your soldering kit and use your tutorial!)

I have to say I'm not certain I understand how PWM works though so I'll have to dig more info on this (I"m still going throughhttp://arduino.cc/en/Tutorial/PWM trying to figure out a good value for LEDs - I suppose sending on values every 5ms is enough so the light always looks on?)

//pwm freq (aka max?) set to 500 - I suppose this means there is a signal sent every 1/500 s, aka every 2ms. (what should I use for LEDs?)

I can turn off the R/G/B with the following:
pwm.setPWM(rPin, 0, 0);

I can turn on on low with the following:
pwm.setPWM(15, 25, 0);
or
pwm.setPWM(15, 0, 25);

Now, looking at your library example (https://learn.adafruit.com/16-channel-p ... -reference) it's mentioned that "The following example will cause channel 15 to start low, go high around 25% into the pulse (tick 1024 out of 4096), transition back to low 75% into the pulse (tick 3072), and remain low for the last 25% of the pulse:
pwm.setPWM(15, 1024, 3072);

wouldn't the result be the same if I had:
pwm.setPWM(15, 0, 2048); //aka light is at 50%

Anyhow, I'm surprised I got so far so thanks again the help!

X

User avatar
adafruit_support_bill
 
Posts: 88136
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit 16-Channel 12-bit PWM/Servo Shield library and

Post by adafruit_support_bill »

I have to say I'm not certain I understand how PWM works though so I'll have to dig more info on this (I"m still going throughhttp://arduino.cc/en/Tutorial/PWM trying to figure out a good value for LEDs - I suppose sending on values every 5ms is enough so the light always looks on?)
Pulse Width Modulation (PWM) works by rapidly switching the output on and off at a set frequency. The width of the pulse determines the "duty cycle" between 0% and 100%.

When used with LEDs, you want the PWM freqency to be fast enough to avoid any obvious flicker. The perceived brightness of the LED will be roughly proportional to the duty cycle.
"The following example will cause channel 15 to start low, go high around 25% into the pulse (tick 1024 out of 4096), transition back to low 75% into the pulse (tick 3072), and remain low for the last 25% of the pulse:
pwm.setPWM(15, 1024, 3072);

wouldn't the result be the same if I had:
pwm.setPWM(15, 0, 2048); //aka light is at 50%
That is correct!

User avatar
champagne
 
Posts: 30
Joined: Mon Nov 17, 2014 1:11 pm

Re: Adafruit 16-Channel 12-bit PWM/Servo Shield library and

Post by champagne »

thanks for all the replies - "One last thing" I'm not understanding:
- if I setPin(r,10,0) and measure the current I get 0.48V
but if I do the same thing for g and b I get a different value (as shown in table) - My thought was I can modulate the 12V input between 0 and 4095 through the PWM pin for each R/G/B pin but I guess not?

here are a couple measurements I did:

Code: Select all

| PWM |  R (V) | G(V) | B(V) |
| 10  | 0.48   | 1.69 | 1.91 |
| 20  |        | 1.73 |      |
| 30  |        | 1.76 |      |
| 1000|        | 4.36 |      |
| 1500|        | 5.6  |      |
Each RGB pin is connected to a N Channel MOSFET as shown here https://learn.adafruit.com/assets/2692 and the spec for the LED is as follow:
Forward Voltage:R(DC 6-7V); G/B(DC 9-10V)
Forward Current:R/G/B:350mA

Measuring V for each pin I can figure out the max PWM I can assign to each color but there has to be a better to figure this out - any idea on how I can compute this? I'm trying to write some code so I can generate a the LED to output a specific color at a specific intensity... (oh yeah I need to buy some heat sink too at 1500 PWM the light gets super hot :-)

thanks!

User avatar
adafruit_support_bill
 
Posts: 88136
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit 16-Channel 12-bit PWM/Servo Shield library and

Post by adafruit_support_bill »

if I setPin(r,10,0) and measure the current I get 0.48V
Current is measured in amps. Looks like you are measuring voltage there.

With LEDs the current is what you want to control. If you exceed 350mA for too long, the LED will overheat and burn out.

User avatar
champagne
 
Posts: 30
Joined: Mon Nov 17, 2014 1:11 pm

Re: Adafruit 16-Channel 12-bit PWM/Servo Shield library and

Post by champagne »

Current is measured in amps. Looks like you are measuring voltage there
oups, sorry about that - yes Voltage.

k so to I need to figure out how much PWM I need to send for say Red (fwd at 7V) computing I then - are my assumptions correct:
- PWM at 1024 would mean sending a signal 25% of the time (so 3V?)
- power is 12V - so I=V/R (I'm using 200 because my understanding the 16-Channel Servo Driver has a 200ohms R on each PWM output)
- so I= (12-7)/200 = 25mA? what does the PWM at 1024 mean in that context? I'm getting only 25/4mA to the Red light?

that would mean the green light gets less current then if I use that logic so to get it just as bright as red I will need to PWM more...

You should probably add a "Buy me a beer" paypal button fyi at this point, I should probably sign up for EE 101 as well...

User avatar
adafruit_support_bill
 
Posts: 88136
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit 16-Channel 12-bit PWM/Servo Shield library and

Post by adafruit_support_bill »

- PWM at 1024 would mean sending a signal 25% of the time (so 3V?)
You need to be concerned about current, not voltage.
- power is 12V - so I=V/R (I'm using 200 because my understanding the 16-Channel Servo Driver has a 200ohms R on each PWM output)
The resistance on the PWM board is irrelevant. You are just using the PWM output to drive the MOSFET. That 200 ohms is not in series with your LEDs.
- so I= (12-7)/200 = 25mA? what does the PWM at 1024 mean in that context? I'm getting only 25/4mA to the Red light?
You need to either measure the current and keep our PWM duty cycle at a safe level, or add some current limiting resistors in series with your LEDs. Keep in mind that any resistors in series with the LEDs must be capable of dissipating enough power. With a 12v supply and 350mA, you will probably need 2W resistors for the red channel.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”