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);
}
}
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?
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.
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.