NeoPixel (WS2811/12) component

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
MarkH_61
Employee
Employee
25 likes received 50 replies posted 25 replies posted

A while back I posted some projects using a component I created for the WS2811/12 RGB LED modules.  I have added some updates including supporting both the WS2811 and WS2812.  Attached is a PSoC Creator workspace that include two projects and the StripLights library.                      Project “P4_OneRing” controls a single ring of these LED modules.  The second project “P4_MultiRings”, allows you to string multiple rings together to make your own very cool string of circular lighted ornaments. 

   

We have a special Black Friday sale coming up this Friday to discount the PSoC 4 Pioneer Kit so you can make your own creation and afford to pick up some of these lights.

   


   

Happy Holidays.

   

Mark Hastings

66 Replies

Currently I did not write the component to be able to switch between LED types on the fly.  With a big enough part you may be able to instantiate two components, one for the RGB and the other for the RGBW parts, but I must admit I did not test that.  I will add it to my todo list.

Actually I have been thinking of changing the entire structure of the way the component works so that anything that you configure in the customizer can be configured at runtime.  It will slow down the draw/pixel functions somewhat, but will not impact the ISR overhead much.

Mark

Anonymous
Not applicable

I would love to be able to do that. I have my own drawing functions so I really don't need the api to do that stuff. Version 2.2 is working really well for me. I'm using the largest psoc4, but I'm using alot of the resources for my application, so I couldn't afford to run two instances. It would be really awesome to be able to select certain features at compile time that will be available at runtime. That way I can optimize the resource usage for my application while still having the flexibility that i need.

If I can help in any way, let me know.

0 Likes

I'm new to Psoc, was using Arduino to control the WS2812B's and was familiar in that environment. Now I have to put on my big boy pants and actually re-learn everything. I have everything loaded but am stuck on how to use the functions. I put the start() in the main void and a simple:

            for (int i =0;i<36; i++) {

               

        StripLights_1_Pixel(i,0,0xFFEE22);

            }

but nothing happens. Do you have a basic structure I could follow? Also interested in updating one pixel at a time and controlling the speed of when they update.

0 Likes

Hi,

I didn't test this library but I read through the API: perhaps you have to update the leds with the function Trigger(uint32 rst);

that is:

Striplights_Trigger(1) after drawing the colour and CyDelay(uint32 speed) for speed when needed.

0 Likes

I tried the Trigger function, there is something I'm not doing right and I can't figure it out. I can't get anything to display on the strip.

#include "project.h"

#include "StripLights.h"

int main(void)

{

    __enable_irq(); /* Enable global interrupts. */

    /* Enable CM4.  CY_CORTEX_M4_APPL_ADDR must be updated if CM4 memory layout is changed. */

    Cy_SysEnableCM4(CY_CORTEX_M4_APPL_ADDR);

    /* Place your initialization/startup code here (e.g. MyInst_Start()) */

StripLights_Start();

    for(;;)

    {

      StripLights_Pixel(1,0,0xff0000);

      StripLights_Trigger(1);

               

    }

}

0 Likes

what device are you using? what psoc and chip?

0 Likes

PSoC 63 CY8C6347BZI-BLD53

I tried adjusting settings for the output pin as well

out.PNG

0 Likes

Hi

not sure the library is compatible with your psoc device. Could you try psoc 4?

colour: try use StripLights_GREEN or another from COLORWHEEL define list in the library, also add extern const uint32 StripLights_CLUT[ ];

your Pixel function may have problem with colour formatting parameter I think.

Fausto

0 Likes

Oh I see, Mark Hastings is also giving you helpful suggestions.

0 Likes

theJaremi,

Two things that you may want to change.  The code 0xFF000000 won't turn on anything with the WS2812 since it only sends the least significant 24 bits.  So to turn full white with the WS2812, you would use 0x00FFFFFF.  Next, you may want to put a delay in your loop or use StripLights_TriggerWait() or StripLights_Ready() to make sure you are hitting them to fast.  The SK2812 do support 0xFF000000 because they have a forth, white LED in which case 0xFF000000 will turn on the white LED full on and the red, green and blue LEDs will be off. With the SK parts, 32 bits are sent for each device instead of just 24.

I haven't had time to release version 3.2 which will include PSoC6, which might be your problem right now.

Mark

0 Likes

The hex code I was sending was definitely part of it. I was eventually able to get it working.

Also, I'm still very new to psoc and there were a few basic things I was missing(interrupts on the right core for example). I used another members psoc6 version of your FunwithLeds but it is missing a bunch of the functions you stated. When do you think you will have your 3.2 version out? I'm assuming you do not get paid for this so I obviously understand you work on it in your spare time. There are still many things I need to learn in psoc creator and how to structure my code better. I have only used micro controllers for about 3 months with no prior experience so it has been a process

0 Likes

Hello Mark,

i try to use your library with tjhe PSoC6 Module CYBLE-416045-02.

If i connect a Pin to SO of the StripLights component, i will get the error " Pin guidance unavailable: Signal 'Net_2' is floating (not driven by anything)."

How to fix this error? Or is it a problem with PSoC6?

Regards,

Peter

0 Likes

Hello,

the library works for PSoC3, PSoC5 and PSoC4 series, it's likely that is a reason for that error.

0 Likes

I have yet to release a version of the driver that is PSoC6 compatible.  Perhaps during next weeks holiday I'll have some time to complete the next "PSoC6" compatible version.

Mark

Hi Mark,

did you already update StripLightsLib for the PSoC6?

I just got myself a CY8PROTO-063-BLE devboard with the CYBLE-416054-02 module and the PSoC6 is quite different from the PSoC4 that I used so far.

In this library I already created a schematic for the PSoC6 version, but there are still some compile errors because device.h and cytypes.h don't exist any more. So I replaced them by "project.h" and "syslib/cy_syslib.h" to fix that error.

But now I get two errors that I don't know how to fix: "'StripLights1_PERIOD' undeclared" and "'StripLights1_ISR' undeclared"

For the second I have a guess, that "CY_ISR" is not available in PSoC6, but how to fix?

Thanks for any help!

Andreas

0 Likes

I just found a good working solution for the PSoC6 here:

https://iotexpert.com/2019/01/08/psoc-6-dma-ws2812-leds/

It is not as nice as the library discussed here, but it uses DMA instead and I think it has great potential!

Maybe someone is also looking for something similar!

Have fun

Andreas

0 Likes

Perhaps people have realized this already, but I'm pretty sure the Verilog B_WS2811 PSoC component which is at the heart of the Pixel driver doesn't care if the strips contain WS2811/12 or SK2812 LED drivers. All the PSoC is doing is sending out a stream of bytes. It is only in the API that this becomes important since the stream of bytes sent out must match the number of bytes expected by each LED in the chain. Thus, simply by replacing parts of the API you can drive mixed WS2811/12 or SK2812 strips.

Hint:

uint32  StripLights_ledArray[StripLights_ARRAY_ROWS][StripLights_ARRAY_COLS];

becomes

uint8  StripLights_ledArray3[StripLights3_ARRAY_ROWS][StripLights3_ARRAY_COLS][3];

uint8  StripLights_ledArray4[StripLights4_ARRAY_ROWS][StripLights4_ARRAY_COLS][4];

or you could use arrays of color structs.

Clearly you have to set up your arrays to reflect your topology, but there is no need for two instances of the StripLights (B_WS2811) PSoC component to make this work.

This also provides more efficient memory usage when using 3 LED strips.

0 Likes

You are correct that the WS2811/12 don't care about how many of them are in the string.  After a reset period (low signal for > 50us) each chips takes the first 24 bits that it sees and doesn't send them on.  After it gets it's 24 bits, it lets all other bits pass right through.  So the second device never sees the first 24 bits, it thinks its the first one in the string.  So if you have a string of 5 WS2811/12 devices but send data for 100 or more, they don't care and will consume the data for the first 5 devices.  If you looked at the output of 5th (Last device), you would see data for only 95 devices (95 * 25 pulses).  Once they all see no pulses to 50us or more, the first device on the string will again consume the first 24 bits. 

There are some variations of the SK2812 that will take consume a 4-byte (32-bit) packet because it has an extra white LED (RGBW).  A string of these is more expensive, but I use them when I need more white light power.  You can get a string of those pretty warm at full power to the point it will make PLA get soft, but not melt.

Mark

0 Likes

It appears I did not make the point I intended to make. My point was, since it has been asked several times, is that you can drive strings with mixed WS2811/12 and SK2812 in a single project using a single instance  of the StripLights component, if you replace some (much) of the C API that is generated with a different implementation. In other words your Verilog B_WS2811 driver doesn't care what is in the LED chain. It actually shouldn't matter if WS2811/12 and SK2812 are strung together is a single chain or are fed by different outputs of the mux, as long as the string of bytes sent matches up with what will be consumed by each individual LED driver in the chain. I will edit my post to try and make this more clear.

0 Likes

Hi mark.

The links for me to be able to download the Lib and the examples are not working.
Could you provide the new link so we can download it?

thank you

0 Likes

Are these files still available ? the links don't seem to work.

 

Thanks

 

0 Likes
MaHi_2791116
Level 1
Level 1

Hi all I have a CY8C4247AZI-M485 on a CY8KIT-043 and managed to get this library to work fine.

Now (due to price constraints) I want to get this working on a CY8C4125AZI-S423 however when I go to compile it says that:

demux_v1_10 component is not compatible with the selected device and I also get the error CyControlReg_v1_80 is not compatible. Is there any way to get a neopixel working with this CY8C4125AZI-S423 ic?

I need to do this quickly (its for a competition) can anyone help?

thanks

0 Likes

This low end part has no UDBs in it to create a control register.

Regards, Dana.

0 Likes

Damn. Do you know how to do this via SPI? I'm thinking if I do SPI I can

bit bang the neopixel

I have added an SPI block and assigned the pin but I can't see what command

I need in the main.c file in order to get this running.

I assume SPI init and then SPI send data. What commands are these? Sorry

I'm new to cypress simis and psoc Creator so the learning curve is quite

high!

Thanks

On Sun, Nov 24, 2019, 7:09 AM DaKn_263916 <community-manager@cypress.com>

0 Likes

This shows SPI and DMA, makes me wonder if polling would suffice

vs the DMA which is not present on that low end part.

https://iotexpert.com/2019/01/08/psoc-6-dma-ws2812-leds/

Regards, Dana.

0 Likes

You can consider CY8C4246PVI-DS402.  It is a 28-SSOP package. Easy to build something with and it has the UDB array and a DMA.  Perfect for controlling lights.  I believe Mark's component should work.  I have not tested it yet.  It builds correctly.  But some testing is probably required.  -J

0 Likes
KyCl_4704321
Level 1
Level 1

is this component compatible at all with any of the psoc 4200 series?

0 Likes