RGB Dimmer
Purpose
The SHC RGB dimmer powers three LEDs with a current of up to 600mA. You can assemble it in different housings and use differend LED types. You can use the device as an ambient / mood light or as a general purpose alarm / information lamp. The circuit and RGB LEDs are small enough to fit in many different lamp housings.
By requesting the device to show different colors and color animations, you can use it to show different states for whatever you like. To react on specific events, you have to configure the PC application controlling your SHC network accordingly. To give you some examples, you could make the LEDs blink in red if your fridge is left open or set the color depending on the outdoor temperature.
In addition to the LEDs, the device can power a small piezo speaker to alarm you as needed. You can play a series of tones (melody), similar to requesting the RGB LED animation.
Functions, Behavior
The device is powered by a DC adaptor. It can receive commands any time. You can request one of the following functions:
- Set a fixed color
- Request a color animation
- Set a fixed tone
- Request to play a melody
Supported Messages
- Generic_Version_Status
- Dimmer_Color_Get/Set/SetGet/Status/Ack/AckStatus
- Dimmer_ColorAnimation_Get/Set/SetGet/Status/Ack/AckStatus
- Audio_Tone_Get/Set/SetGet/Status/Ack/AckStatus
- Audio_Melody_Get/Set/SetGet/Status/Ack/AckStatus
Color Palette
The SHC RGB dimmer uses a 6 bit color palette (same as EGA) for the messages to reduce the needed message sizes. Internally, fading between colors uses full 24 bits (8 bits per color), so there are no visible jumps from one color to another within a color animation.
These are the 64 colors used in the supported messages Color and ColorAnimation:
Color 0 = 000 | Color 1 = 005 | Color 2 = 00A | Color 3 = 00F | Color 4 = 050 | Color 5 = 055 | Color 6 = 05A | Color 7 = 05F |
Color 8 = 0A0 | Color 9 = 0A5 | Color 10 = 0AA | Color 11 = 0AF | Color 12 = 0F0 | Color 13 = 0F5 | Color 14 = 0FA | Color 15 = 0FF |
Color 16 = 500 | Color 17 = 505 | Color 18 = 50A | Color 19 = 50F | Color 20 = 550 | Color 21 = 555 | Color 22 = 55A | Color 23 = 55F |
Color 24 = 5A0 | Color 25 = 5A5 | Color 26 = 5AA | Color 27 = 5AF | Color 28 = 5F0 | Color 29 = 5F5 | Color 30 = 5FA | Color 31 = 5FF |
Color 32 = A00 | Color 33 = A05 | Color 34 = A0A | Color 35 = A0F | Color 36 = A50 | Color 37 = A55 | Color 38 = A5A | Color 39 = A5F |
Color 40 = AA0 | Color 41 = AA5 | Color 42 = AAA | Color 43 = AAF | Color 44 = AF0 | Color 45 = AF5 | Color 46 = AFA | Color 47 = AFF |
Color 48 = F00 | Color 49 = F05 | Color 50 = F0A | Color 51 = F0F | Color 52 = F50 | Color 53 = F55 | Color 54 = F5A | Color 55 = F5F |
Color 56 = FA0 | Color 57 = FA5 | Color 58 = FAA | Color 59 = FAF | Color 60 = FF0 | Color 61 = FF5 | Color 62 = FFA | Color 63 = FFF |
Color Animation
A color animation is defined by a series of up to 10 colors with an additional time value. The RGB dimmer fades one color to the other in the given time.
Time values
The time value used in the ColorAnimation message results in an animation time according to the following formula:
The value 0 has the special meaning and marks the end of the animation if you use less than 10 colors. The calculation was chosen to have both small exact time frames and also bigger ones with a small amount of message data. With the given 5 Bits per time value, it covers the following animation times (rounded values used in the firmware):
time value | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
fading time [s] | end marker | 0.03 | 0.07 | 0.1 | 0.13 | 0.20 | 0.26 | 0.33 | 0.39 | 0.52 | 0.69 | 0.88 | 1.2 | 1.5 | 2.0 | 2.6 |
time value | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
fading time [s] | 3.2 | 4.3 | 5.6 | 7.3 | 9.5 | 12.4 | 16 | 21 | 27 | 35 | 46 | 60 | 78 | 101 | 131 | 170 |
The RGB dimmer uses a timer with ~32ms internally. The result is that you get an instant change of the color without fading when using time value 1. You can use this by purpose when you want an immediate color change instead of a fade.
Color Animation Modes
The behavior of the animation depends mainly on two settings:
- The repeat count is used to repeat the animation several times. An infinite playback is possible using the special value "0".
- The autoreverse function plays the animated colors in reverse order after it finishes in the normal direction.
In all cases, the animation starts and ends with a separate color that is only played back one time. This allows that the color shown previously to the animation can be cleanly faded out and is not mixed with the first color you set in the animation. At the end of the animation, it allows to fade out to a separate color (e.g. black = off), which is otherwise not used in the (repeated) animation.
For the animation, you have to decide how many colors you want to play back. The last color of the animation is where the next one has a time value of 0.
For better understanding, have a look at the following examples:
one-time playback of animation
If you set repeat to 1, the color animation is played back once in the given order. The first color is faded in from the color which is visible before the animation started (black in this example). The last color remains visible after the animation is completed. You may want to use black as last color to switch the RGB dimmer off. The time value 0 as t3 marks the end of the animation.
repeated animation with limited cycles, without autoreverse
If you set repeat to a positive number greater than 1, the colors are played back several times. The first color (c0) is used only once at the beginning. After the first cycle is complete, c3 is directly faded to c1. Note that the last color (c4) is used only at the end when all animation cycles are finished. This is used to fade out to black (= off).
endless animation without autoreverse
This example shows a color animation which is also looped only in one direction. The number of cycles is set to 0, which means infinite repeat. Because there is no need for a separate color which is used at the end of the animation, every cycle ends with c4. After a cycle is complete, c4 is directly faded to c1 again.
autoreverse animation with odd number of cycles
When autoreverse is selected, the animation is played back in reverse order after the last color of a cycle is reached. Playback in the reverse direction ends not at c0, but at c1 to let c0 only be visible once at the start of the animation.
autoreverse animation with even number of cycles
When an even number of cycles is selected for an animation with autoreverse, the last cycle is "skipped" and c1 is directly faded to the last color defined.
autoreverse animation with endless cycles
When endless cycles are selected, the color with the highest number is used in every cycle, because there is no need for a separate "last" color.
Tones
Similar to the color palette for the LEDs, a set of tones (mostly notes) is defined to allow playing melodies or just a single high or low tone.
The following tones used in the supported messages Tone and Melody can be used providing the listed index number. To play a melody in a usual pitch, use index around 25-36.
The accuracy for the listed target frequency is limited by the 16 bit timer value, but has a maximum deviation of 0.28% for some high notes (index ≤ 84), which is not audible. The tones above index 84 are only for special cases, not to play notes/melodies (e.g. create noises with special speakers to scare off animals).
index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tone | silence | C | Des | D | Es | E | F | Ges | G | As | A | B | H |
frequency [Hz] | 0 | 65.41 | 69.30 | 73.42 | 77.78 | 82.41 | 87.31 | 92.50 | 98.00 | 103.83 | 110.00 | 116.54 | 123.48 |
index | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
tone | c | des | d | es | e | f | ges | g | as | a | b | h |
frequency [Hz] | 130.81 | 138.60 | 146.84 | 155.56 | 164.81 | 174.61 | 185.00 | 196.00 | 207.65 | 220.00 | 233.08 | 246.94 |
index | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
tone | c' | des' | d' | es' | e' | f' | ges' | g' | as' | a' | b' | h' |
frequency [Hz] | 261.63 | 277.18 | 293.66 | 311.13 | 329.63 | 349.23 | 369.99 | 392.00 | 415.30 | 440.00 | 466.16 | 493.88 |
index | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
tone | c'' | des'' | d'' | es'' | e'' | f'' | ges'' | g'' | as'' | a'' | b'' | h'' |
frequency [Hz] | 523.25 | 554.37 | 587.33 | 622.25 | 659.26 | 698.46 | 739.99 | 783.99 | 830.61 | 880.00 | 932.33 | 987.77 |
index | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
tone | c''' | des''' | d''' | es''' | e''' | f''' | ges''' | g''' | as''' | a''' | b''' | h''' |
frequency [Hz] | 1046.50 | 1108.73 | 1174.66 | 1244.51 | 1318.51 | 1396.91 | 1479.98 | 1567.98 | 1661.22 | 1760.00 | 1864.66 | 1975.53 |
index | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
tone | c'''' | des'''' | d'''' | es'''' | e'''' | f'''' | ges'''' | g'''' | as'''' | a'''' | b'''' | h'''' |
frequency [Hz] | 2093.00 | 2217.46 | 2349.32 | 2489.02 | 2637.02 | 2793.83 | 2959.96 | 3135.96 | 3322.44 | 3520.00 | 3729.31 | 3951.07 |
index | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
tone | c''''‘ | des''''‘ | d''''‘ | es''''‘ | e''''‘ | f''''‘ | ges''''‘ | g''''‘ | as''''‘ | a''''‘ | b''''‘ | h''''‘ |
frequency [Hz] | 4186.01 | 4434.92 | 4698.63 | 4978.03 | 5274.04 | 5587.65 | 5919.91 | 6271.93 | 6644.88 | 7040.00 | 7458.62 | 7902.13 |
index | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
frequency [Hz] | 9000 | 10000 | 11000 | 12000 | 13000 | 14000 | 15000 | 16000 | 17000 | 18000 | 19000 | 20000 | 21000 | 22000 | 23000 | 24000 |
index | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
frequency [Hz] | 25000 | 26000 | 27000 | 28000 | 29000 | 30000 | 31000 | 32000 | 33000 | 34000 | 35000 | 36000 | 37000 | 38000 | 39000 | 40000 |
E2P Device Configuration
Offset | Block | Content | Type | Size | Description |
---|---|---|---|---|---|
0 | Hardware Values for hardware setup, which have no special meaning to SHC device concepts + the DeviceType, which decides about the existence of further blocks. | DeviceType | EnumValue | 1 Bytes | The device can check with this value if the EEPROM data is meant for the actual type of device. If not, the device goes into an error mode. Values: 0 = BaseStation, 20 = EnvSensor, 40 = PowerSwitch, 45 = Controller, 50 = RGBDimmer, 60 = Dimmer, 70 = SoilMoistureMeter, 80 = Thermostat, 90 = TeaMaker |
8 | OsccalMode | IntValue | 1 Bytes | This value is used to change the speed of the internal oscillator. 0 = don't use OSCCAL calibration (e.g. external crystal oszillator is used). -128 = OSCCAL measure mode: the LED blinks every 60s, so the user can measure the original speed. -127..+127 = The speed is adjusted by the given amount in per mill (e.g. 10 means to speed up the device by +1%). MinVal: -128, MaxVal: 127, Default: 0 | |
16 | Reserved | 6 Bytes | n/a | ||
64 | Generic This block contains SHC configuration data which every device has. | DeviceID | UIntValue | 12 Bits | The DeviceID identifies the specific unit in the SHC network. It is used to address the device and in messages the device sends. Every device has to have a different DeviceID. MinVal: 0, MaxVal: 4095 |
76 | Reserved | 4 Bits | n/a | ||
80 | PacketCounter | UIntValue | 3 Bytes | The PacketCounter is counted up throughout the whole lifetime of the device and is used to make the encrypted packets differently from each other every time. MinVal: 0, MaxVal: 16777215 | |
104 | Reserved | 19 Bytes | n/a | ||
256 | AesKey | ByteArray | 32 Bytes | This key is used to encrypt packets before sending and also used as primary key to decrypt packets. Special devices may have additional keys in their device specific block. | |
512 | RGBDimmer This block contains the specific configuration data that only RGB Dimmer devices need. | BaseStationPacketCounter | UIntValue | 3 Bytes | This is the last remembered packet counter of a command from the base station. Packets with the same or lower number are ignored. MinVal: 0, MaxVal: 16777215 |
536 | BrightnessFactor | UIntValue | 1 Bytes | This value reduces the overall brightness. This is to easily adjust it to your needs without changing the LED series resistors. WARNING: It is recommended to use this only for testing, because it reduces the amount of different brightness levels. Changing the resistors is to be preferred. MinVal: 1, MaxVal: 100, Default: 100 | |
544 | TransceiverWatchdogTimeout | UIntValue | 1 Bytes | Reset RFM12B module if no data is received until timeout is reached. Use this function if your specific transceiver hangs sometimes. Value is in deca seconds. Suggested setting is 48 (for 8 minutes). Set 0 to disable. MinVal: 0, MaxVal: 255, Default: 48 | |
552 | Reserved | 955 Bytes | n/a |
Hardware Overview
PCB | RGB Dimmer 1 PCB (Conventional THTThrough hole technology This is the conventional technique to stick pins of components through the PCB and solder them. This is easy to build up, unlinke using SMD components., non-SMD) 47 x 44 mm |
---|---|
Microcontroller | ATMega 328A-PU (28-pin PDIP) |
Clock Source | 8 MHz internal R/C oscillator |
Special Components |
Voltage regulator 3,3V (TS 2950) |
RFM Transceiver Mode | TX + RX |
UART | only debug TX |
Power | 5-12V with internal 3.3V regulator |
Download
- Firmware Builds for the ATMega
- Hardware Schematics + Layout at GitHub
- SourceCode at GitHub
Assembly Instructions
Look into the Wiki for assembly instructions for this device. It would be appreciated if you correct or enhance the description whenever you find potential for improvement.