/ledctrl

A 16 channel WS2812 RGB LED controller

Primary LanguageCMIT LicenseMIT

ledctrl
This project is currently under development.

*** Hardware block diagram ***

        +---------------------------------------------------------+
        |           +---------+                                   |
+24V+-------------->+  5V/3A  |                                   |
        |           |step-down|                                   |
        |           +---------+    +----------------+             |
        |                          |  Raspberry Pi  |             |
+----+  |            +-------+     |      Zero      |             |
|LCD |  |            | level |     +----------------+             |   +----+
|1602+<-----------+->+shifter+<-+->+I2C|SPI|GPIO|USB+---------------->+Wifi|
+----+  |         |  +-------+  ^  +-----+--+--+----+             |   +----+
        |         |             |        ^  |  ^                  |
        |         |  +-------+  |        |  |  |                  |   +----+
        |         |  | RTC   |  |        |  |  +----------------------+rot |
        |         |  | DS3132+<-+        |  v reset               |   |knob|
        |         |  +-------+     +-----|-----+                  |   +----+
        |         |                |stm32|f103 |                  |
        |         |                |     v     |                  |
        |         |                |   +-+-+   |                  |
        |         |                |   |SPI|   |                  |
        |         |                |   +---+   |                  |
        |         |                |   |DMA|   |                  |
        |         |                |   +-+-+   |                  |
        |         |                |     v     |                  |
        |         |                +-----+-----+                  |
        |         |                |DMA|DMA|DMA|                  |
        |         |                +-----------+                  |
        |         |                |TIM|TIM|TIM|                  |
        |         |                +-----------+                  |
        |         |                |PORTB 16Bit|                  |
        |         |                +-----+-----+                  |
        |         |                      |                        |
        |         |i2c bus               | 16 bit parallel        |
        |         +-----+                +---------+              |
        |               |                          |              |
        |  +------------|--------------------------|-----------+  |
        |  |            |                    8 bit | 8 bit     |  |
        |  |       +----+----+                +----+----+      |  |
        |  |       v         v                v         v      |  |
        |  |   +---+---------+---+ enable  +--+---------+--+   |  |
        |  |   |PCF8574 |PCF8574 +-------->+74LS125|74LS125|   |  |
        |  |   |Expander|Expander|         |Buffer |Buffer |   |  |
        |  |   +---+---------+---+         +--+--------+---+   |  |
        |  |       | 8 bit   v 8 bit          v        |       |  |
        |  |       +-------->+                +<-------+       |  |
        |  |    16 channel   |                |  16 channel    |  |
        |  |    enable       |                |    led data    |  |
        |  |                 |                |                |  |
        |  +-----------------|----------------|----------------+  |
        |                    |                |          ledctrl  |
        |                    |                |                   |
        +--------------------|----------------|-------------------+
                             |                |     ledctrl_carrier
                             |                v
                             |            +---+----+
                             v            |opto    |
     16x                +----+----+       |coupler |
+24V+------------------>+16x      |       +---+----+
                        |isolated |       |   |    |      isolation
                        |relays   |       |   |    |        barrier
              ................................|....................
              .         |in groups|       |   v    |
          +---+----+ 5V |of 4     |       +---+----+
          |24V/5V  +--->+         |       | MAX481 |
+24V+---->+DC-DC   |    +----+----+       |   Tx   |
          |isolated|         |            +---+----+
          +---+----+         |            |   |    |
              .              |            |   v    |
              .              |   16x      | +-+--+ |16x
              .              +------------->+RJ45| |ledctrl_output
              .                  +24V     | |8p8c| |in groups of 4
              .                           +-+-+--+-+
              .                               | 16x patch cable
              .                               | RS485 Signal
              .                               | 24V Power
              .                               v
              .                     +-------+-+--+-----------+
              .                     | +24V  |RJ45|           |
              .                     |   +---+8p8c+-------+   |
              .                     |   |   +----+       |   |
              .                     |   v                v   |
              .                     +---+-----+  +5V  +--+---+
              .                     |  5V/3A  +------>+MAX481|16x
              .                     |step-down|       |  Rx  |ledctrl_driver
              .                     +---+-----+-------+--+---+
              .                         |                |
              .                      +5V|                |led data
              .                         |                |
              .                         |  +----------+  |
              .                         +->+  WS2812  +<-+
              .                            |LED-Stripe|
              .                            +----------+
              .                                     16x Stripes
              .                                     à ~50 LEDs

*** Software block diagram ***

+-----------------------------------+------------------------+
|  kernel space                     .         user space     |
|                                   .                        |
+----------------+                  .   +--------------------+
|  stm32led.ko   |                  .   |       server       |
|                |                  .   |                    |
+----+ +---------+  char dev        .   |          +---------+
|GPIO| |3*16*cols|  /dev/stm32led   .   |          |4*16*cols|
|pin | |  bytes  +<--------------------------------+  bytes  |
+--+-+ |  buffer |                  .   |          |  buffer |
|  |   +----+----+                  .   |          +----+----+
|  |        |    |                  .   |               ^    |
|  |        v    |    +---------+   .   +-------+       |    |
|  |   +----+----+    |port     |   .   | sysfs |   +---+----+
|  |   |remap RGB|    |expander +<------+ GPIO  +<--+JSON-RPC|
|  |   +----+----+    |GPIO pins|   .   |control|   | server |
|  |        |    |    +---+-----+   .   +-------+---+--------+  +------+
|  |        v    |        |         .                    ^   |  |remote|
|  |   +----+----+        |         .       socket port  +----->+client|
|  |   |spidev0.0|        |         .                    v   |  +------+
|  |   +----+----+        |         .                 +--+---+
|  |        |    |        |         .                 |local |
|  |        |    |        |         .                 |client|
+--|--------|----+--------|---------+-----------------+------+
   |        |             |                 Raspberry Pi Zero
   |        |             |                      PiCore Linux
   |reset   |spi data     | enable data
   v        v             |
  ++------+-+-+-------+   |
  |       |SPI|       |   v
  |       +---+       |
  |       |DMA|       |
  |       +-+-+       |
  |         |         |
  |         v         |
  |    +----+----+    |
  |    |3*16*cols|    |
  |    |  bytes  |    |
  |    |  buffer |    |
  |    +----+----+    |
  |         |         |
  |         v         |
  |   +-----+-----+   |
  |   |DMA|DMA|DMA|   |
  |   +-----------+   |
  |   |TIM|TIM|TIM|   |
  |   +-----------+   |
  |   |PORTB 16bit|   | STM32F103
  +---+-----+-----+---+
            |
            v
         led data


Credits:
http://www.cnblogs.com/shangdawei/p/4762035.html
https://github.com/hmng/jsonrpc-c