Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
Scionica

Avatar / Picture

Registered:
Posts: 77
Reply with quote  #1 
I've been working on rebuilding/upgrading my bridge lighting setup, and would like to have a computerless "attract mode".  To this end, I have put thought into installing an Arduino with a DMX shield in the main display so that I don't have to open Artemis or DMX Editor itself.  Now, I've read through some of the documentation for the DMX libraries, and they seem fairly straightforward, however, my experience with DMX programming is entirely through Artemis DMX Editor.  Anyone have experience with the Ardiuno DMX libraries and/or any words of advice how I could best adapt my Artemis programming to what the Arduino is looking for?
__________________
Captain, TSN HOW2STARSHIP???, Chicago, IL
Angel of Rust

Registered:
Posts: 442
Reply with quote  #2 
Quote:
Originally Posted by Scionica
I've been working on rebuilding/upgrading my bridge lighting setup, and would like to have a computerless "attract mode".  To this end, I have put thought into installing an Arduino with a DMX shield in the main display so that I don't have to open Artemis or DMX Editor itself.  Now, I've read through some of the documentation for the DMX libraries, and they seem fairly straightforward, however, my experience with DMX programming is entirely through Artemis DMX Editor.  Anyone have experience with the Ardiuno DMX libraries and/or any words of advice how I could best adapt my Artemis programming to what the Arduino is looking for?


BTW - the new status board is looking great!

I do not have experience with using DMX libraries. However, I do have a pretty good idea about programming Arduino sketches and also how DMX signals work. Ironically, I have been working on and off on building my DMX-to-Arduino controller for Artemis that is doing pretty much the opposite of what you want to do. I hope to have some photos to share in the next week or so.

Because Arduinio sketches have such flexibility, it is best to start out with something really simple and then branch out as you gain more experience. Undoubtedly, you have access to the basic functions for the DMX library you picked out. However, another resource could be the following page:
http://playground.arduino.cc/Learning/DMX

The idea with the Arduino DMX libraries (the good ones anyway) is that the code to output the DMX signal is always running in the background and the sketch that you write is just making changes to a few of the variables it is pumping out to the DMX wires. The nice thing is that you can wire the D+, D- and GND pins on your DMX shield directly to the DMX wires you built to go from the USB-to-DMX converter to the DMX controllers on the status board. All you would need to do is turn the Arduino off when you want to play, so that there is no noise on the DMX lines when they are supposed to be receiving from Artemis.

Back to software, Arduino has a good set of simple commands for starting out and writing some "turn this on, then wait, then turn this on" kind of code.

I would start out with an example sketch from your chosen DMX library and use the function to turn on one of the channels (say, set the value to 255), "delay" for a few seconds, then turn off the same channel (set to zero) inside the main loop function. The whole sketch, including the reference to the library, could be five lines of code or so. From there, you could add more channels, different delay effects and so on. After that, you could look at some randomizing code, more complicated logic and dimming effects, etc. Building and running code goes really fast, so its best to tinker and try things out.

Rather than delays, I use the "stopwatch" approach in my code, which allows the Ardunio to keep an eye on how much time has elapsed while running the main loop and make the appropriate changes after enough time has gone by. You can downloaded the sketches I uploaded to my thread to see how this method works. The difference for you is that, rather than drive the LEDs directly, your code would make changes to the values of the DMX variables that the library is sending out from the attached shield.

In terms of adapting your DMX scripts, I would write down what sequence of lighting effects you want to produce for a given set of events, turn it into a timeline, and then write the Arduino code around the desired timeline. Since this is meant to be an "attract mode", having a static sequence of lighting effects should be ok starting out.

Hopefully some of these ideas are of some use. Good luck!

Scionica

Avatar / Picture

Registered:
Posts: 77
Reply with quote  #3 

These are all helpful, in that it tells me that I've got a good idea on my hands.

Unfortunately I think it's going to be a bit before I actually implement this.  I don't have a whole lot of programming experience, so I'm not entirely sure what sequence my per-channel commands should be.  I'm going to try it anyway, but I figure I'll ask; in what order do all my lighting commands go?  For instance, can I define the entire sequence for DMX channel 1, then move onto the sequence for channel 2, then channel 3, and so on for all the channels in the board?  Or is the programming for the loop more real-time, in the sense that I'd be programming the entire loop for all 100-whatever channels in the order that I'd like them to do something?

Thanks for your thoughts on this.  Clearly I'm not the first person to want to do this, but info on the Internet seems to be a little sparse and/or way out of date.


__________________
Captain, TSN HOW2STARSHIP???, Chicago, IL
davr

Avatar / Picture

Registered:
Posts: 49
Reply with quote  #4 
You can program it however you want. You could make it completely sequential, or you could do them separately, etc. There's a lot of flexibility in programming. If you could give an example of the kind of sequence / animation you want to happen, I could give an example of what the code might look like.
davr

Avatar / Picture

Registered:
Posts: 49
Reply with quote  #5 
Here is some purely hypothetical code to control three different hypothetical kinds of lights, maybe will help you get an idea of one way of doing things. It's definitely not the only way, and probably not the best way either, but just an example!


// DMX channel numbers

// A big blue light we want to slowly fade up and down
const int shieldLight = 1;

// A strip of LEDs we can light up individual ones
const int ledStrip = 2;

// A single light we want to blink on and off
const int blinkyLight = 3;

// Keep track of time
elapsedMillis shieldTime;
elapsedMillis ledTime;
elapsedMillis blinkTime;

// Keep track of values
int shieldVal = 0;
int shieldDirection = 1;
int ledPosition = 0;
int blink = 0;

void loop() {

if(shieldTime > 100) { // every 100ms
 // increase or decrease the shield value
 shieldVal += shieldDirection;

 // change direction at the ends
 if(shieldVal >= 100) shieldDirection = -1;
 if(shieldVal <= 0) shieldDirection = 1;

 // reset timer
 shieldTime -= 100;

 // send DMX command to set the shield light's brightness
 DmxSimple.write(shieldLight, shieldVal);
}

if(ledTime > 250) { // every 250ms
 // light up the next LED
 ledPosition++;

 // after 10th led lit, go back to 0
 if(ledPosition >= 10) ledPosition = 0;

 // reset timer
 ledTime -= 250;

 // send DMX command to light up the specific LED on the strip
 DmxSimple.write(ledStrip, ledPosition);
}

if(blinkTime > 1000) { // every second
  blink = !blink;
  blinkTime -= 1000;

  // send DMX command to turn the light on or off
  DmxSimple.write(blinkyLight, blink);
}

// do nothing for 10ms
delay(10);
}

Scionica

Avatar / Picture

Registered:
Posts: 77
Reply with quote  #6 
davr, that code snippet is very helpful, you've included code snippets for all the use cases I had in mind, and I think I should be able to adapt it for my use.  Thanks!

At the moment might problem is a bit more basic, though.  I have a DMX Master Shield from tinker.it, and I'm not entirely sure the thing works, or at the very least my DMX receivers don't like what the controller is sending.  To make things extra frustrating, the controllers I currently have wired up don't have any "DMX activity" lights on them so I have no idea if they are receiving DMX signaling or not.  I'll have to get my warp core out of the garage since the DMX controllers on that have lots of blinky lights when they are receiving valid DMX data.

__________________
Captain, TSN HOW2STARSHIP???, Chicago, IL
Scionica

Avatar / Picture

Registered:
Posts: 77
Reply with quote  #7 
Quote:
Originally Posted by Scionica
davr, that code snippet is very helpful, you've included code snippets for all the use cases I had in mind, and I think I should be able to adapt it for my use.  Thanks!

At the moment might problem is a bit more basic, though.  I have a DMX Master Shield from tinker.it, and I'm not entirely sure the thing works, or at the very least my DMX receivers don't like what the controller is sending.  To make things extra frustrating, the controllers I currently have wired up don't have any "DMX activity" lights on them so I have no idea if they are receiving DMX signaling or not.  I'll have to get my warp core out of the garage since the DMX controllers on that have lots of blinky lights when they are receiving valid DMX data.


I can only gather that I'm running into some sort of timing issue.  The warp core controllers respond to the Ardiuno, but the two 30-channel controllers that power my bridge display don't indicate they are receiving a valid DMX signal at all.  This may be a bit of a non-starter if my cheap Chinese controllers don't play nice with the Ardiuno.

__________________
Captain, TSN HOW2STARSHIP???, Chicago, IL
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.