GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - koalaByte/rasp-ws2812b: Controlling WS2812b LED's using Rust on the Raspberry Pi

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

20 Commits
20 Commits

Folders and files

NameName
Last commit message
Last commit date
assets
assets
 
 
examples
examples
 
 
src
src
 
 
.gitignore
.gitignore
 
 
Cargo.lock
Cargo.lock
 
 
Cargo.toml
Cargo.toml
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 

Repository files navigation

NB: This was an experiment, and should not actually be used as a method to communicate with the WS2812b

Rasp-WS2812b

Power WS2812b LEDs from your Raspberry Pi over SPI.

Blogpost

How it works?

The LEDs run with a scan frequency of no less than 400Hz, with a data transfer rate of 800kbps.

The traditional method of communication with the WS2812b is usually PWM. The duty cycle to send a single bit is:

Bit Time High Time Low Duty %
0 0.4us 0.85us 32%
1 0.8us 0.45us 64%

A visual of the protocol is below.

PWM LED (0): where
    on time  = 0.4us +/-150ns
    off time = 0.85us +/-150ns
    
Volts
    |    START                      END
    |    v                          v
    |    ----------
    |    |        |
    |    |        |
    |    |        |
    | ----        -------------------
    *-------------------------------- Time
    
PWM LED (1): where
   on time  = 0.8us +/-150ns
   off time = 0.45us +/-150ns
   
Volts
    |    START                      END
    |    v                          v
    |    ------------------
    |    |                |
    |    |                |
    |    |                |
    | ----                -----------
    *-------------------------------- Time

Looking at the above duty cycle lengths, we can approximate each time slice into another 3 periods, each 33% of the original wavelength in order to have constant high/low runs for the given period. This will allow us to continue using SPI, using a clock speed of approximately 3Mhz.

To interact over SPI, each traditional LED sequence (3 bytes, 8 bits per colour channel) needs to be converted to a 9 byte sequence (72 bits per colour channel) before being shifted over SPI. Each traditional PWM 'bit' gets turned into an equivalent 3 SPI bits, and the clock speed of the SPI interface set to achieve within the +/-150ns error margins.

With the traditional period broken into 3 time sections, each can be pulled high or low individually. We can therefore represent what would have been a PWM (1) with an SPI 110. And on the contrary, represent a PWM (0) with an SPI 100.

Example

An example of a Raspberry Pi controlling a flexible panel of WS2812b's:

(Mario) Image of Pixel Mario

License

Licensed under the GNU GPLv3.0

About

Controlling WS2812b LED's using Rust on the Raspberry Pi

blog.tomarrell.com/post/rust_and_leds

Resources

Readme
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.