Tlc5940 Servo Issue

Hi,

I am using a Tlc5940 to drive a servo. I am using the tlc example servo sketch. The servo is sweeping back and forth however it is not moving from 0 to 180 like written in the code. Instead the servo is sweeping from what would be about 60 to about 120. I have no idea what would be causing this problem any help is appreciated.

Here is the code I am using:

/*
    This sketch sweeps a servo on channel 0.

    To connect a servo:
     1. Put a 2k-5k pull-up resistor (R0 below; I've tried with 3.3k) between the
          servo control output pin and +5v.
     2. Connect that same pin to the servo's control line like so

        servo data pin
              |     _____
     OUTn ----+----[_____]---+5v
                      R0

    Steve Pomeroy <steve ~AT~ staticfree.info>, 2009-01-20 */

#include "Tlc5940.h"
#include "tlc_servos.h"

#define SERVO_CHANNEL   0
#define DELAY_TIME      20

void setup()
{
  tlc_initServos();  // Note: this will drop the PWM freqency down to 50Hz.
}

void loop()
{
  for (int angle = 0; angle < 180; angle++) {
    tlc_setServo(SERVO_CHANNEL, angle);
    Tlc.update();
    delay(DELAY_TIME);
  }
  for (int angle = 180; angle >= 0; angle--) {
    tlc_setServo(SERVO_CHANNEL, angle);
    Tlc.update();
    delay(DELAY_TIME);
  }
}

Thank you,
Eddie

Servos use a time-based signal to control position. TLC5940 provides a PWM output that is generally a steady frequency with varying pulse width.

0-180 is 180 degrees, as is 60-240. So it would appear the TLC5940 frequency is not quite 20mS.

Turn your servo 60 degrees in its mount?

Hi thanks for the reply!
So Im a little confused... I changed the values from 0 to 180 to 60 to 240 now the servo goes from what appears to be position 0 degrees to 90 degrees. Do I need to do something else?

Take out the TLC5940 as the servo control signal source?

But I have 15 servos, I need the Tlc5940 to drive all of them eventually. Is there a way to do it with the tlc5940?

Do you have a multimeter with Frequency measurement? Or an oscilloscope? Or a logic analyzer?
Check the servo control signals, see if they're actually outputting 50 Hz.

Post a link to where you are getting the libraries from as well.

I dont have any of those. :stuck_out_tongue: Is there a way I can change the frequency in the code or check it or something?

I don't know without some tools.

How are you controlling the TLC5940 ?

What pwm output are you getting it to produce?

Post your code.

...R

Not all servos can go from 0 to 180.

Sounds like yours only goes about 90 degrees .

At the end of travel does the servo look (sound) like its straining?

Thread started off with travel from 60 to 240, so 180 degrees of travel certainly sounds achievable.

Have not seen where OP has said it goes 180 deg. . Only about 90 deg. .

@ OP

A simple setup ( tape the servo down and maybe use a straightened paper clip tied to the horn) to show where your servo horn is pointing while using the arduino servo library or zoomkat's servo program so to be able too see where the horn is pointing at a given value. Then using your TLC5940 see if the same inputs gives the same positions as documented previously.

justone:
A simple setup ( tape the servo down and maybe use a straightened paper clip tied to the horn) to show where your servo horn is pointing while using the arduino servo library or zoomkat's servo program so to be able too see where the horn is pointing at a given value. Then using your TLC5940 see if the same inputs gives the same positions as documented previously.

Excellent suggestion.

(OR why didn't I think of that)

...R