DMX and Arduino Tutorial
DMX and Arduino Tutorial
36
L53
L202
56
L201
72
L200
40
26
30 -5 5
NC
16
81
L201+ L53
MFL
L201+ L53
L201+ L53
L201+ L53
L201+ L53
82
L201
L201 L119
30-55 30-55
L119
30-55
11
L201+ L53
MFL
L201+ L53
L201+ L53
L201+ L53
L201+ L53
6
L201+ L53
MFL
L201+ L53
L201+ L53
L201+ L53
L201+ L53
75
L200
L201+ L53
L201+ L53
L201+ L53
L201+ L53
L201+ L53
36
NC
NSP
MFL
8x
36
5x
MFL
30-55
*(cleft) 2006 by Tomek Ness and D. Cuartielles * K3 - School of Arts and Communication NC * fhp - University of Applied Sciences NC * Profile 1KW, 36 15 x Fresnel, 2KW 19 x Par64, CP6 2 1 x PAR64, CP60 <http://www.arduino.cc> * <http://www.mah.se/k3> Par64, CP6 1 2x Flood 1KW, NC * Profile 2KW, 30-55 1 x PC, 2KW <http://www.design.fh-potsdam.de> 6 x assym. * * @date: 2006-09-30 * @idea: Tomek Ness * @code: D. Cuartielles and Tomek Ness * @acknowledgements: Johny Lowgren for his DMX devices *
MF L
VNS P
MFL
MFL
NS P
MFL
MFL
MFL
MFL
MFL
MFL
MFL
MFL
10
MFL
MFL
MFL
12
MFL
73
70
13
74
14
15
MFL
MFL
MFL
MFL
MFL
36
46
L198
L198
71
71
17
18
19
36
36
78
77
76
NC
5 -5 30
NSP
MFL
L198
71
27
L201
55
L202
45
L53
35
20
36
36
L201
54
L202
44
L53
34
L201
53
L202
43
L53
33
36
L201
52
L202
42
L53
32
L201
L202
51
41
L53
31
NC
66
65
NC
64
Floor
63
62
61
DMX 512
-DMX512 (Digital MultipleXed) is an agreement over the connection between lighting controllers, dimmers, scrollers, scanners, etc.. -The voltage between the conductors of the cable is either approximately +2,5[v] or approximately -2,5[v ]. If the voltage is for 4[us] long positive, then a 1 is transferred. If the voltage is for 4[us] long negative, then 0 istransferred. -The elektronic foundation for DMX is RS 485. -Which connectors and how to connect them? If connectors are used, then it must be 5-Pol XLR types. Pin 1 = signal reference = cable shield Pin 2 = signal inversion = - Pin 3 = signal = + Pin 4 = optional (e.g. acknowledgment) Pin 5 = optional (e.g. acknowledgment)
Start bit, stop bit and date frame In the data ow of the 0-s and 1-s the separate bytes are to be differentiated by the following appointments: A byte is preceded by a 0: this is called start bit A byte is terminated by two 1-s: these are called stop bits With the receipt of the start bit always eleven bits are read : these eleven bits form the date frame. The transmission of a date frame lasts 44[us]. The time between the transmission of the successive bytes and break is arbitrary, within certain boundaries. DMX512 is called therefore an asynchronous data protocol. Shifts data in DMX format out to DMX enabled devices it is extremely restrictive in terms of timing. Therefore the program will stop the interrupts when sending data. Almost all information about dmx 512 is copied from: http://www.theater-technisch-lab.nl/dmxen.htm
The MAX-485
SN 75176 A +5V GND
100 OHM
RO RE DE
1 2 3
8 7 6
V CC B A GND
DMX Outputs :
pin 2 (signal inversion) pin 3 (singal) pin 1 (reference)
input
DI 4
RE
DE
DI
5 6 7 8
GND A B
LTC485 Transmitting
INPUTS RE X X X X DE 1 1 0 1 DI 1 0 X X LINE CONDITION No Fault No Fault X Fault OUTPUTS B 0 1 Z Z A 1 0 Z Z
code example
/* * * * * * * * * * * DMX Shift Out for arduino - 004 and 005 ------------Shifts data in DMX format out to DMX enabled devices it is extremely restrictive in terms of timing. Therefore the program will stop the interrupts when sending data The elektronic foundation for DMX is RS 485, so you have to use a MAX-485 or a 75176. wirring for sending dmx with a MAX-485 1 2 3 4 5 6 7 8 RO RE DE DI GnD A B Vcc Receiver Output --- set to ground with a 100 ohm resistor Receiver Output Enable -- set to ground Driver Output Enable -- set to 5v Driver Input -- Input from Arduino Ground Connection -- set to ground -- refence for the DMX singal --- (DMX pin 1) Driver Output / Receiver Input -- DMX Signal (hot)------------------ (DMX pin 3) Driver Output / Receiver Input -- DMX Signal inversion ( cold)------ (DMX pin 2) Positive Supply -- 4,75V < Vcc < 5,25V
* Every dmx packet contains 512 bytes of information (for 512 channels). * The start of each packet is market by a start byte (shiftDmxOut(sig,0);), * you should always send all 512 bytes even if you don*t use all 512 channels. * The time between every dmx packet is market by a break * between 88us and 1s ( digitalWrite(sig, LOW); delay(10);) * * (cleft) 2006 by Tomek Ness and D. Cuartielles * K3 - School of Arts and Communication * fhp - University of Applied Sciences * <http://www.arduino.cc> * <http://www.mah.se/k3> * <http://www.design.fh-potsdam.de> * * @date: 2006-09-30 * @idea: Tomek Ness * @code: D. Cuartielles and Tomek Ness * @acknowledgements: Johny Lowgren for his DMX devices * */ int sig = 11; int count = 0; int swing = 0; int updown = 0; /* Sends a DMX byte out on a pin. Assumes a 16 MHz clock. * Disables interrupts, which will disrupt the millis() function if used * too frequently. */ void shiftDmxOut(int pin, int theByte) { int theDelay = 1; int count = 0; int portNumber = port_to_output[digital_pin_to_port[pin].port]; int pinNumber = digital_pin_to_port[pin].bit; // signal (hot / dmx pin 3)
// the rst thing we do is to write te pin to high // it will be the mark between bytes. It may be also // high from before _SFR_BYTE(_SFR_IO8(portNumber)) |= _BV(pinNumber); delayMicroseconds(20); // disable interrupts, otherwise the timer 0 overow interrupt that // tracks milliseconds will make us delay longer than we want. cli(); // DMX starts with a start-bit that must always be zero _SFR_BYTE(_SFR_IO8(portNumber)) &= ~_BV(pinNumber); //we need a delay of 4us (then one bit is transfert) // at the arduino just the delay for 1us is precise every thing between 2 and 12 is jsut luke // to get excatly 4us we have do delay 1us 4 times delayMicroseconds(theDelay); delayMicroseconds(theDelay); delayMicroseconds(theDelay); delayMicroseconds(theDelay); for (count = 0; count < 8; count++) { if (theByte & 01) { _SFR_BYTE(_SFR_IO8(portNumber)) |= _BV(pinNumber); } else { _SFR_BYTE(_SFR_IO8(portNumber)) &= ~_BV(pinNumber); } delayMicroseconds(theDelay); delayMicroseconds(theDelay); delayMicroseconds(theDelay); delayMicroseconds(theDelay); theByte>>=1; } // the last thing we do is to write the pin to high // it will be the mark between bytes. (this break is have to be between 8 us and 1 sec) _SFR_BYTE(_SFR_IO8(portNumber)) |= _BV(pinNumber); // reenable interrupts. sei(); } void setup() { pinMode(sig, OUTPUT); digitalWrite(13, HIGH); } void loop() { // sending the break (the break can be between 88us and 1sec) digitalWrite(sig, LOW); delay(10); //sending the start byte shiftDmxOut(sig,0); //sending the 512 bytes for the channels shiftDmxOut(sig, 150); //1 shiftDmxOut(sig, 150); //2 shiftDmxOut(sig, 150); //3 shiftDmxOut(sig, 150); //4 for (count = 1; count<=508; count++){ shiftDmxOut(sig, 0); } }