TLC5940 driver for Servos

Introduction

The TLC5940 driver for Servos is used in conjunction with a 12 bit TLC5940 16-port extender to operate Servos with their specific frequency of 50Hz.


Driver Parameters

The TLC5940 driver for Servo control has six parameters that need to be configured:

GSCLK

This is the PWM frequency driven by the Builder Base. This pin can be connected to any pin on the Builder Base if pin is not already in use for something else.

XLAT

This is the register clock line which shifts the serial data once transmitted into the output registers which eventually set the pins to the desired output state. This pin can be connected to any pin on the Builder Base if pin is not already in use for something else.

BLANK

This line resets the grayscale clock after counted up to 4095. This pin can be connected to any pin on the Builder Base if pin is not already in use for something else.

SIN

This is the data line which transmits the serial data bits from the client to the extender chip. This pin can be connected to any pin on the Builder Base if pin is not already in use for something else.

SCLK 

This is the serial clock line which keeps the transmission of the serial data bits in sync. This pin can be connected to any pin on the Builder Base if pin is not already in use for something else.

Channel

This is the channel on the TLC5940 modulating the pulses for the Servos; enter a number between 0-15 to select the channel you want to connect to the Servo pulse pin.


Wiring

This is a pinout of the DIP version of the chip

More information regarding the chip can be found in its datasheet

The table regarding current limiting on the IREF pin can be seen here

 

Example

On the TLC5940 the GSLCK, XLAT,BLANK,SIN, and SCKL Pins are connected to the Builder Base via the GP0, GP1, GP2 GP3, and GP4 pins respectively. A channel of the TLC5940 is connected to the pulse pin of the Servo. We need to use a 2k pull up resistor because the TLC a current sink. We also use a 2k resistor on the IREF pin of the TLC to limit the current flowing into the TLC.

Breadboard 

Schematic 

Used Pins

Used Pins

Description

Used Pins

Description

 5V

The voltage level for the assembly

GND

The ground potential for the assembly

GP4 (can be any GP pin)

GSCLK - Grayscale clock line

GP2 (can be any GP pin)

XLAT - latch register line

GP3 (can be any GP pin)

BLANK - the reset for the grayscale counter

GP0 (can be any GP pin)

SIN - serial data line

GP1 (can be any GP pin)

SCLK - serial clock line


How to write an App

Navigate to the App Builder and create a new application. You can find the “Motor” code object under the “Hardware” Tab in the object drop down menu on the left, or you can also use the search bar.

 

 

 

 

 

Drag the “Motor” object onto the grid.

 

Next, under the interface tab, locate the switch, slider percent, and slider analog interface objects. Next, drag two of the switch objects, a slider percent object, and slider analog object onto the grid.

 

 

 

 

 

Finally, connect a switch object to each the clockwise and counter clockwise ports on the motor object, connect the slider percent object to the speed port, and the Slider Analog to the Joystick Axle. For the sake of organization, label each of the interface objects, and save your application.

 


How to create a firmware

Navigate to the Firmware Builder and create a new firmware file.

Click the “+ Add Hardware” button and listed under the “Actuators” tab find the “Motor” hardware option.

Give your device a name, and click “Add Device”

 

 

 

Next, select the “TLC5940” under the driver dropdown menu.

 

 

For this example we select:

  • GSCLK Pin: GP0

  • XLAT Pin: GP1

  • BLANK Pin: GP2

  • SIN Pin: GP3

  • SCLK Pin: GP4

  • DC 1 Pin: 1

  • DC 2 Pin: 2

 

 

 

You may now save your firmware file and upload it to one of your clients.

 

 

 


Supported Hardware

  • TLC5940

  • Servos

  • Other Actuators


Downloads

Apps

Firmware

Assets