Login / Signup

How to use a digital signal controller (DSC) to drive a high-brightness RGB LED for a pixel board 2/2

dsc rgb led

Software Implementation
The software was divided into simple modules that implement certain functionalities or features. This approach allows easier code migration to other controllers by making some software blocks hardware independent. For a lighting systems vendor, it can be important to have multiple hardware platforms using very similar software. The modular structure allows the software modules to be tested independently, making it easier to find bugs.

The application software is broken down into six different modules. Each module represents a C language source file and its corresponding header file. The hardware dependant, low-level routines that access the DSC peripherals, such as SCI (RS-485), ADC and PWM, are represented by different blocks on the diagram below. Control functions are implemented on the protocol manager and color manager files. Finally, the application manager calls these different control functions.

Implementing a modular high-brightness LED matrix

Application manager
The application manager’s main role is to call initialization functions and the different application tasks. Pseudo-code for the application manager is shown below:

//init DSC and peripherals
// …

Protocol manager
The protocol manager reads and interprets the data coming from the controller’s serial communication module. It decodes the messages received, and if the message is valid it may store parameters on memory or pass commands to the color manager task:

//Protocol State Machine
switch (state)
case Idle:
If SCI_buffer_flag != Empty
State = start_byte
case start_byte:
If SCI_buffer[data] == ‘@’
State = check_address
State = idle
//Other States …

Color manager
The color manager’s role is to constantly read the ADC inputs and perform calculations to determine if a PWM duty cycle change is required to match the desired color pattern. It also receives messages from the protocol manager to update the desired color to be lit. The algorithm used for color sensing is key IP and should be a high priority for the lighting application vendor. Movement routines and effects can be added in this layer.

Low-level functions
RS-485, PWM and ADC are three low-level functions that interface with I/O pins and DSC peripherals. They communicate with control algorithms by shared variables, updated on interrupt service routines.

RS485 interfaces with the SCI module and generates an interrupt every time a byte is received and stores the data in a buffer. When a protocol manager task is running, it checks the status of the buffer to output the data.

The ADC generates interrupts every time an analog-to-digital conversion is complete and stores the data in a buffer. It then requests a new ADC sample from a different channel -- Red, Green or Blue. By constantly swapping the channels, the ADC fills the three color buffers with ADC samples that will be filtered for color manager task usage.

Finally, the PWM sets the corresponding DSC PWM channel to the duty cycle calculated by the color manager task.

Testing the System
Four pixel board prototypes were built to test and validate the concept described in this article. They were connected together to build a small expandable matrix that was linked to a gateway board plugged into a PC through a USB cable. Software running on the PC used the USB interconnect to control the LEDs on the matrix. A video of this test can be viewed.

Figure 5 shows the test bench used.

bench test dsc rgb led

Keeping the right balance between cost and functionality is critical in high-performance lighting applications. Software and hardware must be planned and structured from the beginning to provide a growth path for the application and allow flexible customization so designs can be re-used among multiple platforms.

The selected protocols and algorithms are the heart of application and provide extra differentiation. Even a simple design for a basic lighting application may require higher performance characteristics so it can be scaled to meet more demanding needs.

Selecting the right controller for the application is an important step toward maintaining a sustainable design. In the example we have described here, Freescale’s MC56F8006 DSC, peripheral set and tools environment have successfully fulfilled the application’s needs. For a more in-depth treatise, Freescale’s application note, AN3815: Implementing a Modular High-Brightness RGB LED Network, can be downloaded from Freescale's website. It includes hardware and software overviews, schematics, gerber files, a full testing routine and much more.

By Renato Frias

Read also: How to use a digital signal controller (DSC) to drive a high-brightness RGB LED for a pixel board

If you want to know more about this Freescale product, please submit your request to Arrow Italy using this form.

NOTE: this form is valid ONLY for Companies or Customers based in Italy and working in the Italian area.

Who's online

There are currently 0 users and 8 guests online.

Recent comments