RGB LCD Shield - PWM control?

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
alberth
 
Posts: 7
Joined: Wed Apr 11, 2012 11:56 am

RGB LCD Shield - PWM control?

Post by alberth »

I haven't gotten to messing around with the shield (or better yet, assembling it!), but I've poked around in the code. And as your site says, you can't change the RGB precisely - you can only choose certain values. (I'm drooling at this video because just because of that precise control: http://www.youtube.com/watch?v=8ZDXuR6EIi4)

That said, is there any way software-wise I could do that? If not, since I haven't assembled it yet - is there any way I could modify it to enable PWM control?

Finally, are you guys planning to offer a new version of your shield that would enable PWM control? (And maybe, just maybe, could I exchange this old one for the new version if you do have a new one? :D)

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

Re: RGB LCD Shield - PWM control?

Post by adafruit_support_bill »

You can do PWM on the RGB by running jumpers from the RG & B cathodes to 3 unused PWM pins.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: RGB LCD Shield - PWM control?

Post by adafruit »

we have a USB/Serial backpack for the LCDs that can do full PWM control

User avatar
alberth
 
Posts: 7
Joined: Wed Apr 11, 2012 11:56 am

Re: RGB LCD Shield - PWM control?

Post by alberth »

adafruit_support: Which side is the cathode side? The PCB has no markings for this. Also, since you did say to connect it to the unused PWM pins, would it be possible to simply solder wires to three of the header pins? (Hence no wire connecting - I like the small profile of shields.)

adafruit: I've looked on your site and have searched many times, but it seems that you only offer the USB/Serial backpack inside the pack. I think I'll stick with the PWM connection solution for now.

Another product question: Will you guys offer a shield kit for the bigger 20x4 RGB LCDs anytime soon? (Again, I love the small profile of shields!)

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

Re: RGB LCD Shield - PWM control?

Post by adafruit_support_bill »

would it be possible to simply solder wires to three of the header pins?
That is the easiest way. They are pins 16, 17 & 18 as shown on this diagram.

User avatar
alberth
 
Posts: 7
Joined: Wed Apr 11, 2012 11:56 am

Re: RGB LCD Shield - PWM control?

Post by alberth »

I've soldered little metal "jumpers" from LCD pins 16, 17, and 18 to the top of the shield header pins 6, 5, and 3, respectively. I tried to then write PWM values from 0-255 to those pins at the same time (that is, 255 to pins 6, 5, 3) and I get a weird redish/blueish color instead of white. (Using the regular library to set the backlight to white works.)

Here's my dumbed down code to test the backlight setting. Note that I've removed any references to your library to prevent any initialization on the LCD that may prevent this from working.

Code: Select all

// Test for the RGB backlight control via PWM

int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

void setup() {
  // Debugging output
  Serial.begin(9600);
  
  // Init backlight PWM outputs!
  pinMode(3, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  
  // Oddly enough, 0 = full brightness
  analogWrite(3, 0); 
  analogWrite(5, 0); 
  analogWrite(6, 0);
  Serial.println("Displaying full brightness (white)");
  delay(2000);
}

void loop() {
  analogWrite(3, brightness); 
  analogWrite(5, brightness); 
  analogWrite(6, brightness); 
  Serial.print("Setting overall brightness to ");
  Serial.println(brightness);
  
  brightness = brightness + fadeAmount;
  
  if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount ; 
  }
  
  delay(30);
}
Is this a software problem or a hardware one?

User avatar
alberth
 
Posts: 7
Joined: Wed Apr 11, 2012 11:56 am

Re: RGB LCD Shield - PWM control?

Post by alberth »

I should also mention that I found out that setting it to 0 makes it display full brightness, not 255, as indicated in a code comment.

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

Re: RGB LCD Shield - PWM control?

Post by adafruit_support_bill »

If you connect to the PWM pins you have to cut the RGB connections to the shield.

User avatar
alberth
 
Posts: 7
Joined: Wed Apr 11, 2012 11:56 am

Re: RGB LCD Shield - PWM control?

Post by alberth »

Oh... So I can't use them simultaneously? I really like the feature (or non-feature) of having the LCD on when the Arduino is resetting...

Is there any way, with software or hardware modification, I can use both PWM and the shield's control of the LED backlight?

If not, do I disconnect the RGB connections by removing the resistor?
Also, is there any way of maintaining the backlight color through resets and such, like with the current shield?

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

Re: RGB LCD Shield - PWM control?

Post by adafruit_support_bill »

Is there any way, with software or hardware modification, I can use both PWM and the shield's control of the LED backlight?
It is probably possible to modify the library to set those pins on the i2c port expander to input mode when you want to use PWM pins. And when you want to use the shield backlight control, you could do the same for the PWM pins.

User avatar
alberth
 
Posts: 7
Joined: Wed Apr 11, 2012 11:56 am

Re: RGB LCD Shield - PWM control?

Post by alberth »

Actually, I don't think that test code I've used touches the I/O expander at all. From looking at the library code, you must call lcd.begin() to make it start working.
The I2C expander doesn't even start until that is called.

That said, I also added this bit of code into Adafruit_RGBLCDShield.cpp (and the prototypes in its header):

Code: Select all

/* ADDED COMMANDS FOR ENABLING/DISABLING i2c BACKLIGHT CONTROL
 * (in favor of PWM control)
 */
void Adafruit_RGBLCDShield::enableBacklight()
{
  _i2c.pinMode(8, OUTPUT);
  _i2c.pinMode(6, OUTPUT);
  _i2c.pinMode(7, OUTPUT);
}

void Adafruit_RGBLCDShield::disableBacklight()
{
  _i2c.pinMode(8, INPUT);
  _i2c.pinMode(6, INPUT);
  _i2c.pinMode(7, INPUT);
}
I call lcd.disableBacklight() to set those pins to INPUT, but it still fails.
It still gives me a redish/pinkish hue with high brightness.

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

Re: RGB LCD Shield - PWM control?

Post by adafruit_support_bill »

a redish/pinkish hue with high brightness.
You might try reducing the PWM cycle on the Red line - or add a ~100 ohm resistor in series. The red led is more efficient than the blue or green and tends to overpower them.

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

Return to “Arduino Shields from Adafruit”