News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

Strange WS2812 issues

Started by RGV250, Today at 01:33 AM

Previous topic - Next topic

RGV250

Hi,
I have been tearing my hair out with strange issues with the WS2812B.inc file.
I am not sure if this is all my problems but when i increase the length of the strip over 128 all sort of things happen. 128 is fine but 129 with no other code changes causes the issue.
In the 2 screenshots, The LED_OK shows a blue LED at position 128 but when I change WS2812B_Amount to 129 it puts it in position 0 where I expected it to be where the arrow is.
It could be a simulation issue but I can't tell yet as I have not got the hardware.

LED_OK.JPG
LED_NOK.JPG

I also found it caused problems under 40Mhz which is not a problem now as I am using 48Mhz. This was tested with an actual device as I had a 12 LED ring to try to get it working initially.

VSM and Positron files.
WS2812B_Strip_18F2550_2A.zip

Regards,
Bob

RGV250

Hi,
I think the issue is regarding the clock speed, I have just tried with an Amicus simulation at 64Mhz and it is stable. I am not sure why it seems fine up until that point but I just need to get a level shifter for the Amicus board when I get the actual LED ring.
This is what I hope to use it for, I saw this and thought it would make a nice clock, I know there are only 40 for the seconds but who cares, it will be just a rotating LED.

LED ring.JPG

Regards,
Bob

top204

#2
Hello Bob

I would recommend getting a PIC18F26K22 device for your tests on things using the Proteus simulator.

They are nice devices and operate at 64MHz (actually up to 80MHz), and run from 3.3 Volts or 5 Volts.

The other newer PIC18F devices are not as reliable in the simulator.

If you are using the original Amicus18 board, see the small solder jumper for making the board run from 3.3 volts or 5 volts. Cut the original track, and make a new solder track for 5 volt operation. Or get one of the Amicus8 development boards, that have a 2mm jumper on them for 3.3 volt or 5 volt operation. They are really nice boards to work with, and are pin for pin compatible with my original Amicus18 board.

Also, if the clock is not operating as expected, open the WS2812B.inc file and see the block of code:

$if _xtal = 64                                      ' Are we using a 64MHz oscillator?
    Symbol cWS2812B_Zero = 6                        ' Amount of cycles for a zero delay (approx 350ns)
    Symbol cWS2812B_One  = 16                       ' Amount of cycles for a one delay (approx 900ns)
$elseif _xtal = 48                                  ' Are we using a 48MHz oscillator?
    Symbol cWS2812B_Zero = 4                        ' Amount of cycles for a zero delay (approx 350ns)
    Symbol cWS2812B_One  = 10                       ' Amount of cycles for a one delay (approx 900ns)
$elseif _xtal = 40                                  ' Are we using a 40MHz oscillator?
    Symbol cWS2812B_Zero = 3                        ' Amount of cycles for a zero delay (approx 350ns)
    Symbol cWS2812B_One  = 9                        ' Amount of cycles for a one delay (approx 900ns)
$elseif _xtal = 32                                  ' Are we using a 32MHz oscillator?
    Symbol cWS2812B_Zero = 2                        ' Amount of cycles for a zero delay (approx 350ns)
    Symbol cWS2812B_One  = 7                        ' Amount of cycles for a one delay (approx 900ns)
$elseif _xtal = 16                                  ' Are we using a 32MHz oscillator?
    Symbol cWS2812B_Zero = 0                        ' Amount of cycles for a zero delay (approx 350ns)
    Symbol cWS2812B_One  = 2                        ' Amount of cycles for a one delay (approx 900ns)
$elseif _xtal = 12                                  ' Are we using a 12MHz oscillator?
    Symbol cWS2812B_Zero = 0                        ' Amount of cycles for a zero delay (approx 350ns)
    Symbol cWS2812B_One  = 1                        ' Amount of cycles for a one delay (approx 900ns)
$else
    $error "12MHz, 16MHz, 32MHZ, 40MHz, 48MHz and 64MHz oscillators suitable for this code"
$endif


Change the values a little, for the cWS2812B_Zero and cWS2812B_One pulses, and see which values work better at 40MHz or 48MHz. It will be tiny changes, by 1 or 2 cycles, so do not change the values too high. The WS2812B devices operate on fast async pulses.

Regards
Les

RGV250

Hi Les,
I am trying to use up devices I already have, I really ought to bin the 16C84's :)
Originally I tried an 18F2680 at 16Mhz with John's Amicus8 board and a 12 LED ring. This was a problem as it was erratic, I did try to tweak those values but could I not get it to work reliably. I then decided to use the 18F2550 at 48Mhz with internal xtal and that seemed OK with the original 12 LED ring so put it down to the speed. They were the only devices I could find that ran at 5v, I then needed more LED's so that is when I tried the VSM, it seemed to be fine up until the 128 LED point and then all sorts of strange things were happening.
Anyway, at 64Mhz it is working exactly as planned and I am just waiting for the actual hardware.
The next step is figuring out if it is possible to use the fading "Knight rider" code just for the seconds as they will step on at approx 0.67 seconds so should look quite good.

Regards,
Bob
 

top204

#4
The KIT (knight rider) scanner code I wrote for the WS2812B devices, should look good as the seconds move around.

Also, why not make the LEDs slightly flicker in the dark, as if they are flames.

Regards
Les

RGV250

Hi Les,
Not sure about flickering but they probably do need dimming at night. Code is looking much better now than over the weekend and my sanity recovering. The only problem is I have a week to wait until I get the ring.

Bob

charliecoutas

I'm had trouble using WS2812 when interrupts happened. It threw the timing out of course, but it took me a while to find it. Good luck Bob.

Charlie