Pages: [1]   Go Down
Author Topic: EL Wire Sequencer - Vixen  (Read 800 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Folks,

I try to run some EL wires with these EL Sequencer (https://www.sparkfun.com/products/11323). When I use the Generic Serial output plugin form Vixen, everything works fine. But I also wanted to run this with the Enttec Open DMX output of Vixen.

I use the DMX Sketch of Akiba (freaklabs), he shares his sketches on his homepage or on youtube.

Code:
#define DMX_NUM_CHANNELS 4

enum

{
  DMX_IDLE,
  DMX_BREAK,
  DMX_START,
  DMX_RUN
};

volatile unsigned char dmx_state;

int chan_cnt;

unsigned int dmx_start_addr = 1;
unsigned int dmx_addr;

unsigned char dmx_pin[DMX_NUM_CHANNELS] = {2, 4, 6, 8};

unsigned char dmx_data[DMX_NUM_CHANNELS];

volatile unsigned char update;

void setup()
{
  update = 0;
 
  dmx_state = DMX_IDLE;
 
  for (int i=0; i<DMX_NUM_CHANNELS;i++)
  {
    pinMode(dmx_pin[i], OUTPUT);
    digitalWrite(dmx_pin[i], LOW);
  }
 
  UCSR0C =(1<<USBS0)|(3<<UCSZ00);
  Serial.begin(250000);
 
}

void loop()
{
  if (update)
  {
    update = 0;
   
    for (int i=0; i<DMX_NUM_CHANNELS; i++)
    {
      if (dmx_data[i] != 0)
      {
        digitalWrite(dmx_pin[i], HIGH);
      }
      else
      {
        digitalWrite(dmx_pin[i], LOW);
      }
    }
  } 
}

/********************************************************
Interrupt service handler for DMX

*/

ISR(USART_RX_vect)
{
  unsigned char status = UCSR0A;
  unsigned char data = UDR0;
 
  switch (dmx_state)
  {
    case DMX_IDLE:
      if (status & (1<<FE0))
      {
        dmx_addr = 0;
        dmx_state = DMX_BREAK;
        update = 1;
      }
    break;
   
    case DMX_BREAK:
    if (data == 0)
    {
      dmx_state = DMX_START;
    }
    else
    {
      dmx_state = DMX_IDLE;
    }
    break;
   
    case DMX_START:
      dmx_addr++;
      if(dmx_addr == dmx_start_addr)
      {
        chan_cnt = 0;
        dmx_data[chan_cnt++] = data;
        dmx_state = DMX_RUN;
      }
   
    break;
   
    case DMX_RUN:
      dmx_data[chan_cnt++] = data;
      if (chan_cnt >= DMX_NUM_CHANNELS)
      {
        dmx_state = DMX_IDLE;
       
      }
    break;
   
    default:
      dmx_state = DMX_IDLE;
    break;
 
  }
}

When I start a sequence in Vixen, the lights will turn on and off like the should do. But after a short time they get out of sync and it seems like the sequencer hung up. Is it possible that there is a problem with the memory, so that there is a shortage of memory after a little while or an memory overlfow?

Cheers

Face_nn

Logged

Atlanta, USA
Offline Offline
Edison Member
*
Karma: 55
Posts: 1812
AKA: Ray Burne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://playground.arduino.cc/Code/AvailableMemory

Assuming you have available flash for the small routine, put it in your sketch and print the memory out to the console monitor... watch for a while... if there is no change in the free memory, remove the added code as there is no memory leak.


Ray
Logged

Pages: [1]   Go Up
Jump to: