Arduino, SuperCollider, コンピュータ

SuperCollider -> Arduino -> DMX

What I am going to write below might contain many mistakes and misunderstandings, so any correction would be greatly appreciated.

I have been learning how to synchronise lights with sounds by using Arduino. Small LED lights is fairly easy to control between a laptop and Arduino. But if you need more power of lights and more general way of controlling them, you may want to operate DMX512. Arduino can handle DMX with a shield, while there is an option to buy a USB-DMX interface. You can even make a DMX-shield by yourself. Nevertheless, I bought a ready-made DMX-shield CTC-DRA-10-1, which didn’t seem too expensive to me.

original plan
original plan

I had thought the Arduino only with DMX-shield would have turned out to be a USB-DMX interface. It could be. I found it possible to control DMX from the Arduino but couldn’t write any sketch to receive a command to operate DMX from my laptop. It seems to me that “Serial” is used for handling DMX somehow and it can’t receive any data from the laptop at the same time. This may be totally wrong. I googled to find a successful example of CTC-DRA-10-1 receiving data for DMX from a PC running Grasshopper. Not even knowing what on earth Grasshopper is, I followed its instructions on the Arduino side and sent commands from SuperCollider. Nothing happened. This failure might be due to the LED light I am using. You have to set its DIP switch correctly to receive DMX signals, but I still don’t understand how to do it according to its user’s manual.

After struggling to find a way to control the light through DMX and USB cable in vain, I ended up connecting the laptop and Arduino by Ethernet cable, leaving the USB connection just for power supply, and sending OSC data for DMX control from the laptop to Arduino. In short, I bought an Ethernet shield.

ended up with...
ended up with…

DMX-shield, Ethernet-shield and Arduino
DMX-shield, Ethernet-shield and Arduino

I found a valid setting of DIP switch through trial and error, although its DMX channel numbers seem different from ones that SuperCollider sends signals to, which doesn’t make sense to me. At worst, anyhow, I can synchronise an RGB LED light with sounds from SuperCollider.

DIP menu
DIP menu

DMX channel Function
DMX channel Function

1, 2, 3 and 10 turned ON
1, 2, 3 and 10 turned ON

[Arduino]
I imported OSC class Arduino library ver1.0.1 by recotana and DMX Library for Arduino.
This Arduino code below is based on an example from the article, “Arduino, OSC, iPhone and DMX”, mixed with an example code of DMX Library for Arduino:

#include "SPI.h"
#include "Ethernet.h"
#include "OSCClass.h"
#include <Conceptinetics.h>
 
// Define the number of DMX channels to use (1-512) limit to save memory
#define DMX_MASTER_CHANNELS   100
 
// Pin number to change read or write mode on the shield
#define RXEN_PIN                2
 
// Configure a DMX master controller, the master controller
// will use the RXEN_PIN to control its write operation on the bus
DMX_Master        dmx_master ( DMX_MASTER_CHANNELS, RXEN_PIN );
 
OSCMessage recMes;
 
OSCClass osc(&recMes);
 
// MAC address of ethernet shield
byte serverMac[] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB };
 
// IP address of ethernet shield
byte serverIp[]  = { 192, 168, 12, 3 };
 
// port number for receiving OSC data
int  serverPort  = 10000;
 
// OSC message will start with “/dmx/” on SuperCollider
char *topAddress="dmx";
 
 
void setup() {
     // Enable DMX master interface and start transmitting
     dmx_master.enable ();
 
     // Set all channels to 0(0-255)
     dmx_master.setChannelRange(1, 10, 0);
 
     Ethernet.begin(serverMac, serverIp);
 
     // setting OSC receive server
     osc.begin(serverPort);
 
    // OSC message buffer clear
     osc.flush();
 
}
 
void loop() {
    // Do we have an OSC message?
    if ( osc.available() ) {
      // topAddress (“/dmx/“) matching
      if( !strcmp( recMes.getAddress(0) , topAddress ) ){
          // Get our variables from the message
          char *channel   = recMes.getAddress(1);
          float value     = (float)recMes.getArgFloat(0);
 
          //Convert our float value to integer
          int intvalue = int(255.0*value);
 
          //Send out the DMX values
          dmx_master.setChannelValue(atoi(channel), intvalue);
      } 
    }
}

[SuperCollider]
I still don’t understand why but found “/dmx/7”, “/dmx/8”, “/dmx/9”, and “/dmx/10” work. Of course, it depends on the DMX device.

// IP address and port number of ethernet shield 
~eShield = NetAddr.new("192.168.12.3", 10000);
 
// LED dip switch: 1, 2, 3, 10 turned ON
~eShield.sendMsg("/dmx/10", 0.5); // blue (0.0-1.0)
~eShield.sendMsg("/dmx/9", 0.5); // green (0.0-1.0)
~eShield.sendMsg("/dmx/8", 0.5); // red (0.0-1.0)
~eShield.sendMsg("/dmx/7", 0.5); // 0.0-0.5: brightness, 0.5-1.0: flashing slow to fast
light up
light up
put in an aluminium enclosure
put in an aluminium enclosure

6 Comments

  1. Hi, Nice to meet you.

    My name is Daniel, at WIZnet in Korea.  
    We have been searching some application references in which WIZnet solution is applied, and found your project “SuperCollider -> Arduino -> DMX“ using Ethernet Shield. In the Ethernet Shield WZnet’s W5100 chip is embedded. Your development looks very cool & smart. 
    Recently we opened WIZnet Museum (http://wiznetmuseum.com) site. This is a academic-purposed collection of open projects, tutorials, articles and etc from our global customers.

    If you are O.K. we would like to introduce your projects in here. Hopefully, you will allow this.

    Hopefully, keep contacting us for the friendship.

    Thank you very much

  2. Hi, Nice to meet you.

    My name is Daniel, at WIZnet in Korea.  
    If you are O.K. We would like to introduce your projects in “www.wiznetmuseum.com”. Hopefully, you will allow this.
    Hopefully, keep contacting us for the friendship.

    Thank you very much

  3. My name is Daniel, at WIZnet in Korea.
    We have been searching some application references in which WIZnet solution is applied, and found your project “SuperCollider -> Arduino -> DMX“ using Ethernet Shield. In the Ethernet Shield WZnet’s W5100 chip is embedded. Your development looks very cool & smart.
    Recently we opened WIZnet Museum (http://wiznetmuseum.com) site. This is a academic-purposed collection of open projects, tutorials, articles and etc from our global customers.

    If you are O.K. we would like to introduce your projects in here. Hopefully, you will allow this.

    Hopefully, keep contacting us for the friendship.

    Thank you very much

  4. Hello,
    I want to control a lamp (lightmaXX LED PAR 38 10mm polish 61 RGB-LEDs) via arduino and the same dmx-board like you by a button, so I don’t need the ethernet-board.
    The DMX Values of the lamp:
    CH1 red
    CH2 green
    CH3 blue
    Ch4 Dimmer 0-189, Flash 190-250, No funktion 251-255
    To activate the DMX mode Dip10 on, all other Dips are marked with an X. What does it mean?

    I tried an easy sketch like blink.
    Here ist the code:
    #include
    #define DMX_MASTER_CHANNELS 5
    #define RXEN_PIN 2
    DMX_Master dmx_master ( DMX_MASTER_CHANNELS, RXEN_PIN );

    void setup() {
    dmx_master.enable (); // DMX activate
    dmx_master.setChannelRange ( 1, 4, 0 ); // all channels 0
    pinMode(13, OUTPUT); // onboardLED for control
    }

    void loop() {
    dmx_master.setChannelValue ( 1, 127 ); // Channel 1 (red) @ 50 %
    digitalWrite(13, LOW); // onboardLED off
    delay ( 1000 );

    dmx_master.setChannelValue ( 1, 255 ); // Channel 1 (red) @ 100 %
    digitalWrite(13, HIGH); // onboardLED on
    delay ( 1000 );
    }

    It doesn’t work. Do you have an idea why?

    Best regards

    colmans

    1. Hi colmans, sorry for this delayed reply.
      I don’t have that lamp, so I can’t try the dips setting. But if you turn Dip 10 on, you may also have to turn a dip for red lights on. Actually, I had a hard time to find it 😉

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です