Help with LED Lamp concept.

kculm:

strykeroz:

kculm:
On the at85 I use 3,Red 0,Green 1,Blue.

Shuffle that red over to D4 and I think you'll have a better result. The tiny core doesn't give you hardware PWM control on D3 so the effect of analogWrite() will be a harsh cut-over from OFF to ON.

Cheers ! Geoff

Thanks Geoff, But I have a question. The diagram http://www.akafugu.jp/images/microcontroller-reference-sheet.png it show PIN 3 as PWM. am I missing something as usual

thanks

it is. It's just not usable as one in the Arduino IDE. use 4 and you'll be fine.

kculm:
Thanks Geoff, But I have a question. The diagram http://www.akafugu.jp/images/microcontroller-reference-sheet.png it show PIN 3 as PWM. am I missing something as usual

There's a hardware limitation: Pin 3 can only output the inverse of pin 4, pin 4 is the 'true' signal.

fungus:

kculm:
Thanks Geoff, But I have a question. The diagram http://www.akafugu.jp/images/microcontroller-reference-sheet.png it show PIN 3 as PWM. am I missing something as usual

There's a hardware limitation: Pin 3 can only output the inverse of pin 4, pin 4 is the 'true' signal.

While that's strictly true for the datasheet, in reply #38 of this thread on ATTiny85 and PWM Coding Badly explained that the inverted PWM output can't be used by the Arduino cores for ATTiny. My own testing confirms this gotcha - that D3 is not able to use hardware PWM with the arduino-tiny core. Software PWM like the tone() function works fine on all 5 of the standard ATTiny85 IO pins though, so there's an easy way around this limitation if you must use that leg.

Cheers ! Geoff

kculm:
I have one last issue, When I run it with out transistors on the Arduino it works smooth. But when I use 3, PNP transistors it works fine up until the Green to Blue transition. It almost dims out completely then flicker to blue.

You know the PWM is working so it has to be a power supply problem. You probably need some decoupling. Add ceramic capacitors between ground and 5V next to the transistors (as close as you can), see if that helps.

strykeroz:

fungus:
There's a hardware limitation: Pin 3 can only output the inverse of pin 4, pin 4 is the 'true' signal.

While that's strictly true for the datasheet, in reply #38 of this thread on ATTiny85 and PWM Coding Badly explained that the inverted PWM output can't be used by the Arduino cores for ATTiny. My own testing confirms this gotcha - that D3 is not able to use hardware PWM with the arduino-tiny core. Software PWM like the tone() function works fine on all 5 of the standard ATTiny85 IO pins though, so there's an easy way around this limitation if you must use that leg.

I don't know how the cores use the timers. I know that using hardware PWM on D3 and D4 at the same time wouldn't work for analogueWrite() functions.

fungus:

kculm:
I have one last issue, When I run it with out transistors on the Arduino it works smooth. But when I use 3, PNP transistors it works fine up until the Green to Blue transition. It almost dims out completely then flicker to blue.

You know the PWM is working so it has to be a power supply problem. You probably need some decoupling. Add ceramic capacitors between ground and 5V next to the transistors (as close as you can), see if that helps.

Thanks I will give that a try when I get home tonight. But so I am clear. I need to put a Cap from a Ground pin on the Arduino to the emitter on the PNP // Or is it from the Ground real to the 5v real.

And what size Cap.. ( Way to much to learn, I am glad it is fun).

Thanks

kculm:
Thanks I will give that a try when I get home tonight. But so I am clear. I need to put a Cap from a Ground pin on the Arduino to the emitter on the PNP // Or is it from the Ground real to the 5v real.

Between ground (any ground) and the 5V power line as close to the PNP as possible (touching it is good).

kculm:
And what size Cap.. ( Way to much to learn, I am glad it is fun).

0.1 ... 0.22 uF, that sort of size, but only ceramic type.

fungus:

kculm:
Thanks I will give that a try when I get home tonight. But so I am clear. I need to put a Cap from a Ground pin on the Arduino to the emitter on the PNP // Or is it from the Ground real to the 5v real.

Between ground (any ground) and the 5V power line as close to the PNP as possible (touching it is good).

kculm:
And what size Cap.. ( Way to much to learn, I am glad it is fun).

0.1 ... 0.22 uF, that sort of size, but only ceramic type.

I am using 3 transistors, so I am thinking one for each?

Also I cant thank you guys enough, I am learning so much.

kculm:
I am using 3 transistors, so I am thinking one for each?

At least! :slight_smile:

fungus:

kculm:
I am using 3 transistors, so I am thinking one for each?

At least! :slight_smile:

Did not help,

it works fine with out transistors. not as bright. and it only jacks up on the full blue to full green and full green to full blue.

kculm:
it works fine with out transistors. not as bright.

Has to be a power problem...how many mA are you using, how many are available.

kculm:
and it only jacks up on the full blue to full green and full green to full blue.

ie. At maximum current.

fungus:

kculm:
it works fine with out transistors. not as bright.

Has to be a power problem...how many mA are you using, how many are available.

kculm:
and it only jacks up on the full blue to full green and full green to full blue.

ie. At maximum current.

Right now I am testing it on an Arduino uno.

This is what I get. With out transistors it works fine. With Transistors is when I get the bule to green, green to blue issues.

If I use an at85 with out Transistors Is all jacked up, but with transistors I have the same issue as with Using the Arduino.

I have found another sketch but its not as nice, and I hate to just give up.

The green fades almost to nothing and the blue jumps on, if that helps any

kculm:
I have found another sketch but its not as nice, and I hate to just give up.

I can't see your circuit from here, unfortunately. Can you draw it?

fungus:

kculm:
I have found another sketch but its not as nice, and I hate to just give up.

I can't see your circuit from here, unfortunately. Can you draw it?

LED-Lamp1.jpg

If you back this down to just one RGB LED for simplicity, does it work smoothly on the ATTiny setup?

strykeroz:
If you back this down to just one RGB LED for simplicity, does it work smoothly on the ATTiny setup?

Same Effect .

Excellent. Then can you post the current version of the code here? We have to be close to sorting this now...

strykeroz:
Excellent. Then can you post the current version of the code here? We have to be close to sorting this now...

This is what I am using. Pretty Much the same. I just changed the Following.

#define MAX_RGB_VALUE 245 // no bigger than 255. (it was 255)

Works OK. just not a Rich

/*
 RGB LED - Automatic Smooth Color Cycling

 Marco Colli
 April 2012 
 Uses the properties of the RGB Colour Cube
 The RGB colour space can be viewed as a cube of colour. If we assume a cube of dimension 1, then the 
 coordinates of the vertices for the cubve will range from (0,0,0) to (1,1,1) (all black to all white).
 The transitions between each vertex will be a smooth colour flow and we can exploit this by using the 
 path coordinates as the LED transition effect. 
*/
// Output pins for PWM
#define  R_PIN  4  // Red LED
#define  G_PIN  0  // Green LED
#define  B_PIN  1  // Blue LED

// Constants for readability are better than magic numbers
// Used to adjust the limits for the LED, especially if it has a lower ON threshold
#define  MIN_RGB_VALUE  10   // no smaller than 0. 
#define  MAX_RGB_VALUE  245  // no bigger than 255.

// Slowing things down we need ...
#define  TRANSITION_DELAY  70   // in milliseconds, between individual light changes
#define  WAIT_DELAY        500 // in milliseconds, at the end of each traverse
//
// Total traversal time is ((MAX_RGB_VALUE - MIN_RGB_VALUE) * TRANSITION_DELAY) + WAIT_DELAY
// eg, ((255-0)*70)+500 = 18350ms = 18.35s

// Structure to contain a 3D coordinate
typedef struct
{
  byte  x, y, z;
} coord;

static coord  v; // the current rgb coordinates (colour) being displayed

/*
 Vertices of a cube
      
    C+----------+G
    /|        / |
  B+---------+F |
   | |       |  |    y   
   |D+-------|--+H   ^  7 z
   |/        | /     | /
  A+---------+E      +--->x

*/
const coord vertex[] = 
{
 //x  y  z      name
  {0, 0, 0}, // A or 0
  {0, 1, 0}, // B or 1
  {0, 1, 1}, // C or 2
  {0, 0, 1}, // D or 3
  {1, 0, 0}, // E or 4
  {1, 1, 0}, // F or 5
  {1, 1, 1}, // G or 6
  {1, 0, 1}  // H or 7
};

/*
 A list of vertex numbers encoded 2 per byte.
 Hex digits are used as vertices 0-7 fit nicely (3 bits 000-111) and have the same visual
 representation as decimal, so bytes 0x12, 0x34 ... should be interpreted as vertex 1 to 
 v2 to v3 to v4 (ie, one continuous path B to C to D to E).
*/
const byte path[] =
{
  0x01, 0x23, 0x76, 0x54, 0x03, 0x21, 0x56, 0x74,  // trace the edges
  0x13, 0x64, 0x16, 0x02, 0x75, 0x24, 0x35, 0x17, 0x25, 0x70,  // do the diagonals
};

#define  MAX_PATH_SIZE  (sizeof(path)/sizeof(path[0]))  // size of the array

void setup()
{
  pinMode(R_PIN, OUTPUT);   // sets the pins as output
  pinMode(G_PIN, OUTPUT);  
  pinMode(B_PIN, OUTPUT);
}

void traverse(int dx, int dy, int dz)
// Move along the colour line from where we are to the next vertex of the cube.
// The transition is achieved by applying the 'delta' value to the coordinate.
// By definition all the coordinates will complete the transition at the same 
// time as we only have one loop index.
{
  if ((dx == 0) && (dy == 0) && (dz == 0))   // no point looping if we are staying in the same spot!
    return;
    
  for (int i = 0; i < MAX_RGB_VALUE-MIN_RGB_VALUE; i++, v.x += dx, v.y += dy, v.z += dz)
  {
    // set the colour in the LED
    analogWrite(R_PIN, v.x);
    analogWrite(G_PIN, v.y);
    analogWrite(B_PIN, v.z);
    
    delay(TRANSITION_DELAY);  // wait fot the transition delay
  }

  delay(WAIT_DELAY);          // give it an extra rest at the end of the traverse
}

void loop()
{
  int    v1, v2=0;    // the new vertex and the previous one

  // initialise the place we start from as the first vertex in the array
  v.x = (vertex[v2].x ? MAX_RGB_VALUE : MIN_RGB_VALUE);
  v.y = (vertex[v2].y ? MAX_RGB_VALUE : MIN_RGB_VALUE);
  v.z = (vertex[v2].z ? MAX_RGB_VALUE : MIN_RGB_VALUE);

  // Now just loop through the path, traversing from one point to the next
  for (int i = 0; i < 2*MAX_PATH_SIZE; i++)
  {
    // !! loop index is double what the path index is as it is a nybble index !!
    v1 = v2;
    if (i&1)  // odd number is the second element and ...
      v2 = path[i>>1] & 0xf;  // ... the bottom nybble (index /2) or ...
    else      // ... even number is the first element and ...
      v2 = path[i>>1] >> 4;  // ... the top nybble
      
    traverse(vertex[v2].x-vertex[v1].x, 
             vertex[v2].y-vertex[v1].y, 
             vertex[v2].z-vertex[v1].z);
  }
}

Ok, I think I see the problem.

With PNP transistors the output will be inverted, ie. The LEDs switch on when the Arduino pin is LOW. This is the opposite of when you connect it directly.

Try changing all your analogWrite(X,Y) to analogWrite(X,255-Y).