Neopixels and PIC microcontrollers

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
nombrandue
 
Posts: 6
Joined: Mon Oct 14, 2013 11:13 am

Neopixels and PIC microcontrollers

Post by nombrandue »

I have been working on a small project that involves both a PIC microcontroller and a few Neopixel rings, and have run out of idea's on what is going on with my project.

Neopixel hardware, three pieces, chained for a total of 43 pixels:
24 RBGW pixel Ring
12 RBGW pixel ring
Neopixel RBGW Jewel

PIC:
16F1825 (also have looked at using a 16F1509, as there is AN1606 on using the CLC peripheral to run the Neopixels, and an 18F4550 from other examples).

Everything is hooked up as per the Uberguide (shared ground, 470 Ohm resister inline between the MCU and the DIN line, 1000uF 53V capacitor between gnd and power on the Neopixels power rail), and somewhat works.

What I am seeing is, when sending 32 bits to the pixel, is one pixel lights up. Ok, so far so good, since each RBGW pixel expects 32 bits to set up the color. The next cycle of the main loop in the MCU, the pixel changes color. That isn't expected behavior, as I am just sending the same 4 bytes over and over again.

I am thinking it is something with my data modulation setup, but I am not 100% sure how to fix it, as I am not sure if I am just not sending the data fast enough ( I should, my pwm has a period of 1.25us) or if my send loop is too clunky and big for the timing constraints (It is in C, compiled with the XC8 compiler, free license).

Honestly, I would like the driver for the actual flipping of the MDBIT bit in the MDCON register in assembly, but I don't know assembly very well, and can't find much on how to work with the DSM in MPASM on the 16F line of MCU's. I also would like to know if there are any common problems anyone has run into when building a program to talk to the Neopixel products from a PIC microcontroller.

User avatar
astropolis
 
Posts: 6
Joined: Wed Nov 15, 2017 5:30 am

Re: Neopixels and PIC microcontrollers

Post by astropolis »

I have this working on a PIC18F1XK22 driving a 60-LED RGB strip. I haven't tried it on RGBW yet. I am driving by bitbanging one port bit from a VERY tight assembler loop which is called from a C suite compiled with the free version of XC8.

From what you are saying it seems that you only ever get to drive one pixel, which to me implies that you are triggering a reset condition before you get the data out for the second. If you have access to a scope see if your output is staying on zero for too long after the 32nd bit. You should see a zero time of around 400nS for a one bit or 800nS for a zero, if it goes over 1000 you may have problems.

The trick is to code very tightly, pay attention to the timings, and run the driver inner loop interrupts off.

This project is not quite finished, in its final form it will be a 2 inch square PCB with various connectors. It is all working with a hand-wired version on Veroboard, I am currently waiting for real PCBs to be etched. Once complete I plan to release the documentation and code.

User avatar
nombrandue
 
Posts: 6
Joined: Mon Oct 14, 2013 11:13 am

Re: Neopixels and PIC microcontrollers

Post by nombrandue »

I have been focusing on getting one pixel lit, in my current code attempt. I can write to all pixels on my string, but with varying results. My logic on that is, if I can get one pixel to illuminate, hold a steady color, and allow me to change the color without lighting up other LED's, or having the colors change beyond what I am trying to toggle, the I have communication clear. I am thinking that the timing is off on my current version, in terms of sending all 32 bits, which is causing my colors to drift through the RBGW gambit.

Reading the datasheet for the RBGW pixels, it looks like per cycle, you write the 32bit data to each pixel, and once all pixels are written to, you latch low for 80us (looks to be 50us with the RBG strings). The SK6812RGBW datasheet lists different timings from the RBG strings:
T0H: 0.3us +/-.15us
T0L: 0.9us +/-.15us
T1H: 0.6us +/-.15us
T1L: 0.6us +/-.15us
Trst: 80us

Figuring I have a pwm period of 1.25us, to send a 1, I need a pwm duty cycle of 50%, so it stays high for 60ns, and low for 60ns. Sending a 0 would be 30%, so I would need the pwm to be high for 30ns, low for 90ns.

My coding inspiration comes from a few posts on the Adafruit board, specifically related to the Madison's NeoClock, and from https://0x7d.com/2014/neopixel-clock/ which uses pwm. The URL's project confirmed my thoughts on writing to the CCP registers in order to toggle the 1 and 0 bit streams using two different duty cycles.

I am thinking, based on a lot of other projects using the PIC's, that I need to do the bit writing (in this case to the DSM module) in assembly, to ensure it moves as fast as the timings need. This should be interesting, to say the least, because which I can read it, to an extent, I have never used assembler in a project before.

User avatar
astropolis
 
Posts: 6
Joined: Wed Nov 15, 2017 5:30 am

Re: Neopixels and PIC microcontrollers

Post by astropolis »

Firstly I think that the RGBW should recognise the 33/67 and 67/33 duty cycles that the RGB uses, the numbers in the datasheet are a limiting case. Secondly I decided that I had to use assembler. It's not that difficult, particularly if you can see on a scope what you are generating.

My driver wouldn't work for you directly, because I'm using a 64MHz chip. I will be releasing it in due course.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”