StellaLight

From Ethersex_Wiki
Revision as of 21:21, 2 April 2013 by Mgue (talk | contribs) (timer)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
StellaLight
Status
Stable
menuconfig Applications->StellaLight: Multichannel pwm
Pinning yes
Ecmd yes
Uses Timer Timer 2
Depends on DMX Storage (optional), udpStella (optional)
Code https://github.com/ethersex/ethersex/tree/master/services/stella

StellaLight produces PWM signals on up to 16 independent pins for driving LEDs or servo motors.

Internals

Stella uses an 8-bit Timer of your choice for producing the PWM signals. Since the overflow interrupts need to be very consistent, StellaLight will not work flawlessy when other modules are active that disable the interrupts for a short amount of time.

This is a list of module where you can expect some problems with: Onewire, RFM12 (please add more if you find some).

Moreover StellaLight does not support Gamma Correction since that would require at least 10-12 bit PWM.

Configuration

In Menuconfig you can select the prescaler. The higher the frequency, the more often the StellaLight PWM functions will be executed, leading to an higher overall load of the device. So if you run into problems, try decreasing the frequency, ergo increase the prescaler.

Option Prescaler
Very slow 1024
Slow 256
Normal 128
Fast 64

You can calculate the resulting frequency by using this formula:

F_CPU: The clockspeed of your AVR (like 8Mhz, 16Mhz etc.)

F_STELLA=F_CPU/Prescaler/512

So given a setting of "Normal" on a 16Mhz device will result in 244Hz which is pretty good for most setups. So more than enough for the human eye (10 times more)

If you have enabled DMX Storage in Menuconfig, you also can set the universe and start channel of StellaLight, so you can control StellaLight via Artnet or DMX FXSlot.

Pinning

STELLA_PORT1_RANGE(PXI,PXJ) sets the range (I to J) of StellaLight controlled pins on PORTX
STELLA_PORT2_RANGE(PX2I,PX2J) sets the range (I to J) of StellaLight controlled pins on PORTX2
STELLA_USE_TIMER(I) programs TimerI for StellaLight

Two examples:

1. 3 LEDs (e.g. RGB) on PORTA, Pins: 0,1,2

ifdef(`conf_STELLA', `dnl
  STELLA_PORT1_RANGE(PA0,PA2)
  STELLA_USE_TIMER(2)
')dnl

2. 15 LEDs (e.g. 5x RGB) on PORTA, Pins: 0,1,2,3,4,5,6,7 on PORTD, Pins: 0,1,2,3,4,5,6

ifdef(`conf_STELLA', `dnl
  STELLA_PORT1_RANGE(PA0,PA7)
  STELLA_PORT2_RANGE(PD0,PD6)
  STELLA_USE_TIMER(2)
')dnl

udp control

We recommend to use the DMX Storage. But for easy set ups it is possible to use a simple udp protocol to control stella channels. Activate protocols->udpStella and configure the port. A datagram for stella has three bytes:

Byte # Semantic Valid values
1 Command Byte
 STELLA_SET_IMMEDIATELY=0,
 STELLA_SET_FADE=1,
 STELLA_SET_FLASHY=2,
 STELLA_SET_IMMEDIATELY_RELATIVE=3,
 STELLA_SET_FADESTEP=4,
 STELLA_GETALL = 255
2 Channel 0-15
3 Value 0-255

You will get back an UDP datagram if you send the STELLA_GETALL command. It consists of an identifier ["STELLA"]+[Amount of channels]+[channel#1]+..+[channel#n]

Alternative

Have a look at Starburst for an improved and more resource-conserving solution.