Such as detecting the color scheme of a strip of leds WS2801 «Soloelectronicos

Ambilight is a technology designed to improve the visual experience analyzing the incoming signals and producing an environmental sidelight to the content that is being displayed on the screen a very attractive result, which in addition to the feeling of seeing one even bigger screen.» Until recently you could get this effect only if we bought a TV that counted with that system and there was no other option, but r recently with the appearance of plates with sufficient computing capacity, can emulate software from Hyperion running on a Raspberry Pi connected to a strip of leds WS2801. While this type of strips used the same chip not all use the same color sequence, which means that if you connect it to a Raspberry Pi and not adjust this parameter the effect will not be as realistic as the software changed colors…

 strip leds.png

addressable RGB led strips based on chip ws2801 (LEDs WS2801) are the most common for all types of assemblies where it is necessary to address a set of RGB leds with very few threads, which in the case of the WS2801 are only two ” : clock and data line, plus clear feed which is 5V DC.

there are strips based on the chips WS2801 in format “ Christmas lights” with physical cables which are joining each plate made by the own chip ws2801, RGB led and of course the associated electronics, but more common, is to acquire the whole in the form of self-adhesive tape circuits then others. For example, this (which can be purchased at Amazon for less than € 27 ). A peculiarity of this strip ws2801, is that it can be cut according to the length required, as well as in addition that it is also possible to enlarge connectors that carry at each end, and can join between them where needed.

an important aspect is that to feed the strips also need apart power supply dimensioned to the number of leds you are going to acquire (e.g. for 50 leds can be a source of 5v and 2A)

but to emulate the ambilight effect the most common is to use a Raspberry Pi (como vimos en este post ) e s possible that the effect produced is not successful basically because the default setup of our strip of leds is not setting “normal” which is the RGB combination

to find out that RGB combination is the one used in our strip of leds, it is best that we connect this to an Arduino board one or similar (if we do not have any available at Amazon for less than € 10 )  ws2801

usually a led WS2801  only 4 have connections, that we can do so for the purpose of pruebas(máximo 2 leds):

  • Green cable from the SD pin of the strip of leds to pin 11 of the Arduino Uno.
  • red wire from CK pin of the strip of leds to the pin 13 of the Arduino Uno.
  • black wire from GND pin the strip of leds to GND pin of the Arduino Uno.
  • the blue wire coming from the pin + 5V from the strip of leds to connect it to the connection + 5v Arduino

is tell the way to connect one or two leds WS2801 to a serious Arduino as follows:

 leds arduino

highlight that circuit that we propose is to test one or two leds RGB type WS2801 as normally vérios led Strip should be powered externally outside the line of + 5V for 5V Arduino, as not to do so could result in damage to qu plate controller that connect, unless we are only going to try one or at most two leds where if we can connect directly to the 5v from our Arduino like mass or earth which also connect to the mass of Arduino.

test of a strip of LEDS of more than two LEDS

in case of not having a led individal should not perform the above scheme because we could burn our Arduino, instead, connect the strip of leds by a side to a 5V source /2amp.   and on the other to Arduino, by one of the ends according to the usual scheme:

 arduino.png

as discussed in this blog, in the case of using a strip of leds must be careful because that connects the three wires to Arduino in one of the ends of the strip of leds (the left side of the Strip). As opposite wires are loose at each end (usually the Red wire is the positive and blue negative) will also connect these to give food to the strip of leds (although it could also be made by Strip connections that produce energy since they have 5V in 4 connections).

SOFTWARE in the ARDUINO

to test the RGB combination will connect a modudo to an Arduino which will be also ‘bridge’ between the host computer and based on WS2801 Strip. LED data is transmitted, and are not stored in buffer, which means that if there are more Arduino code may generate delays due to limited of the Arduino, but despite RAM e l algorithm puts some effort to avoid losses from buffer

WS2801 closure, delay-based protocol It could inadvertently trigger if the USB or the CPU bus is overwhelmed with other tasks. This code caches incoming data series and introduces breaks intentional if there is a threat of premature filled buffer.

the cost of this complexity is something that reduces the performance, but the gain is very good for avoiding the majority of Visual bugs even though finally a USB bus and host CPU load function, is beyond control.

if we don’t have it, download the software of arduino (arduino official page) and install it.

connect the arduino one to your pc with the usb cable. If you ask for the drivers, you can find in the folder arduino-1.0.4drivers.

download this library: fastled library download which we import to the Arduino IDE.

now touch upload the sketch to which descaremos the Adalight code for the lights here

Descomprimiremos file and add the files you just downloaded from carptea my documents / Arduino and ng

pluck the arduino software and configure the IDE the Arduino board tools – > plate Arduino Uno (or plate that we have)   without forgetting the port of communications

go File > Sketchbook > Arduino > Adalight and uan time loaded the sketch must adjust the number of leds (can the number of leds for this test) have on the installation as well as the maximum speed (500000)

#define NUM_LEDS 88 / / Max LED count
#define LED_PIN 11 / / arduino pin output – probably not required for WS2801
#define GROUND_ PIN 10 / / probably not required for WS2801
#define BRIGHTNESS 255 / / maximum brightness SPEED
#define 500000 / / virtual serial port speed, must be the same in boblight_config

now we can already compile the software (first button that puts a v check).

 adalight. PNG

if there was no errors now can climb the sw by pressing the button Upload( flechita a la derecha en el software de Arduino.[)

contrary to what happens with the sketch LedlIght where the 3 red lights are illuminated, green and blue if all has gone well, if we have connected the leds to the arduino and the external source, when we load this code within the single Arduino look the first led of the chain which will mean that we are on track.

 IMG_20170221_170329.jpg

within Arduino code is non-volatile, so it will not clear even if you disconnect the card.

Sw on PC

once we have the sw of Adalight on Arduino, touch install the capture program that sends signals to our Arduino

between the program ambibox is the best especially with 10 windows, since it not only has the ability to capture your desktop but put a customizable background convert the Strip in lany psychedelic depending on the audio, automatic variable background, plugins, etc

can be found here both software and the add-on for XBMC.

once downloaded, during installation you can select the complete installation option, marking also the option of downloading and installing playclaw.

start the configuration, click on the button of more settings:

 more

at the bottom, as como vemos we see Select Device like Adalight will choose the communications port (to which East connected the Arduino) and in the number of areas, we coloremos the number of total leds that you have installed (in the example 88).

order of the sequence of colors

need to figure out the order of colors, which we can test by setting a color by using the Mode selector ( Static Background) by clicking on the color (displayed in the palette) by clicking on the check Use backlight (to activate the power of the Strip to the color selected) and finally selecting in combo order of colors combination to the tira(o muestra) that we have  :

 combinations

order of colors there are 6 possible options: RGB and RBG, BRG, BGR, GRB GBR of which he must go by selecting one by one and by clicking on the color palette a number of significant colors until the color of the leds is similar to the palette and will the combination of order of our Strip leds.

if we do not want to try all the color palette an idea is to use the primary colors (red, green and blue) to check if it corresponds the color palette selected with the combination of lit leds.

in the above example you can see how the selected green combination corresponds to the leds illuminated in Green: IMG_20170507_090930  

</p data-recalc-dims=

” />

a very common combination, strange that seems, to many economic led strips is BGR

once we know which is the right combination of his strip of leds WS2801 If it is to be used in a Raspberry Pi with Hyperion software, if you have configured configuration file hyperion.config.json have to edit it and copy it to the Raspberry PI directory /storage/.config (do not confuse with the path /storage/hyperion/configuration /)

 hyperion .]

what must change in the hyperion.config.json is part primary on the header “device” whose configuration contains the following fields:

  • name’: user name (used for display purposes only)
  • ‘type’: the type of device or leds (known by now types are ‘ws2801’ (, ‘ldp8806’, ‘ ‘lpd6803’, ‘sedu’, ‘adalight’, ‘lightpack’, ‘test’ and ‘none’)
  • output : the output specification depends on the selected device. This can be, for example, the specifier of device, serial number of the device, or the name of the output file
  • rate’: the baudrate of the output to the device
  • colorOrder’: is here the qeu parameter we are interested because it specifies the order of the bytes of color (‘rgb’, ‘rbg’, ‘bgr’, etc.). It is very important to note that if we do not adjust this value can change the edge of colors . For example many pull are the t type BGR, which means that if we dial default RGB Red will change in all displays by blue and biceversa

example of configuration of the device section corresponding to the previous post:

“device”: {
“colorOrder”: “bgr”
“rate”} {: 500000,
“type”: “ws2801”,
“name”: “MyPi”,
“output”: “/dev/spidev0.0”
},

in addition to cmbiar the order of colors also can manipulate the configuration of color manipulation used to adjust output colors to a specific environment.
The configuration contains a list of transformations of color. Each transform contains the following fields:

  • ‘id’: the unique identifier of the transformation of color (e.g.. ‘Device_1’)
  • ‘leds’: the index (or indexes) of leds that applies this transformation of color (for example, ‘ 0 – 5, 9, 11, 12-17’). Rates are based on zero.
  • ‘hsv’: handling in the domain of colours Valor-saturacion – value with the following settings:
    • ‘saturationGain’ the gain adjustment of saturation
    • ‘valueGain’ setting of the gain
  • ‘red’ / ‘green’ / ‘blue’: manipulation in the domain of red-green – blue color with the following parameters for each channel tuning:
    • ‘threshold’ the minimum value of input required to be on the channel
      (más cero)
    • ‘ gamma’ the correction factor of the gamma curve
    • ‘blacklevel’ the lowest possible value (when the channel is black)
    • ‘whitelevel’ the highest possible value (when the channel is white)

to the side list with color transformations, there is also an option of smoothing.
‘smoothing’: smoothing of the colors in the domain of time with the following tuning parameters:

  • ‘type’ type of algorithm of smoothing (‘linear’ or ‘none’)
  • ‘time_ms’ constant time for the algorithm of smoothing in milliseconds
  • ‘updateFrequency’ leds in Hz refresh rate

example of configuration of the color section corresponding to the previous post

“color” : {
“transform”: [
{
“blue”: {
‘threshold’: 0.050000000000000003,
“blacklevel”: 0.0,
“whitelevel”: 0.84999999999999998,
‘gamma’: 2.0
},
“leds”: “0-81”,
“hsv”: {
“saturationGain”: 1.0,
“valueGain”: 1.0
},
“green”: {
‘threshold’: 0.050000000000000003,
“blacklevel”: 0.0,
“whitelevel”: 0.84999999999999998,
“gamma”: 2.0
},
“id”: “leds”,
“network”: {
‘threshold’: 0.050000000000000003,
“blacklevel”: 0.0,
“whitelevel”: 1.0,
“gamma”}}]} {{: 2.0
}
},
{
“blue”: {
‘threshold’: 0.050000000000000003,
“blacklevel”: 0,
“whitelevel”: 0,
“gamma”: 2.0
},
“leds”: “82-149,”
“hsv”: {
“saturationGain”: 0,
“valueGain”: 0
},
“green”: {
‘threshold’: 0.050000000000000003,
“blacklevel”: 0,
“whitelevel”: 0,
“gamma”: 2.0
},
“id”: “ledsOff”,
“network”: {
‘threshold’: 0.050000000000000003,
“blacklevel’: 0,
“whitelevel”: 0,
“gamma”}} [{{:22000000000000002
}
}
]

also can change the settings for each individual led. Eta part specifies the area averaged an input for each led image to determine its color. Each item in the list contains the following fields:

  • index: the index of the led. This determines its location in the chain of leds. zero
    being the first led.
  • hscan: the fractional part of the image along the horizontal used for the average (minimum and maximum inclusive)
  • vscan: the fractional part of the image along the vertical used to average (minimum and maximum inclusive)
  • ‘updateFrequency’ the update frequency of the leds in Hz


“leds” :
[
{
‘index’: 0,
“hscan”: {“minimum”: 0.0000, “maximum”: 0.0500},
“vscan”: {“minimum”: 0.0000, “maximum”: 0.0800}
}
{
‘index’: 1,
“hscan”: {“minimum”: 0.0000, “maximum”: 0.0357},
“vscan”: {“minimum”: 0.0000, “maximum”: 0.0800}
},

… []]

{
‘index’: 87,
“hscan”: {“minimum”: 0.0000, “maximum”: 0.0500},
“vscan”: {“minimum”: 0.0000, “maximum”: 0.0714}
}
]

Finally, also can touch the setup of effects engine, which contains the following elements:

  • path: an array with absolute locations of directories with effects
  • bootsequence : The effect selected as ‘boot sequence’. It is important to changeIAR to its value in OpenElec “/ storage/hyperion/effects”

example configuration section effects corresponding to the previous post:

“effects”: {
“paths”: [
“/ storage/hyperion/effects”
]
},

Once copied the file hyperion.config.json in storage/.config restart the RPI and if all goes well you should see a rainbow effect and the lights should be consistent with the colors you need to reproduce the sw of hyperion

Be the first to comment

Leave a Reply