rainbowduino - VCC outputs

Hallo Seeeders,
once again I have some mysterious things going on and I need your kind help!

I’m trying to use the VCC pins 1-8, using digitalwrite and analogwrite,
to control some led group, about 3-4 leds for each VCC output.

I have 2 types of led, but each group have only same-kind:
BIG-> 3.2 volt // 100mA
NORMAL-> 3.4 // 20mA

Power supply gives 12v, 2A.

The code, a simple (0-255) fadein-fadeout analogwrite, works, but the led never get as brights as they should,
always remain very dim, about 1/3 of maximum brightness.

If I measure the VCC outputs I have:
-> about 2,5V when (analogwrite = 255)
-> about 1V when (analogwrite= 0)

I suppose this has something to do with the “resistor-free circuits” inside rainbowduino,
unfortunately I don’t really understand how to get higher voltage/amperage out.
Or may be related to the rainbowduino ATMEGA168 PWM implementation?

Should I access the pins directly using some BITSHIT code accessing the registers,
without the analogwrite functions of the arduino IDE?
I hope there’s an easier solution…

Another weird thing is that some leds fade smoothly, other just switch on/off,
but they receive the same analogwrite command! I suppose it’s caused by the “delay” interacting with PWM…

What am I doing wrong? :blush:

Thanks a lot for your help,
I’m getting crazy with this!
bless,
kk

Here’s the simple code I’m using:

void setup()			 
{

  for(int i = 10; i >=3; i --)
  {
    pinMode(i, OUTPUT);
  }
}

void loop()			
{
  for(int i = 3; i <=10; i ++)
    {
      fadeDown(i);
        delay(50);
    }
  
   for(int i = 10; i>=3; i --)
    {
      fadeUp(i);
      delay(50);

    }
} 

void fadeUp(int pin)
{
  for (int k = 255; k >= 0; k -= 5)
  {
    analogWrite(pin, k);
    delay(30);
  }
}


void fadeDown(int pin)
{
  for (int k = 0; k <= 255; k +=5)
  {
    analogWrite(pin, k);
    delay(30);
  }
}

Can I see your hardware schematic , how you connect your wire and LED.

But the your code cannot work as you wish, because the AnalgoRead function just can use the analog pins which is PC pins of 168, but it did not be layout for you and be used as the MBI5168 OE ,SD,CLK and LE pins. And the AnalogWrite function didnot meet the DigitalPin 0-13 , just D3 D5 D6 D9 D10 D11 can be used as hardware PWM pins.

8 VCC pins give out is PB and PD pins ,and in Arduino IDE function be used as digital pins. You can use the timer to control it as PWM , just like the demo code do .

-> The connections are really simple:
Led channels ( - ) : each channel to a VCC(0-8).
Led channels ( + ) : all to the VCC (+) green socket in the topright angle.

-> Ok, so I can only use DigitalWrite with timers to “act as” PWM, not AnalogWrite directly.
Something like this? http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1240496944
How should I modify the democode in Rainbow_bata to work with VCC???

Looking at the ATMEGA168 diagram, I suppose: PD pins are accessed via PORTD // PB pins via PORTB // PC pins via PORTC.

For future reference, I think we can say that it’s better to use the RGB pins to drive single leds.
If anyone would be so kind to explain a way to do it, I would appreciate very much!
(it’s not that I’m lazy, it’s my brain that really can’t reach those heights!!! :blush: )

Thanks for your support,
kk

Sorry for my mistake of the AnalogWrite explanation befor.

You can use the PD and PB some pins for PWM just use the analogwrite(pin,val); but not all the Digitalpins can be use in this function ,just D3 D5 D6 D9 D10 D11 can be used.

And the ranbowduino’s layout the D3 D4 D5 D6 D7 D8 D9 D10 for VCC pins , so you can use some of them directly.

Thanks FreeZinG, it makes sense now: VCC (7,4,3) cannot be analog written,
and that’s why some led groups just went ON/OFF, while some others were dimmed correctly.

The other half of the problem is that LEDs are never fully driven,
even when Analogwrite is (255) or DigitalWrite is (HIGH).
The same LEDs, connected to the RGB pins, are much brighter than when connected to the VCC pins.
Is there a workaround for this?

I’m still interested to know if anyone can sketch out some code to show
how to use the 24 Rainbo RGB pins to PWM 24 led channels.
I know it’s “electrically” possible, as I’ve tried to connect leds to some RGB pins and used the DispshowPicture function to randomly dim single leds, and it worked. But it’s like driving a car with your theets.
It would be nice to be able to address single RGB pins from Arduino sketches:
maybe you guys at seeedstudio feel like working on it?

Thanks a lot for your support,
kk

Hi kkkk,

The problem with the brightness is that you have the LEDs connected the wrong way. If you only want to use the VCC pins then you need to connect the LED + to the VCC pins and the LED - to ground (GND). However I don’t think the current will be limited in this configuration, because the constant current control is done by the constant current sinks on the RGB pins, so you may want to try it with a resistor in series first!

If you want to use the VCC pins exclusively then you need to ditch the Rainbow_bata code because it is using the VCC pins to multiplex, turning them on and off using a timed interrupt depending on what is on each row of the matrix. You need to just use digitalWrite on the VCC pins. The PWM example using a timer interrupt that you linked to would be OK, although it seems pretty complicated and there may be simpler versions around.

The alternative is to keep the Rainbowduino driver code and use the 15 levels of brightness that it provides by using software PWM. If I can get my Rainbowduino Carnival entry written up it documents controlling individual LEDs with the Rainbowduino driver code, but basically you just wire them up in a mini-matrix with the anodes (+) connected together in rows and connected to the VCC pins, and the cathodes (-) connected together in columns and connected to the RGB pins. It doesn’t matter if your LEDs aren’t physically strictly laid out in rows and columns, just wire them up as though they are.

Then in the software you put a dot in the matrix with the corresponding level of brightness where you want a LED to turn on. You can have dot patterns in Prefabnicatel and use DispShowPicture, or alter the characters in ASCII_Char and ASCII_Number to define patterns of dots and use DispShowChar.

Thanks Dave, I’ve understood more reading your answer than in the last month of tryouts!
I’ve connected the Led as you suggested and put some safety 100 Ohm resistors I had around after a group of 4 Leds, and they’re much brighter now.

I suppose I’ll wait for the carnival to learn a lot of things that I can’t figure out for myself,
as I can follow your thoughts about modifying the rainbow firmware,
but it’s way too complicated to try on my own.

Thank you indeed,
all the best,
kk