You are here

Let PSoC Brighten Your Holidays | Cypress Semiconductor

Let PSoC Brighten Your Holidays

If you have used microcontrollers as long as I have, you have most likely bit-banged a serial protocol a couple of times.  For those of you new to microcontrollers, bit-banging is when you write 1s and 0s to a GPIO port to simulate hardware you controller doesn't have.  It is almost always a pain, it takes excessive CPU cycles and is even worse if you are on the receiving end, like an I2C slave.  If anyone ever asks you to bit-bang an I2C slave, just say NO!  Just trust me on this one!

Anyway, it is impossible for your microcontroller to always have every serial interface that may come along.  For example, I read about a string of 50 Christmas lights that had red, green, and blue LEDs in each bulb and here comes the best part, each bulb is addressable.  Yes, you can control each individual bulb for color and intensity, four bits for each color (red, green, and blue) and 8 bits for intensity.  Of course the string of lights came with its own controller that could generate 12 different patterns, but I wanted to create my own patterns.  With a little Google searching I found that someone had already hacked the asynchronous protocol and bit-banged an IO port to control the lights with some microcontroller.  Nobody had actually created hardware to make this easier or less CPU intensive, you know why? Because nobody else used a PSoC3 or PSoC5 with their powerful UDBs!  Yes a PSoC3/5 can bit bang with the best of them, but why bother when you have extremely flexible hardware, plus bit banging is so 90's. 

The protocol was a 26-bit packet with one start and three stop bits. Each data bit was divided into three 10uS periods.  The first period is always low, the second period was low if the data was a 1 and high if the data bit was a 0 .  The last period is always high.  See images below for bit and packet formats.

 

The packet format is pretty straight forward with the address, brightness level and three colors packed into 26 bits.  See figure below.

I had a choice, be lazy and use a 32-bit wide shifter or use a single 8-bit wide shifter with a slightly more complicated state machine. The 32-bit wide implementation would be easier but would be a bit wasteful in hardware.  The 8-bit wide implementation would take a bit longer, but much more efficient. I choose to go with the 8-bit wide design.  One other nice feature in the UDBs, is that you can create two 4 byte FIFOs for data flowing into or out of an interface.  This turned out to be perfect since it took 4 bytes to transfer the full 26-bit packet.

The string of lights is 50 bulbs long and if you want to update all the bulbs at one time, it would take 200 bytes (50 bulbs * 4 bytes per packet). Since you don t want the processor to just sit and wait for an interface to move data, DMA is the perfect solution. This way I was able to update the entire string using DMA with almost no CPU overhead!  Where the other guys are wasting their CPU cycles toggling bits, the CPU in the PSoC could concentrate on generating cool interactive patterns, converting DMX commands to the light string format, or any other task.  What is even better, I could implement 8 of these interfaces in a single PSoC3 or PSoC5 at the same time.  

Making this interface into a PSoC Creator component, provides a way to setup all the hardware and DMA with a single start command as with all Creator components.  More APIs are added to generate cool lighting patters.  The video below is an example of version 1.0 controlling three strings of light on my house.

This second video shows four strings on the floor in our lunch room.

 

This third video demonstrates yet another use for the lights.

 

Just think of the possibilities interfacing a string of lights to anything that can be measured with a PSoC!

 

Here are a few other images of the actual box the string came in, the string that I modified, my interface board, and a close up view of one of the bulbs.

 

 

 

Stay tuned for an upcoming video with the details of what it took to make the lighting component and how easy it is to interface the string with the Cypress PSoC3 First Touch Kit.

Mark Hastings

Comments

kmmankad's picture

Great Stuff!
I'm still learning PSoC,so this is all really exciting.Infact,I was bit-banging a SensePath Bus protocol the other day,so this is inspiring to do better :-)

I'm curious as to which PSoC3 board that is.I'm actually in the process of building something similar,with a USB bootloader.(Kinda like the arduino,but an arduino on an overdose of steroids would be the right words,since its a PSoC3 :P )

kmmankad's picture

Great Stuff!
I'm still learning PSoC,so this is all really exciting.Infact,I was bit-banging a SensePath Bus protocol the other day,so this is inspiring to do better :-)

I'm curious as to which PSoC3 board that is.I'm actually in the process of building something similar,with a USB bootloader.(Kinda like the arduino,but an arduino on an overdose of steroids would be the right words,since its a PSoC3 :P )

kmmankad's picture

Great Stuff!

I'm still learning PSoC,so this is all really exciting.Infact,I was bit-banging a SensePath Bus protocol the other day,so this is inspiring to do better :-)

I'm curious as to which PSoC3 board that is in the pictures.I'm actually in the process of building something similar,with a USB bootloader.(Kinda like the arduino,but an arduino on an overdose of steroids would be the right words,since its a PSoC3 :P )

meh's picture

The board I used was a board that we used in house for another project but was no longer needed. One of the Cy8CKIT-003 FirstTouch Start Kits would work just fine. You can find the FirstTouch Kits at;
http://www.cypress.com/?rID=38235

GIL's picture

Hi ! very interesting !!
for my second version of 1/2 CNC milling machine, I used 4 FirstTouch. But the problem is no all pins are available. At the end I decided to develop a breakout board (general purpose board). I hope this Christmas finish to mount them !!

jordanss123 jordanss123's picture

fake yeezy boost 750 I appreciate such people conversing on such type of blogs.

 

 

ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.