My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
FountVisualsResearch  
Updated Oct 27, 2013 by rijadsul...@gmail.com

Research

Features using the TLC5947

  • 24 Channels of Pulse Width Modulated RGB LEDs
  • 30mA Current Sink
  • 12-Bit Color Depth
  • Easy to Use SPI Interface
  • Operates from 3.0V to 5.5V
  • Easy Implementation
  • Several Coding Examples Available
  • Requires Only 4 Wire Connection

Circuit Diagram

Figure 1: TLC5947 Standard Application Wiring Diagram.

Block Diagram

SPI Protocol

The TLC5947 works with standard SPI mode 0 also known as microwire SPI. This means only a two wire connection is necessary. The SOUT pin on the TLC5847 does not output anything useful unless the user is chaining multiple drivers or you want to check the previous data sent. The SCLK pin of the TLC will be connected to the PIC’s SCL/SCK pin. The SIN pin of the TLC will be connected to the PIC’s SDO pin. Initially the BLANK line needs to be held HIGH, and the XLAT pin needs to be held LOW at boot up. When the serial data has been completely sent, the XLAT pin is pulsed to latch the serial data into the registers. When ready to turn the LEDs, on set BLANK to LOW.

Operation Timing

Figure 2 below shows the operation timing diagram. The first bit sent on the first clock cycle (GS23 11B) is for channel 24 bit 12. The next is channel 24 bit 11, then channel 24 bit 10 and so on until all 24 channels have been filled with 12 bit values. The clock stops and XLAT is set HIGH and BLANK is set LOW. After BLANK hits LOW the LEDs are turned on at their set PWM brightness. When the next value is ready to be sent, BLANK goes back to LOW and the process begins again. From what has been read, the initial GS0 0A bit is not necessary since the clock is not running.

Figure 3: TLC5947 SIN SCLK XLAT and BLANK Operation Timing Diagram.

LEDs Used

The LEDs being used are common anode RGB LEDs. Each diode typically pulls 20mA and can be pulsed up to 10kHz. The LEDs are diffused to cause the light to be evenly distributed. Using common anode LEDs is very important since the TLC5947 sinks current rather than sourcing it. These LEDs were found for $0.18 a piece.

Figure 4: RGB LED Schematic.

Driver Alternatives

A. NXP PCA9685: 16-channel, 12-bit PWM I2C-bus LED controller.

The PCA9685 is very similar to the TLC, with the exception that it only controls 16 channels and is I2C driven. Using I2C would be nearly as easy as using SPI. The PCA9685 can sink current up to 20mA and source up to 10mA per channel.

B. NXP 74HC595: 8-bit Serial to Parallel Shift Register.

This alternative is if we choose to not use PWM on the LEDs. This would allow us to simply turn on and off the LEDs. The 74HC595 only requires 3 wires for communication.

LED Alternatives

A. Use Surface Mound LEDs.

If our PCB design allows us to mount LEDs directly on the board, then surface mount LEDs may be a viable alternative. This is going to depend on which cup enclosure we choose. The LEDs would be 5060BRG4 5.5mm chip LEDs made by Yetda Industry. They pull a max of 30mA per LED.

B. Use Separate Through Hole Red, Green and Blue LEDs.

This would be an alternative used if the common anode RGB LEDs end up being too expensive. They would be a bit more cumbersome, but they would definitely be cheaper.

C. Use a Small Fog Machine and Lasers.

This alternative would be for the fountain only. It would require a bit more power, but the visuals would be unique and attractive.

Code

Description

The code block of the visuals features three functions. One function will set all LEDs to a color with a display style. Another function is solely for the cup, and it will cause LEDs to turn on radially around the rim of cup while the pour timer increases. The last function is similar to the previous but for the fount only. It will increase the brightness of the fount LEDs while the pouring timer increases on the fountain.

Pseudo Code

SPI Setup

The code below is an example of using SPI mode 0 on a PIC18. This code has not been adapted to work for the TLC5947 or the PIC our team plans on using. This is a general example of how SPI can be implemented.

#define USE_OR_MASKS
#include <p18cxxx.h>
#include "spi.h"

//-------------------------------Configuration setting ----------------------------------------------
/**
    * Oscillator is configured as HS
    * Fail safe monitor is enabled
    * watch dog timer is disabled
    * Extended instruction mode is disabled
    * oscillator switch over is enabled 
*/
#if defined(__18F4685)      //If the selected device if PIC18F4685, then apply below settings else user will have to set
#pragma config OSC=HS, FCMEN=ON, WDT=OFF, IESO=ON, XINST=OFF, LVP=OFF 
#endif

unsigned char SPI_Send[21] = "MICROCHIP_SPI_MASTER";
unsigned char SPI_Recv[21];

//****************** SPI MASTER *******************************
//**************************************************************

void main(void)
{
   unsigned char sync_mode=0;
   unsigned char bus_mode=0;
   unsigned char smp_phase=0;
   unsigned char w=0;   
   
   CloseSPI();                          // Turn off SPI modules  if was previosly on
     
//***********Configure SPI MASTER  module to transmit in master mode ************
   sync_mode = SPI_FOSC_64 ;   
   bus_mode = MODE_01;
   smp_phase = SMPMID;     
   OpenSPI(sync_mode,bus_mode,smp_phase );
   
//**********  WRITE INITIAL CHARECTER  ************************************
   while(WriteSPI(0xF5));               
//send initial charecter to use the same as flag at slave side and send it till successful transmision
   
//********** WRITE THE STRING TO SPI ***************************************
    putsSPI(SPI_Send);                  //send the string of data to be sent to slave

//********* Read the initial flag id **********************************************
    if( 0xF5 == ReadSPI() ) 
    {
        getsSPI(SPI_Recv,20);           //   read the string sent from slave
        SPI_Recv[20] = '\0' ;           //terminate the string with a null charecter    
    }
    
/* Turn off SPI module and clear IF bit */
   CloseSPI();

   while(1);                        //End of program
}

Visual Functions

The LED blocks for the cup and fount will have two functions: setLEDs and pourLEDs. The setLEDs function will take in a char array describing the type of display mode that will be used. It will also take in the colors being displayed on the LEDs. Due to power constraints, the LEDs will not run more than 100% of one color LED or a sum of 4096 bits. Luckily our visuals can all be displayed using standard red, blue or green colors. Below are examples of how the functions will be implemented.

void setLEDs( char *disp, char *color )
{
	if ( color.strcmp(“red”) )
		// set writeSPI array
		// use all red LEDs for disp
	if ( color.strcmp(“green”) )
		// set writeSPI array
		// use all green LEDs for disp
	if ( color.strcmp(“blue”) )
		// set writeSPI array
		// use all blue LEDs for disp
	if ( color.strcmp(“redgreen”) )
		// set writeSPI array
		// use all red and green LEDs for disp


	if ( disp.strcmp(“flash”) )
		// set writeSPI array
		// flash the LEDs at a certain speed
	if ( disp.strcmp(“fade”) )
		// set writeSPI array
		// fade in and out at the defined color
	if ( disp.strcmp(“solid”) )
		// set writeSPI array
		// solid LEDs at defined color

	writeSPI(writeSPIArray);
}

void pourLEDs( BYTE pourTime )
{
	// Turn on blue LEDs proportionally to pour timer.
}
Powered by Google Project Hosting