Members | Sign In
All Forums > Development

DMX controller code

posted Sep 17, 2012 16:36:45 by ThomRobertson
I found the ENTTEC box, bought it, and got it working with Artemis:

But clearly I'm just using a serial driver to send messages to the device, and I wanted to share the specifics of what I'm doing.

First, I'm linking against a library and .H file called FTD2XX.

Second, here's two very important functions I mostly copied from example code:

DWORD WINAPI ArtemisDMXSendFunction(LPVOID args)
int i;
ULONG bytesWritten;

// set RS485 for sendin

while (!ArtemisDMX::terminated) {


FT_W32_WriteFile(ArtemisDMX::ftHandle, &ArtemisDMX::StartCode, 1, &bytesWritten, NULL);
FT_W32_WriteFile(ArtemisDMX::ftHandle, ArtemisDMX::DMXData, 512, &bytesWritten, NULL);


return 0;

void ArtemisDMX::MakeConnections(void)
FT_STATUS ftStatus;
char Buf[64];

connected = FALSE;



// connect to first device
if (ftHandle == INVALID_HANDLE_VALUE) {
// Application->MessageBoxA("No device","Error",MB_OK);

if (FT_W32_GetCommState(ftHandle,&ftDCB)) {
// FT_W32_GetCommState ok, device state is in ftDCB
ftDCB.BaudRate = 250000;
ftDCB.StopBits = FT_STOP_BITS_2;
ftDCB.ByteSize = FT_BITS_8;
ftDCB.fOutX = false;
ftDCB.fInX = false;
ftDCB.fErrorChar = false;
ftDCB.fBinary = true;
ftDCB.fRtsControl = false;
ftDCB.fAbortOnError = false;

if (!FT_W32_SetCommState(ftHandle,&ftDCB)) {
// Application->MessageBoxA("Set baud rate error","Error",MB_OK);

FT_W32_PurgeComm(ftHandle,FT_PURGE_TX | FT_PURGE_RX);

inter_frame_delay = 30;

DWORD threadId;
CreateThread(NULL, 0, ArtemisDMXSendFunction, 0, 0, &threadId);

eventsRunning = FALSE;

Creator of Artemis
page   1
8 replies
TomWyatt said Sep 18, 2012 14:46:00
fantastic! Cheers Thom

Looking at the driver code on the Future website it looks like this is driving the FTDI chips directly rather than setting up a Virtual COM port within windows.

I'll have to tinker with it tonight but theres a possibility this might just work with the FTDI chips on the older arduinos. If the chip is being nice and just passing rx/tx out of its pins then its fine, if it doesnt then I'm not sure.
I've got an FTDI232 based serial port adapter that uses the same chipset as the entec, if I can get that to work theres hope for the arduinos etc.

It might be possible to alter the firmware on a Leonardo to work in direct mode as well. I'll post what I find here

TomWyatt said Sep 23, 2012 15:32:49
Righty! I've had a chance to play with artemis and the USB stuff and theres good news all round!

The driver that the old Arduino Deicemilias use supports artemis! I'm working on a firmware for them now that'll actually *do* something but I can see DMX data hitting their FTDI chips.

I'll post code on my blog and github accounts when i have something more useful
TomWyatt said Sep 23, 2012 17:17:51
I now have an LED on the arduino that responds to the shield status of the ship :)

Essentially what I've done is set up an arduino sketch that:

1) opens the serial port at 250000 bps
2) continually reads for data

The data comes through as a stream of RGB values from the DMXCommands.xml file, its a bit of a pain t keep track of the stream and know which byte is Red etc

What I've done is remove all of the current event colours and replace the Red values with a unique number while also clearing the GB values. The arduino is then triggering things based on the Red value.

For example

<event type="PLAYER_SHIELDS_ON" continuous="yes">

<!-- steady blue light -->
<timeblock mseconds="1000">
<setvalue index="0" value="2" change="0"/>

the arduino then sets an LED whenever a "2" is received.

alan.noltensmeyer said Oct 02, 2012 01:23:02

Could I have a look at your arduino sketch? I want to see if I can get it working on my arduino Uno.

TomWyatt said Nov 05, 2012 14:48:02
Alan: you wont be able to, the Uno uses a reprogrammable Atmega chip for USB comms whereas the older arduinos use the same FTDI chip that the DMX devices do. From Artemis's point of view the Old arduinos are just a DMX device.

In any case I've given up with DMX interface in its current form. Its too limited for what were trying to do!

I've gone back to breaking the network protocol instead as (even without help or documentation) i've managed to pull more of the information I need
KiranShila said Dec 28, 2012 15:17:33
Can you still post the code? It would be ever helpful.
onwijzebackup said Jan 31, 2013 20:11:01
The following code does what is mentioned by TomWyatt on a MC-Nove:
int incomingByte = 0;

void setup() {
// initialize serial communication at 250000 bits per second:

// the loop routine runs over and over again forever:
void loop() {
// read the serial input
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte =;

if (incomingByte == 2){
// set pin 13 to high if a 1 is received
digitalWrite(13, HIGH);

[Last edited Jan 31, 2013 20:11:50]
Catscradler said Feb 21, 2013 04:25:51
I spent a few hours getting Artemis to light up some LEDs through my Arduino this past weekend, and it turned out to be pretty straightforward. Here's the process:

  • Unzip the Arduino DMX library found here:
    to your Arduino libraries folder.
  • Upload the example DmxSerialRecv sketch to your Arduino.
  • Connect red, green and blue LEDs (and appropriate resistors) to pins 9, 6 and 5.
  • That's it. Start Artemis and you've got a basic RGB indicator.

Okay, it was almost that straightforward for me. I have an Uno R3. In recent Arduinos, they dropped the FTDI USB to serial chip in favour of a ATmega16U2. The USB to serial library Thom uses seems to look for any FTDI chip to use as a serial bridge, so I used an FTDI breakout board:

The process with that goes:
  • Upload the sketch over the Arduino's USB.
  • Disconnect the Arduino's USB.
  • Connect the FTDI board's TX pin to the Arduino's RX pin, and the FTDI board's RX to the Arduino's TX.
  • Connect the FTDI board's USB to the computer.
  • Power up the Arduino using an external power supply or battery.
  • Start Artemis.

For any further programming of the Arduino, disconnect its RX pin and hook it back up to the computer via USB.

But hey, why stop at getting the basics working? I wanted the red alert to flash. I wanted seperate indicator lights for the various systems. I wanted...actually that's about it for now.
Arduino sketch
[Last edited Feb 21, 2013 04:30:04]
Login below to reply: