Posts with «christmas projects» label

Arduino DMX shield for Christmas projects

.

 

This shield allows to connect an Arduino with DMX equipment. It implements the RS485 interface to adapt the electrical levels needed for DMX connection.

This shield has been designed with flexibility in mind and allows the user to choose between several Arduino pins for digital input and output of DMX data, it supports a microSD slot and also has the serial connection to support a serial LCD display.

This design allows basic operation of DMX through simple pre programmed messages stored in the Arduino Sketch or, with the proper libraries and programming, it could well become a standalone system with playback capabilities of sequences stored on the microSD. When needed, this solution is also a suitable interface for a PC sending through a serial port the DMX commands.

DMX basics

This interfacing and communication standard has been developed to allow easier management of complex lighting systems. On stages and discos, many spots, pars, moving heads and other equipment need to be managed and controlled, but bringing power from a centralized panel rises many issues for safety and cabling complexity.

With DMX, each device has an integrated or external controller. A control system sends a specific message to each controller with a byte that the controller itself interprets according to its address and capabilities. Power supply becomes “local” and the communication is with a daisy chained cable that carries low voltage signals.

DMX data is sent in parallel to every controller connected and the address given to each controller allows each device to grab and interpret only the relevant information.

The transmission scheme has been designed for efficiency as DMX may drive up to 512 devices at the same time, with 40 complete transmission sets per second. To achieve this, with 8 bits, 1 start and 1 stop bit, speed has to be 250 kbps. The serial data starts with a header and then bytes are sent in sequence, starting from the first one.

If we have to send a new command to the controller with address 10, we need to send also the data relevant to the controllers from 1 to 9. The addressing system is based on position of the byte and each controller counts the incoming bytes, discarding the ones preceding and following its own byte.

It is also important to remember that each command received is always relevant, therefore to alter the state of a single controller, it is necessary to send valid commands to all the controllers that have a lower address. The sequence, however, may end when the address of the relevant controller has been reached (no need to send the sequence with data exceeding the relevant controller address).

The values from 0 to 255 initially represented the level of the light (0 = off, 255 = full brightness), but the adoption of DMX by other devices turned the meaning of the byte into other commands, eg. position, program selection, specific preset, activate feature and so on. Each manufacturer specifies the mapping between values and functions and sometimes a single byte is not enough to manage all the capabilities, therefore the device occupies an interval of addresses on the DMX bus and reads more than one byte, in sequence.

 

Shield schematics

This shield uses a MAX485 by Maxim to convert the signal levels from the Arduino digital pin to the RS485 differential simplex two wire plus ground connection. The MAX485 contains a receiver and a transmitter, with enabling signals. The /RE (pin 2) and OE (pin 3) – that enable reception and transmission – are with inverted levels, so that it is possible to use a single line and the two pins connected together to manage transmission direction. Pin 1 is Receive Output, pin 4 is Data Input, pin 6 and 7 are the differential outputs.

It is possible to choose between different Arduino D pins for each of the three signals needed: RO may be mapped onto D0 or D4, DI onto D1 or D3 and /RE+OE onto D2 or D5.

The other chip on the shield is an 74HC4050D that contains six buffers to match TTL levels from Arduino ICSP with the 3,3V required by the microSD. This is required just by microSD input lines because Arduino input correctly reads the 3,3V level supplied by microSD as a logic “1”.

The last bits of the schematics include a couple of LEDs connected to D7 and D8, a pushbutton on A1 and the serial connection for the LCD on A0/A2 (jumper selectable).

Configuration

Before you proceed with this shield, you should decide the various jumpers positions; if no other shield is used with Arduino, you are free to choose any of the two positions available; when used with other shields, use the jumpers to avoid any conflict. Please note that ICSP is used with Ethernet shields as well, therefore the microSD slot might create conflicts if used with an Ethernet equipped solution.

DMX library 

DOWNLOAD DMX LIBRARY (Arduino1.0.1)

This shield needs a specific library named DmxSimple.h available for download at http://code.google.com/p/tinkerit/wiki/DmxSimple ; with it you will find some examples. We also have two other sketches to let you experiment with this shield.

/* Welcome to DmxSimple. This library allows you to control DMX stage and
** architectural lighting and visual effects easily from Arduino. DmxSimple
** is compatible with the Tinker.it! DMX shield and all known DIY Arduino
** DMX control circuits.
**
** DmxSimple is available from: http://code.google.com/p/tinkerit/
** Help and support: http://groups.google.com/group/dmxsimple       */

/* To use DmxSimple, you will need the following line. Arduino will
** auto-insert it if you select Sketch > Import Library > DmxSimple. 

Modified by Boris Landoni
open-electronics.org

*/

#include 

const int jrde =  2;
const int jdi  =  3;
const int jro  =  4;
const int lr   =  7;
const int ly   =  8;

void setup() {

  pinMode(jrde, OUTPUT);
  pinMode(jdi,  OUTPUT);
  pinMode(jro,  INPUT);
  pinMode(lr, OUTPUT);
  pinMode(ly, OUTPUT);

  digitalWrite(jrde, HIGH);

  /* The most common pin for DMX output is pin 3, which DmxSimple
  ** uses by default. If you need to change that, do it here. */
  DmxSimple.usePin(jdi);

  /* DMX devices typically need to receive a complete set of channels
  ** even if you only need to adjust the first channel. You can
  ** easily change the number of channels sent here. If you don't
  ** do this, DmxSimple will set the maximum channel number to the
  ** highest channel you DmxSimple.write() to. */
  DmxSimple.maxChannel(5);
}

void loop() {
  int brightness;
  /* Simple loop to ramp up brightness */  
  for (brightness = 0; brightness <= 255; brightness++) {
    digitalWrite(lr, HIGH);
    /* Update DMX channel 1 to new brightness */
    //DmxSimple.write(1, brightness);
    DmxSimple.write(2, brightness);
    //DmxSimple.write(3, brightness);
    DmxSimple.write(4, 189);

    /* Small delay to slow down the ramping */
    delay(10);
    digitalWrite(lr, LOW);
  }

}


Vixen

 

 

We also suggest to use Vixen (www.vixenlights.com) to create sequences on a PC, synced with music, that are sent to Arduino over the serial port. The communication between Arduino and Vixen is managed by our sketch DMX_LightSequencing.

/*
The purpose of this code is to allow the Arduino to use the 
generic serial output of vixen lights to control 5 channels of LEDs. 
Author: Matthew Strange
Created: 14 October 2010
Modifier: Ben Towner
Modified: 19-OCT-2010
Changes: Addition of 20 Digital On/Off Channels - Setup for Arduino Mega 2560
Modified by Boris Landoni
open-electronics.org

*/

#include 

const int jrde =  2;
const int jdi  =  3;
const int jro  =  4;
const int lr   =  7;
const int ly   =  8;

#define DELAY    10

int i = 0;     // Loop counter
int incomingByte[25];   // array to store the 25 values from the serial port
int address=1;
int ch=16;
int k;

//setup the pins/ inputs & outputs
void setup()
{
  Serial.begin(9600);        // set up Serial at 9600 bps

  pinMode(jrde, OUTPUT);
  pinMode(jdi,  OUTPUT);
  pinMode(jro,  INPUT);
  pinMode(lr, OUTPUT);
  pinMode(ly, OUTPUT);

  digitalWrite(jrde, HIGH);

  /* The most common pin for DMX output is pin 3, which DmxSimple
  ** uses by default. If you need to change that, do it here. */
  DmxSimple.usePin(jdi);

  /* DMX devices typically need to receive a complete set of channels
  ** even if you only need to adjust the first channel. You can
  ** easily change the number of channels sent here. If you don't
  ** do this, DmxSimple will set the maximum channel number to the
  ** highest channel you DmxSimple.write() to. */
  DmxSimple.maxChannel(ch);

  for (k=0; k= ch) {
    // read the oldest byte in the serial buffer:
      for (k=0; k

Lighted plexiglass Christmas ornaments (Arduino version)

In the previous post we showed you how to make small Christmas shapes using an RGB LED and a small circuit based on PIC.
The designs were obtained working with the CNC some acrylic sheets.
But our CNC can do much more … Therefore we decided to make the greatest figure and design a new driver that mounts more LEDs.

Just because we do not like things simple we recreated all using a system based on Arduino.
This allows you to create an open source system easy to modify.
The microcontroller is an Atmega328 preprogrammed with the bootloader of Arduino UNO. The programming can be done via a USB / TTL (eg FTDI5V of SparkFun).
The circuit operation is very similar to that of the smallest model: here we find the photocell that allows to verify the amount of light present in the environment, but in this case, you can adjust the sensitivity of the circuit by a trimmer.

BOM

R1: 10 kohm
R2: 820 ohm
R3: 820 ohm
R4: 1 kohm
R5: 820 ohm
R6: 820 ohm
R7: 1 kohm
R8: 820 ohm
R9: 820 ohm
R10: 1 kohm
R11: 820 ohm
R12: 820 ohm
R13: 1 kohm
R14: 820 ohm
R15: 820 ohm
R16: 1 kohm
R17: 820 ohm
R18: 820 ohm
R19: 1 kohm
R20: 820 ohm
R21: 820 ohm
R22: 1 kohm
R23: 820 ohm
R24: 820 ohm
R25: 1 kohm
R26: 820 ohm
R27: 820 ohm
R28: 1 kohm
R29: 10 kohm
R30: 4,7 kohm
R31: 10 kohm
R32: 4,7 kohm
R33: 4,7 kohm
R34: 10 kohm
R35: 4,7 kohm
R36: 10 kohm
R37: 4,7 kohm
R38: 10 kohm
R39: Trimmer 4,7 kohm MV

C1: 100 nF
C2: 470 µF 25 VL
C3: 470 µF 25 VL
C4: 100 nF
C5: 15 pF
C6: 15 pF
C7: 100 nF
C8: 100 µF 25 VL

T1: BC547
T2: BC547
T3: BC547

LD1: LED 5 mm RGB c.a.
LD2: LED 5 mm RGB c.a.
LD3: LED 5 mm RGB c.a.
LD4: LED 5 mm RGB c.a.
LD5: LED 5 mm RGB c.a.
LD6: LED 5 mm RGB c.a.
LD7: LED 5 mm RGB c.a.
LD8: LED 5 mm RGB c.a.
LD9: LED 5 mm RGB c.a.

U1: 7805
U2: ATMEGA328P-PU (with bootloader)

Q1: 16 MHz

LDR1: photoresistor 2÷20 kohm

- Terminal 2 via (3 pz.)
- Socket 14+14
- Battery 12V/2A
- Strip male 6 via
- Plug
- Switch

Comparing the value read from the A/D converter connected to the photoresistor with that connected to trimmer R39, the micro decides whether to start the sequence of fading, or whether turn off the LEDs. RGB LEDs are driven by the transistor; this choice permit to control with a single line of microcontroller, more LEDs in order to create large luminous figures.

As you can see, we use a line dell’ATmega for each of the primary colors of red, green and blue, so it is clear that all the diodes will do the same play of light. Of course isn’t required to mount all the LEDs provided in the circuit: you mount those who need to obtain a good visual effect on the size of the pattern in the Plexiglass. Note that there are three terminals on the PCB: one to connect the power switch (ON / OFF) a second (BATT) to apply to the circuit power supply and a third (CHARGE) for a possible battery charger lead or a small 12-volt solar panel, which already incorporates the charging circuit. These solutions allow you to use the figures lack the power grid. In this regard, an analog input of the microcontroller is dedicated to control the battery voltage: when it drops below 10 V, the circuit will emit flashes to warn that the energy is about to end.

This circuit is evidently intended to be used externally (provided it is properly isolated) and will turn on and off independently, thanks to the ambient light sensor, which will illuminate the figures in the evening to let off in the morning. In short, is a solution to decorate the garden or backyard.

Building shapes
The materials chosen for this application are clear polycarbonate (or methacrylate) or Plexiglas, which can give the shape you want. Then we need to affect, deep enough (half or two thirds the thickness of the plate) the drawing or writing that you want to appear bright.

The Sketch

//****************************************************************
//*  Name    : RGB controller for common anode led               *
//*  Author  : Landoni Boris                                     *
//*  www.open-electronics.org                                    *
//*  blog.elettronicain.it                                       *
//*  www.futurashop.it                                           *
//****************************************************************

int red = 9;    // RED LED connected to PWM pin 3
int green = 10;    // GREEN LED connected to PWM pin 5
int blue = 11;    // BLUE LED connected to PWM pin 6
int photo = A4;    // BLUE LED connected to PWM pin 6
int trim = A5;    // BLUE LED connected to PWM pin 6
int volt = A2;    // BLUE LED connected to PWM pin 6
int r=50; int g=100; int b=150;
int rup; int gup; int bup;
int fader=1;
int inc=10;
void setup()
{
      Serial.begin(9600);
      Serial.println("Serial READY");
      rgb(r, g, b);
      r = random(0,255);
      g = random(0,255);
      b = random(0,255);

} 

void loop()  {

  Serial.print("trim  ");
  Serial.println(analogRead(trim)*2);  

  Serial.print("photo ");
  Serial.println(analogRead(photo)); 

  Serial.print("volt ");
  Serial.println(analogRead(volt));
  if (analogRead(volt)<600){
      Serial.println("low battery");
      rgb(0, 0, 0);
      delay(500);
      rgb(255, 255, 255);
  }

  if ((analogRead(trim)*2)>analogRead(photo)){
      Serial.println("trim > photo  -  off");
      rgb(0, 0, 0);
      fader=0;
  }
  else
  {
    if (fader==0){
      r = random(0,255);
      g = random(0,255);
      b = random(0,255);
    }
    fader=1;

  }
  //delay(2000);

  if (fader==1){
    funcfader();
  }
}

void funcfader(){
    Serial.println("fader");
    if (rup==1){r+=1;}
    else{r-=1;}
    if (r>=255){rup=0;}
    if (r<=0){rup=1;}

    if (gup==1){g+=1;}
    else{g-=1;}
    if (g>=255){gup=0;}
    if (g<=0){gup=1;}

    if (bup==1){b+=1;}
    else{b-=1;}
    if (b>=255){bup=0;}
    if (b<=0){bup=1;}

    delay(inc*2);
    rgb(r, g, b);
}

void rgb(int r, int g, int b)
{
  Serial.print("RGB: ");
  Serial.print(r);
  Serial.print(" ");
  Serial.print(g);
  Serial.print(" ");
  Serial.println(b);
  if (r>255) r=255;
  if (g>255) g=255;
  if (b>255) b=255;
  if (r<0) r=0;
  if (g<0) g=0;
  if (b<0) b=0;
  analogWrite(red, r);
  analogWrite(green, g);
  analogWrite(blue, b);
}

 

Star
Reindeer
Santa Claus
Tree