HIDE NAV

Lab 3 - RGB Strip One-Wire Driver

Creating a Device Driver Library for a strip of Addressable Memory Cell RGB Diode Pixels



Summary

Create a Reusable Code Library to Interface an RGB Strip with the RP2040 / Pi-Pico

I.  Create a male pin connector for the RGB strip by soldering.

II.  Determine the timings for 1, 0 and reset pulses according to the RGB pixel datasheet.
   Use an oscilloscope to test your pulse timings and ensure they are within the datasheet specifications
   Create functions for rgb_one_pulse(), rgb_zero_pulse and rgb_reset_pulse()
   Verify that your code works with a basic main program that sends one or more color codes by calling a 24 line sequence of rgb_one_pulse() or rgb_zero_pulse

.

III.  Create functions to automate the decoding of numbers into sequences of rgb_one_pulse(), rgb_zero_pulse as described below.
    Next create a function that takes in three values to send one entire pixel color.
    (See below for code examples)

IV.  Add a frame buffer as a 2D array of unsigned 8-bit with size 3 x L, where L is the length of your strip.
    Create a function to send the entire buffer.
    Create a function to calculate color gradient using a start and stop locations, as well as start and stop colors.
    Create a function to shift all values in the buffer to the next index. The last color value should 'loop' and replace the first color.
    (See below for code examples)



Equipment and Supplies

- Rasperry Pi Pico with Headers   pinout diagram

- RGB Strip of WS-2812 modules   Datasheet - WS2812B Intelligent control LED

- 3x1 male pin header strip

- Heatshrink Tubing & Hot-Melt Glue

- Stranded Wire (28-22 awg.)

- Bench Power Supply

- USB Micro Cable

- Breadboard

- Cables and 22 AWG Solid Core Wire for Breadboard Jumpers



Part I - Breadboard Connection Cable & Wiring

- Make a cable connector.

- If using a strip of length 30 (or less) LEDs, LED power connections Vdd (V+) and Vss (Gnd) can be obtained from USB cable using the Vsys pin.

- For longer strips, please supply LED strip Vdd directly from a dedicated power supply or battery. You can supply the Pico power to Vsys from that source as well.



Part II - One-Wire Bus Signals

Below is a set of C macros that will allow you to delay the cpu using No-Operation (NOP) instruction sequences with direct use of the Assembler.


...

#define NOP __asm volatile ("nop":);
#define NOP5 NOP NOP NOP NOP NOP
#define NOP10 NOP5 NOP5
#define NOP50 	NOP10	NOP10	NOP10	NOP10	NOP10

...