update notes for new implementation

This commit is contained in:
King Kévin 2015-07-18 20:15:35 +02:00
parent 640816fc38
commit 3c59bb74cf
1 changed files with 58 additions and 46 deletions

104
README
View File

@ -1,26 +1,20 @@
project
=======
The CuVoodoo AtmoLight mimics the Philips ambient lighting.
The idea it to have LED on the back to the screen shine one the side with the same color as the border colors displayed on the screen, creating and ambient light.
The CuVoodoo ScreenLight mimics the Philips ambient lighting.
The idea is to have LEDs on the back of the screen and light on the sides the same color as the border colors displayed on the screen, creating an ambient light.
recipe
======
To implement this I used:
- VLC with the included AtmoLight video filter to ouput the colors to be shown on the LEDs
- an Atmel ATMEga328P microcontroller at 16 MHz (i.e. Arduino Nano 3.0) to control the LEDs and show the values received from VLC over serial
- strips of WS2812B chains LEDs, individually controlled using a data line
- boblight to output over serial the colors to be shown on the LEDs
- an Atmel ATMEga328P microcontroller at 16 MHz (i.e. Arduino Nano 3.0) to control the LEDs and show the values received over serial
- A strips of WS2812B chained LEDs (i.e. BlinkyTape), individually controlled using a data line
The original AtmoLight offers only has 4 channels: top, bottom, left, right.
Each channel correspond to an LED strip, but all LED on the strip will show the same color.
The BlinkyTape LED strip offers 60 LEDs WS2812B LEDs.
The BlinkyTape LED strip offers 60 WS2812B LEDs.
To match the 16/9=1.78 aspect ratio of my screen I divided the LED strip in 19 LEDs for top and bottom, and 11 LEDs for the sides, for a close aspect ratio of 19/11=1.73.
Although the LEDs are individually controllable, they will have the same color per side.
To have a more fine grained ambient light VLC comes with several AtmoLight device types, such as fnordlicht, which offers more channels.
See the fnordlich branch for the corresponding implementation.
code
====
@ -31,7 +25,7 @@ This is the microcontroller (e.g. Arduino Nano 3.0) code.
Use `make` to compile and flash it.
`lib/uart.c` allows to talk over serial.
VLC will send the coloer values over USB, going to the serial UART.
boblight will send the color values over UART (e.g. USB).
`lib/ws2812b` allow to control WS2812B LED strips.
The data transmission is done implemented in assembly since it is time critical
@ -43,55 +37,73 @@ The LED strips are connected in parallel as follows:
- 08 LEDs on pin D6 (PD7) for the bottom second LED strip
- 11 LEDs on pin D7 (PD8) for the right LED strip
`main.c` will parse the UART input data for AtmoLight messages and set the LED colors on the strip.
It will use the AtmoLight channel color values to set the colors on the corresponding WS2812B LED strips.
`main.c` will parse the UART input data for AtmoLight messages and set the LED colors.
protocol
--------
To set LED colors send AtmoLight messages for the 60 RGB LEDs (aka. channels), at a baudrate of 115200 bps 8N1.
AtmoLight messages have the following format:
- fixed atmolight header: ff 00 00
- number of bytes: one byte (3 RGB * 60 LEDs)
- LED 0 color: 3 bytes (RGB)
- LED n color
- ...
other
-----
`test.rb` will connect to the microcontroller and run standard tests to see if all is working.
The easiest way to see what messages VLCs AtmoLight (AtmoLight device type) is sending, use 2 USB to UART converter with TX/RX interconnected.
VLC should use the first (ttyUSB0), and you get the data on the other (ttyUSB1).
To set the baurdaute: `stty -F /dev/ttyUSB1 38400`.
To get the data: `xxd -ps /dev/ttyUSB1 > dump.txt`
A summary for diffentes pictures is available in `vlc-atmolight-dump.txt`
alternatives
============
limitation
==========
Two other implementations are available in branches.
Don't forget to short the reset pin of the microcontroller with 5V to prevent reset when the serial port is open.
Else the firmware will miss the start of VLC's communication while booting.
This will automatically be corrected after some short time though since the firmware synchronises on the AtmoLight message header.
atmolight
---------
In the current WS2812B implementation setting an LED colors requires 36 us.
Thus setting 11 LEDs (left/right strips) requires 396 us, and 19 LEDs requires 684 us.
AtmoLight offers a simple solution, but only has 4 channels: top, bottom, left, right.
Each channel correspond to an LED strip, but all LED on the strip will show the same color.
This is a waste of the individually controllable WS2812B LEDs, but it works fine.
This implementation also uses the AtmoLight protocol, with a serial baudrate 38400 8N1.
The standard AtmoLight message offers 5 channels: summary, left, right, top, bottom
fnordlicht
----------
VLC supports other device type in the AtmoLight video filter, such as fnordlicht.
The device type fnordlicht allows to control up to 254 channels (RGB LEDs).
This fits better the WS2812B capabilities.
Sadly VLC only supports up to 16 channels per zone (top,left,bottom,right).
Thus this used 50 from the 60 LEDs (16+9+16+9).
And because of the slow baudrate (19200 bps) and expensive messages (15 bytes per LED) this only allows a refresh rate of 2 fps.
limitations
===========
The firmware might miss the first packet of the communication while booting.
But this will automatically be corrected after some short time though since the firmware synchronizes on the AtmoLight message header.
In the current WS2812B implementation setting an LED color requires 36 us.
Outputting the data to the WS2812B strips requires 48 us for a single LED on all pins/strips in parallel.
For 11 LEDs per strip it requires 348 us.
The AtmoLight protocol uses a baud rate of 38400 bps with 8N1 configuration.
Thus receiving one byte requires 1.0s/(38400bps/(8+1)bits) = 234 us.
Since the ATmega buffers one received byte while the next one is shifted in.
This leaves enough time to ouput WS2812B data, particularly since this code is not interruptable, without loosing an incoming byte.
This also leaves enough time set the color of 11 LEDs.
But this does not leave enough time for setting the color of 19 LEDs.
Thankfully the LED color setting code is interuptable.
The colors will be set, while new data is coming in and saved in the interrupt routine.
A buffer of 2 AtmoLight messages is thus enough to handle setting the LEDs and output the data.
I use AtmoLight protocol with a baud rate of 115200 bps 8N1.
Thus receiving one byte requires 1.0s/(115200bps/(8+1)bits) = 78 us.
This leaves enough time to set the colors of an LED.
But this does not leaves enough time to output the WS2812B data, particularly since this code is not interruptible.
Thus you should wait ~ 0.4 ms before sending a new AtmoLight message.
Else transmitted bytes will be lost, and the code will sync to the next message.
To set the color of all channels VLC sends a 19 bytes AtmoLight message.
Thus the AtmoLight refresh rate is 38400bps / (8+1)bits/byte / 19bytes/frame = 224 fps.
This is faster than any (almost) video frame rate.
Finally the VLC AtmoLight video filter module is only available in VLC <= 2.2.
This module has been removed for VLC 3.0.
The maximum refresh rate is 115200bps / (8+1)bits/byte / (4 header bytes + 3 bytes/LED * 60 LEDs) = 69 fps.
To avoid dropping AtmoLight messages prefer a refresh rate <= 60 fps.
links
=====
VLC AtmoLight video filter module README: https://github.com/videolan/vlc/blob/2.2.0-git/modules/video_filter/atmo/README.txt
VLC AtmoLight removal announcement (2015-05-10): https://mailman.videolan.org/pipermail/vlc-devel/2015-July/103679.html
VLC AtmoLight removal (2015-05-10): http://repo.or.cz/w/vlc.git/commit/6713041eebe0c4245de4f78dfeb5effecb797faf
VLC changelog: https://github.com/videolan/vlc/blob/master/NEWS
AtmoLight protocol: http://www.vdr-wiki.de/wiki/index.php/Atmo-plugin
WS2812B LEDs: http://www.world-semi.com/en/Driver/Lighting/WS2811/WS212B/
boblight: https://code.google.com/p/boblight/