Go Down

Topic: TLC5940 LED fade coding not full brightness VS Tlc.set(1, 4095); (Read 177 times) previous topic - next topic

toxsickcity

Hi,

I am having troubles making a 2 Colour LED fade at full brigtness..
i am thinking its something to do with arduino having 1023 vs TLC having 4095 pwm levels?!

I have a arduino with ntc 10k thermal sensor and it controls lighting...

I had added some code to compare the real full brightness and appear to be half.

I am in the process of converting my code from MOSFET/Arduino to TLC.

at the moment the setColorVGA / redVGA, blueVGA are the parts of code in question.

cheers.

Code: [Select]
  if (tempVGA < COLDTEMP) tempVGA = COLDTEMP;
  if (tempVGA > HOTTEMP) tempVGA = HOTTEMP;


Code: [Select]
  redVGA = map(tempVGA, COLDTEMP, HOTTEMP, 255, 0);  // reverse 0, 255 for resistance use
  blueVGA = map(tempVGA, COLDTEMP, HOTTEMP, 0, 255);


Code: [Select]
void setColorVGA(int redVGA, int green, int blueVGA) {
#ifdef COMMON_ANODE
  redVGA = 255 - redVGA;
  blueVGA = 255 - blueVGA;
#endif
//  analogWrite(ledVGAR, redVGA);
//  analogWrite(ledVGAB, blueVGA);
Tlc.set(1, redVGA);
Tlc.update();//actually executes the pin states programmed above

Tlc.set(2, blueVGA);
Tlc.update();//actually executes the pin states programmed above

Qdeathstar

Hi, you should give us the smallest sketch that reproduces the problem.


Depending on the library you are using for the TLC5940, this looks wrong:

Tlc.set(1, redVGA);




redVGA should possibly be mapped to a value between 0 and 4095



https://www.arduino.cc/reference/en/language/functions/math/map/


TLCredVGA = map(redVGA, 0, 255, 0, 4095);

A creaking creeping shadow
stiff against the freezing fog
glares at a tickless watch.

Time has failed him -- all things shall pass.

Grumpy_Mike

Quote
i am thinking its something to do with arduino having 1023 vs TLC having 4095 pwm levels?!
Well yes but the Arduino's PWM has only 256 levels not 1023, you are mixing that up with the analogue read range.

Go Up