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