TLC5940 PWM frequency

1,511 views
Skip to first unread message

Maik Becker

unread,
Dec 26, 2013, 9:11:09 AM12/26/13
to tlc5940...@googlegroups.com
Hello

Is it possible to set a PWM frequency to 25kHz? I have connected a High Power LED driver to a TLC5940 and I get a buzz when dimmimg LEDs. 

I tried editing the config file of the library and changed TLC_PWM_PERIOD to 320 and TLC_GSCLK_PERIOD to 0
but dimming the LEDs doesn't work anymore. 

best regards

Alex Leone

unread,
Dec 26, 2013, 1:54:41 PM12/26/13
to Maik Becker, tlc5940...@googlegroups.com
Hi Maik,

GSCLK pulses 4096 times per pwm period, so I think 25kHz is too fast (it would require a 100MHz GSCLK!).  You could try doubling the frequency to 2000Hz:

#define TLC_GSCLK_PERIOD 1
#define TLC_PWM_PERIOD 4096


--
You received this message because you are subscribed to the Google Groups "tlc5940arduino" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tlc5940arduin...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Maik Becker

unread,
Dec 27, 2013, 9:49:35 AM12/27/13
to tlc5940...@googlegroups.com, Maik Becker
Hi Alex

Thanks for your answer. So 25kHz ist not possible? What is the highest frequency I can configure? I will try 2kHz but doesn't think that would help.
Does changing the frequency affect the steps I can do? So maybe doubling the frequency means 4096 step become 2048 steps?

P.S. I'm using the Arduino MEGA 2560 which works at 16MHz so it wouldn't be possible?




Alex Leone

unread,
Dec 27, 2013, 3:24:05 PM12/27/13
to Maik Becker, tlc5940...@googlegroups.com
Changing the frequency doesn't change the number of steps, as long as GSCLK is 4096 times more than the frequency of BLANK (the pwm period).

You could change the number of steps for a faster frequency - for example, if you can live with 256 steps (Tlc.set with values 0-255), you could do 31.25kHz pwm:

#define TLC_GSCLK_PERIOD 1
#define TLC_PWM_PERIOD 512


Maik Becker

unread,
Dec 28, 2013, 7:26:56 AM12/28/13
to tlc5940...@googlegroups.com, Maik Becker
Thank you very much! that helps me a lot. I think I can live with 256 steps. Well I have to try it. But one thing I don't understand:
How do you calculate these values? I tried to calculate them with the formulas in your documentation but I didn't found a connection between the steps and TLC_GSCLK_PERIOD or TLC_PWM_PERIOD 

Maik Becker

unread,
Jan 12, 2014, 1:06:04 PM1/12/14
to tlc5940...@googlegroups.com, Maik Becker
Hi Alex

Can you explain more about how to set PWM frequency over 20KHz?
Does it mean I have to set 

#define TLC_GSCLK_PERIOD 1
#define TLC_PWM_PERIOD 512

to get a frequency of 31.25KHz? What about the steps? I'm using a high current LED driver on the Outputs of the TLC5940 with a pull-up resistor to get a 5V signal. Because of that the Output values are inverted. 4095 is full off an 0 is full on of the LEDs. So how can I use only 256 steps?

Clive Carey

unread,
Jan 18, 2014, 2:49:18 AM1/18/14
to tlc5940...@googlegroups.com, Maik Becker
Hi Maik,

I too need a high PWM frequency as I am driving a series of motors - ideally 60Khz. Did you manage to sort your problem out?

Incidentally I have also been looking at using an external signal for the GSCLK as described here:-


Regards,

Clive 

Maik Becker

unread,
Jan 24, 2014, 10:12:22 AM1/24/14
to tlc5940...@googlegroups.com
Now I got it working with 31.25KHz but it's not a good solution for me. 

With these settings I get a frequency of 15.62KHz but with max. 256 steps:
#define TLC_GSCLK_PERIOD 1
#define TLC_PWM_PERIOD 512

With these settings I get a frequency of 31.25KHz but max. 128 steps:
#define TLC_GSCLK_PERIOD 1
#define TLC_PWM_PERIOD 256

128 steps is not much so I need another solution. Is it only nessasary to give a higher frequency to GSCLK pin to get it work with more than 20KHz PWM frequency and still have 4096 steps?

Clive

unread,
Jan 24, 2014, 10:23:34 AM1/24/14
to Maik Becker, tlc5940...@googlegroups.com
Check the link I posted. It provides 256 levels at a frequency of 39KHz. 


--
You received this message because you are subscribed to a topic in the Google Groups "tlc5940arduino" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tlc5940arduino/iAxjRo8g7Zc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tlc5940arduin...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
_________________________________
         Burton House Holiday Let
            www.burtonhouse.info
In the heart of the Yorkshire Riviera :o)
             Like us on Facebook 
_________________________________

8bar

unread,
Feb 28, 2014, 9:36:37 AM2/28/14
to tlc5940...@googlegroups.com, Maik Becker
Hi Alex,

Using the formula f(PWM) = f(osc)/(2 * TLC_PWM_PERIOD) and f(OSC)=16MHz, wouldn't TLC_PWM_PERIOD=512 give 15.625 kHz instead of 31.25 kHz?

Also, wouldn't that make TLC_GSCLK_PERIOD = 3 using TLC_GSCLK_PERIOD = ((2 * TLC_PWM_PERIOD)/256 - 1) ?

It seems like it should be TLC_PWM_PERIOD = 256 and TLC_GSCLK_PERIOD = 1 for 31.25 kHz and 256 brightness levels. What am I missing?

Scott

8bar

unread,
Mar 1, 2014, 10:56:02 AM3/1/14
to tlc5940...@googlegroups.com
To follow up, Maik Becker responded:

Hi Scott
Yes you are right. I have measured the frequency with setting TLC_PWM_PERIOD = 256 and TLC_GSCLK_PERIOD = 1
And get 31.25KHz. But with this setting I only have 128 steps.

Maik

It isn't clear why there would only be 128 steps instead of 256. Any insight from anyone?
Scott

8bar

unread,
Mar 16, 2014, 9:27:17 AM3/16/14
to tlc5940...@googlegroups.com
Can anyone tell me what the range of values I can assign to TLC_PWM_PERIOD and TLC_GSCLK_PERIOD are? I want to slow the PWM frequency way down.
Scott

Nirav Gadhia

unread,
Aug 5, 2015, 12:12:12 AM8/5/15
to tlc5940arduino
Dear Friend,

As you have worked on TLC with arduino. 
I am working on project which control the multiple servos by TLC5940nt PWM driver with arduino uno board.
I have written the code as per requirement of rotation but I have found that the servo is rotating almost half of its given angle.
If I have written the 90 degree to rotate the servo then it rotate just half of it means approx 45 degree.
I dont understand that why it happens so???

Plz suggest me if you have any idea regarding this.

Thank you,
Nirav

Nirav Gadhia

unread,
Aug 5, 2015, 12:12:31 AM8/5/15
to tlc5940arduino, maikbec...@googlemail.com
Dear Friend,

As you have worked on TLC with arduino. 
I am working on project which control the multiple servos by TLC5940nt PWM driver with arduino uno board.
I have written the code as per requirement of rotation but I have found that the servo is rotating almost half of its given angle.
If I have written the 90 degree to rotate the servo then it rotate just half of it means approx 45 degree.
I dont understand that why it happens so???

Plz suggest me if you have any idea regarding this.

Thank you,
Nirav


Reply all
Reply to author
Forward
0 new messages