Go Down

Topic: EL Wire Sequencer - Vixen (Read 986 times) previous topic - next topic

Face_nn

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: [Select]
#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


mrburnette

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

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy