The circuit consists of the usual minimum requirements for a PIC (PIC18 dealt with here) that is, power supply, oscillator (external crystal oscillator - 40MHz) and In-circuit serial programming (ICSP).
Circuit Operation
A typical "wall-wart" power-supply is used (a surplus laptop charger in this case) in conjunction with a voltage regulator (LM7805) to provide the regulated 5V required by the PIC microcontroller and the WS2812.
The WS2812 was purchased (from ebay - Hong Kong supplier) already mounted with the necessary current limiting resistor and by-pass capacitor (see Photographs Section). This makes the electrical connections trivial, simply require 5V and 'ground', with a connection from the desired PIC output pin to the DIN pin of the WS2812.
Multiple WS2812 are connected by 'daisy-chaining' the Dout pin of a WS2812 to the Din pin of the next WS2812. Obviously all the WS2812 5V pins need to be connected together (and to Vdd) and similarily with the 'ground' pins.
Power Supply for WS2812
As previously stated, WS2812 require 5V and 'ground', with multiple WS2812 being wired in parallel. The datasheet states that an individual WS2812 typically requires 18.5mA. The test circuit involving five (5) daisy-chained WS2812 (see Schematic and Photographs Sections) was measured to consume 80mA when each of the WS2812 had at least one LED energised.
This means if a 'large number' of WS2812 are to be used simultaneously (and it is also anticipated that many of LED's will be energised simultaneously) a seperate power supply for the WS2812 may be required. For example, 50 x WS2812, all with at least one LED energised, could be expected to require ~1A.
Software/Firmware
There is a lot of information and code libraries for WS2812 and Arduino (1), not so much for PIC microcontrollers as such. The majority of the information appears to concern the 'strict timing requirements' of the non-standard communication protocol which results in a myriad approaches trying to adhere precisely to the datasheet.
However, as highlighted by some authors (2), (3) careful consideration of the timing diagrams shows that the 0-bit pulse width (max of 500 ns) is the only difficult constraint (in terms of cycle times available when using 'low' frequency PIC microcontrollers). This allows simple 'bit-banging' routines to be used to drive the WS2812, although relatively fast microcontroller oscillator frequencies are necessary. I've successfully used 20MHz and above with the relevant microcontroller (didn't try lower frequencies).
The background to the communication timing diagrams for the WS2812 and the bit-banging routines is discussed in the Testing/Experimental Results Section.
Only Logged-In Members can add comments