Controlling an LED with DMX

760 views
Skip to first unread message

Marcus Haines

unread,
Jan 10, 2022, 2:39:23 PM1/10/22
to open-lighting
Hi! I am an engineering student currently working on a fun little project where I am building my own DMX-controlled moving light. I have been struggling recently with figuring out how I can receive a DMX signal on something like a raspberry pi and output that as a PWM to control servos and an LED. I came across OLA today and was wondering if I could use this software to do just that: receive DMX and assign channels to variables that I can use python on the pi to output to servos and LEDs. If anyone has any knowledge that might aid me in this, I would greatly appreciate it if you could share.

Thanks!
Marcus

Peter Stuge

unread,
Jan 10, 2022, 4:20:54 PM1/10/22
to open-lighting
Hi Marcus,

Marcus Haines wrote:
> I came across OLA today and was wondering if I could use this
> software to do just that: receive DMX and assign channels to
> variables that I can use python on the pi to output to servos and LEDs.

No.


> If anyone has any knowledge that might aid me in this, I would greatly
> appreciate it if you could share.

Always avoid general-purpose operating systems such as Linux when you
have strict and short timing contraints, which is certainly the case
for DMX reception (µs precision) and perhaps also for the servo control
loops, depending on the servo interface hardware.

General-purpose operating systems and high-level programming languages
such as Python are featureful and convenient but come at the cost of
absolutely massive timing jitter, in proportion to the precision
required in this application.

So, you must use significantly less software. At least for the timing
critical parts.

If you want you can still use Pi hardware. Look at the dedicated Pi
DMX software written by Arjan van Vught:

https://www.raspberrypi-dmx.com/
https://github.com/vanvught/rpidmx512
https://www.raspberrypi-dmx.com/6-rdm-responder-pixel-controller

Note that when e.g. that last page mentions or shows OLA running on a
Pi it is refering to a second Pi with an OLA-compatible DMX interface,
communicating with Arjan's software running on Pi number one.


Arjan's software supports some servo controllers and RGB LEDs so you
would just have to do a little programming to make your own moving
head, but I believe that has to be C or C++.


//Peter

michael

unread,
Jan 10, 2022, 5:22:45 PM1/10/22
to open-l...@googlegroups.com
Hi Marcus,

I agree with Peter. You can do it, but you will not be happy with the outcome. Use a microcontroller such as an STM32. If you learn C and/or C++ they are not so hard to program. Or you can program them with the Arduino environment. If you use one with enough flash and ram you can even use micro python or circuit python, which are python environments developed for microcontrollers.

I would start with C, as there is a ton of examples available. These microcontroĺers have lots of pwm's and I am sure that there are examples on how to control servos or even stepper motors with it. Receiving  DMX512  is easy. It gets trickier with RDM, but you don't need that yet.

I am sure that there are a lot of people here who can help you but  you need to do it, also for learning. Start with a microcontroller evaluation board. You can get reaĺy cheap ones for under $20 that contain everything you need to start with. Some of them come in an arduino form factor with with an interface to upload and debug the code via usb (jtag).
I have seen a arduino DMX512 shield you can hook up to the board and that uses one of the serial ports of the microcontroller board.

If it is a private fun project, you will learn much more and later can even build your own pcb using e.g. KiCad or if it is a school project you can stick to the eval board, as I know schedules sometimes are tight and people tend to take more than they can handle.

You are always welcome to ask for questions as long as you do the work. Remember that you will learn a lot by doing it yourself.

Good luck and best regards
Michael

-------- Ursprüngliche Nachricht --------
Von: Marcus Haines <mar...@mmcentral.net>
Datum: 10.01.22 20:37 (GMT+01:00)
An: open-lighting <open-l...@googlegroups.com>
Betreff: [open-lighting] Controlling an LED with DMX

Hi! I am an engineering student currently working on a fun little project where I am building my own DMX-controlled moving light. I have been struggling recently with figuring out how I can receive a DMX signal on something like a raspberry pi and output that as a PWM to control servos and an LED. I came across OLA today and was wondering if I could use this software to do just that: receive DMX and assign channels to variables that I can use python on the pi to output to servos and LEDs. If anyone has any knowledge that might aid me in this, I would greatly appreciate it if you could share.

Thanks!
Marcus

--
The Open Lighting Project: open-l...@googlegroups.com, #openlighting (irc.freenode.org)
To unsubscribe from this group, send email to open-lightin...@googlegroups.com
For more options, visit https://groups.google.com/groups/opt_out?hl=en
---
You received this message because you are subscribed to the Google Groups "open-lighting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-lightin...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/open-lighting/4b7ea395-4303-48a2-bf97-bd7b730faa3fn%40googlegroups.com.

Peter Newman

unread,
Jan 10, 2022, 5:30:29 PM1/10/22
to open-lighting
On Monday, 10 January 2022 at 21:20:54 UTC pe...@stuge.se wrote:
Hi Marcus,

Marcus Haines wrote:
> I came across OLA today and was wondering if I could use this
> software to do just that: receive DMX and assign channels to
> variables that I can use python on the pi to output to servos and LEDs.

No.

Actually yes, it will work, in terms of if you use one of the dongles or protocols that supports DMX input:

Then the Python API will provide that data from OLA, you can then do anything in Python land with that data that you want. Hell you could probably even use http://docs.openlighting.org/ola/man/man1/ola_trigger.1.html and do it all in Bash!

If you're primarily interested in the mechanical engineering side, or wanted to prototype the hardware side first, that could be a quick way to achieve that.
 
> If anyone has any knowledge that might aid me in this, I would greatly
> appreciate it if you could share.

Always avoid general-purpose operating systems such as Linux when you
have strict and short timing contraints, which is certainly the case
for DMX reception (µs precision) and perhaps also for the servo control
loops, depending on the servo interface hardware.

General-purpose operating systems and high-level programming languages
such as Python are featureful and convenient but come at the cost of
absolutely massive timing jitter, in proportion to the precision
required in this application.

There's at least one fixture which is run on Linux:

Although I'm not clear exactly how much is, whether the mechanical bits run on another processor and the Pi is just running the media server bit.

There are also an ever growing list of entertainment related products running on Linux (or even Windows), from many lighting desks though to media servers and even equivalent systems like camera robotics.
 
So, you must use significantly less software. At least for the timing
critical parts.

If you want you can still use Pi hardware. Look at the dedicated Pi
DMX software written by Arjan van Vught:

Personally I've never really quite understood the point of using such a powerful processor as essentially a glorified microcontroller. There are also equivalent libraries for Arduino and Teensy at least:

Peter Newman

unread,
Jan 10, 2022, 5:33:46 PM1/10/22
to open-lighting
On Monday, 10 January 2022 at 22:22:45 UTC mic...@cubic.org wrote:
I would start with C, as there is a ton of examples available. These microcontroĺers have lots of pwm's and I am sure that there are examples on how to control servos or even stepper motors with it. Receiving  DMX512  is easy. It gets trickier with RDM, but you don't need that yet.

If you want to do RDM (and probably for DMX too) there are the libraries I linked to above, which will deal with all the complicated bits, so you just need to deal with the stuff specific to your particular fixture.

michael

unread,
Jan 10, 2022, 5:34:30 PM1/10/22
to open-l...@googlegroups.com
Hi Marcus,

I would also recommend that you search for an eval board and present it here and we can have a discussion about it.

Btw. Is it a private project or part of your school education. I am from Germany, but where ever you school is, I am pretty sure that the teacher not only gives points for the most complicated but also for the most elegant solution and if not everything works perfect it is ok as long as you describe the path and the decisions that lead to it. And you can tell if you are in discussion with experts and professionals.

Michael

Marcus Haines

unread,
Jan 11, 2022, 10:28:50 AM1/11/22
to open-lighting
Thanks everyone for these replies! Yes, this is a school project and yes, it does have some relatively tight deadlines, even though this is a year-long project. My original plan was to use an Arduino UNO and a DMX shield, both of which I have, to receive DMX probably from a GrandMA 1 console (the place I run lights for has an old one lying around). The probelm I ran into yesterday and actually the reason I made a post here after finding OLA was related to Arduino's difficulty with driving 330hz servos. I believe I found a fix for that by editing the timing in the servo.h driver but I haven't had a chance to test that yet. 

Peter, thanks so much for providing links to your library! I'll be honest and say that I'm new to microcontrollers and coding in general, and am unsure of how exactly to download each of those tools you provided. Also, is RDM necessary for my application? I'll be honest again and say I've never heard of nor thought about RDM and so I'm not exactly sure what it does, but from what I've read it seems like an add-on to DMX which just gives a few extra monitoring features, but please correct me if I'm wrong. 

So I guess the new question since it seems like the Arduino stuff I have will work is which of these libraries do I need, what's the best way to install them, and where can I find a list of all of the commands these libraries have so I can start to play around with them? Being extremely inexperienced with coding, this project is getting more complex by the second and I really appreciate all of your help!

Stefan Krüger

unread,
Jan 11, 2022, 1:54:50 PM1/11/22
to open-lighting
Hi Marcus,
sounds like a great project!

regarding RDM your are correct:
RDM = Remote Device Management - is a sort of addon -
i would say youst ignore that it is a option for now.. could be a nice addon if your done with all other things..
Peter linked to the DMXSerial2 library - that is for RDM.
Matthias Hertel (the author of this library) has also a simpler one with only DMX:
https://github.com/mathertel/DMXSerial
(that link links to the github website - github is a place where people can upload and manage software projects....)
check out this link on how to install  libraries in arduino:

if you have installed the library you can check out the included examples on how to use it:
to start with DMX-Receiving have a look at DmxSerialRecv
they are available via the menu in the arduino ide:
Arduino 1.8.19 - Library Example - DMXSerial .jpg
or you look at the repository:

if you than have a missing thing you can look up the source code if there is a function you do not know about:
https://github.com/mathertel/DMXSerial/blob/master/src/DMXSerial.h
for a *first time software* thing  that is sometimes a bit puzzling at first...

in the Arduino IDE itself you also have a bunch of *buildin* examples.
you can also find them in the official documentation:
https://docs.arduino.cc/built-in-examples/

if you plan on buy a second/new arduino board i recommend the Leonardo version -
as it has a Serial Port and build in USB-controller -
this way you can use the Serial.print() statements to debug code and at the same time send dmx with the Hardware Serial Port (USART).
with an Arduino UNO you only can do one of the two things simultaneously...


for now Offtopic:
in a fare future CircuitPython could be also an option...
Adafruit sells really nice boards - my favorite is the ItsiBitsy M4
its a SAMD51 Cortex M4 with 512KB Flash and 192KB RAM - running @120 MHz...
and running the CircuitPython interpreter - so you can really code this thing in python :-)
but currently there is no proven way to generate or receive DMX with CircuitPython...
you can also use this board with arduino - then it is really really nice and fast -
but again - i don't know of a working DMX library for this platform/board...




and if there are any questions left -
i am willing to help ;-)

sunny greetings
stefan

Marcus Haines

unread,
Jan 11, 2022, 2:35:16 PM1/11/22
to open-lighting
Hi Stefan and thank you for taking the time to reply! I apologize if this is a duplicate message for you - I am still figuring out Google Groups :)

DMXSerial looks like it will be the perfect library for my use case, and I had just a couple of questions I was hoping you could help me with. To start, I understand that I need lots more practice and time researching coding, especially for the arduino as it seems its language is much more complicated than Python, which many of my classmates are using for their projects.

Using this library, is there a way to assign incoming DMX channels to variables that I can use to send instructions to my servos and LED? For example, if DMX channel 1 is the red channel of my led, can I assign that channel to a variable which I will name CH1 for this example and then use an if then statement to write that variable to the LED? So basically I'd say something along the lines of if CH1 is at 100%, digitalWrite(RedLED, 100);? I'd just have to make sure to assign RedLED to the right pin on my arduino in setup.

If this is something I can do, I'd love it if you would be able to point me to an example that I can adapt for my project. If I'm totally wrong here, what is the best way to approach this?

Thanks!
Marcus

Stefan Krüger

unread,
Jan 11, 2022, 3:10:27 PM1/11/22
to open-lighting

Hi Marcus,

all fine ;-)

arduino is not in itself more complicated than Python.
i love the syntax of Python - and some things are a bit easier to understand than in C++…
in general the thinking concept behind most programming languages is very similar -
and for Python and C++ definitly… it is more of a syntax thing…
(at least for this simple things we speak about here…)

regarding the Send and Receive:
DMX is a chained system:
there is only one active sender - that is your control desk.
all other devices are just receivers.
they are all wired daisy-chained:

SENDER -------------+-------------+---------
                    |             |
                    device         device

the stub-line should be as short as possible (<3cm if i remember correctly)
therefore the devices have an input and output plug on the housing -
internally these two are directly connected with wires..
so with your Arduino UNO that is all fine.

what i meant is that you are only able to use the Serial.print() functions if you are not receiving DMX at the same time..

have you had a look at the example?
https://github.com/mathertel/DMXSerial/blob/master/examples/DmxSerialRecv/DmxSerialRecv.ino

basically it is exactly doing what you requested.
it is only adding a check for a missing dmx value and if so a fallback value for the leds..

.

in an absolute minimal way for receiving dmx values is this:


#include <DMXSerial.h>

void setup() {
    DMXSerial.init(DMXReceiver);
}

void loop() {
    int this_channel_value = DMXSerial.read(theDMXchannelToRead);
    // do something with the value stored in *this_channel_value*
}

Could I assign channel 1 to a variable and write something along the lines of if channel 1 is at 100%, digitalWrite(RedLED, 100);?

as i written - yes that is exactly what the example does!
it only uses the correct function analogWrite()
as digitalWrite() can only set the output to HIGH or LOW (=ON / OFF)
where analogWrite() does create a PWM on the output.(have a read in the linked reference page.)
there is also an build in Example for fading - look into it


i suggest test all your parts one after the other:

leds changing brightness
motors moving the way you want

and than combining this with the dmx receiving…
and here also add one after the other…
so it is easier to catch bugs earlier and it is easier to find & fix them…

sunny greetings
stefan

Marcus Haines

unread,
Jan 11, 2022, 3:24:41 PM1/11/22
to open-lighting
Hi Stefan! 

I just took a look at that example you provided and it is perfect! It looks like I'll be able to modify that to be perfect for my project and the syntax logically makes quite a bit of sense. Reading through it, I was a bit confused in the section where it was defining the channels for the Arduino to watch, beginning on line 28:


// This Example receives the 3 values starting with this channel:

const int startChannel = 0 * 3 + 1;

#define RedDefaultLevel 100
#define GreenDefaultLevel 200
#define BlueDefaultLevel 255

void setup() {
DMXSerial.init(DMXReceiver);

// set some default values

DMXSerial.write(1, 80);

DMXSerial.write(2, 0);
DMXSerial.write(3, 0);


Ignoring the three lines where it was defining default values, would you be able to explain what these other lines do and how the startChannel command works?

Additionally, would I need any other drivers or config commands in order to make the Arduino read from the RX port? I ordered the CQRobot DMX Shield and that communicates using the RX port, and from what I've read, this library reads from that port but I didn't know if I needed to use a line of code to enable it or if that example code will be what I need to get up and running on a basic level.

Thanks!
Marcus

michael

unread,
Jan 11, 2022, 5:45:46 PM1/11/22
to open-l...@googlegroups.com
Hi Marcus,
Such a project is never easy but in the end you learn a lot, even if you think you didn't .
Managing the project is as important as doing the tech stuff. In every project you have the risc that something fails. For managing failures there is a tool called FMEA (Failure Mode and Effects Analysis). It can be as simple a a table of possible riscs, the probability for the risc to happen, its impact for the project, what you can do if the risc happens and if or what you can find out about the risc. 
One example could be the servos. You are not shure if the arduino can properly control the servos at all. It has some probability. What can you do to find out? You can search for existing implementations and examples and try them out. Are there any options if the problem manifests itself. You can check for a chip that you can control via i2c, that can control the servos or you may order a different arduino board that supports controlling the servos properly.

There is no magic behind an FMEA. The power of it is that you make a list of any risc you can think of upfront and update it the lifetime of the project. You can prioritize the riscs and start with the show shoppers and work yourself down to the ones that introduce lower riscs. It will change over time while you discover new riscs and solve existing ones.

The grandma1 is a pretty nice console. I was part of the development team of the grandma2 software.

You do not need RDM. You can start with a fixed address and add address dip switches later and use the DMX layout of a fixture that the your grandma1 all ready knows.

I correct myself. Arduino might be the better to start with.

A great project has a great project manager.

Michael

-------- Ursprüngliche Nachricht --------
Von: Marcus Haines <mar...@mmcentral.net>
Datum: 11.01.22 16:28 (GMT+01:00)
An: open-lighting <open-l...@googlegroups.com>
Betreff: Re: [open-lighting] Controlling an LED with DMX

--
The Open Lighting Project: open-l...@googlegroups.com, #openlighting (irc.freenode.org)
To unsubscribe from this group, send email to open-lightin...@googlegroups.com
For more options, visit https://groups.google.com/groups/opt_out?hl=en
---
You received this message because you are subscribed to the Google Groups "open-lighting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-lightin...@googlegroups.com.

michael

unread,
Jan 11, 2022, 6:04:05 PM1/11/22
to open-l...@googlegroups.com
Just ignore the strange start channel calculation. It looks overcomplucated to me.

The dmx shield looks perfect. To start easy you can configure it as slave only (slave mode) and not need to care about the enable/disable of the transmitter. Perfect choice to start with.

Michael


Von meinem Samsung Galaxy Smartphone gesendet.

-------- Ursprüngliche Nachricht --------
Von: Marcus Haines <mar...@mmcentral.net>
Datum: 11.01.22 21:24 (GMT+01:00)
An: open-lighting <open-l...@googlegroups.com>
Betreff: Re: [open-lighting] Controlling an LED with DMX

--
The Open Lighting Project: open-l...@googlegroups.com, #openlighting (irc.freenode.org)
To unsubscribe from this group, send email to open-lightin...@googlegroups.com
For more options, visit https://groups.google.com/groups/opt_out?hl=en
---
You received this message because you are subscribed to the Google Groups "open-lighting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-lightin...@googlegroups.com.

Marcus Haines

unread,
Jan 12, 2022, 11:32:57 AM1/12/22
to open-lighting
Sounds good, Thanks Stefan! Just reading through the code again before I begin to write my first draft, what do lines 38-41 do?

// set some default values

DMXSerial.write(1, 80);

DMXSerial.write(2, 0);

DMXSerial.write(3, 0);


I understand everything but these default values. Would you be able to provide some insight? I tried reading through the github but I couldn't find any documentation on these default values.

Thanks! Marcus
Message has been deleted

Stefan Krüger

unread,
Jan 12, 2022, 1:46:53 PM1/12/22
to open-lighting

i think with these default values it does this:
*write value 80 to the library internal dmx channel 1
and so on.

i think you can just ignore them.
that is what i have done in my minimal example i gave in the second response..
(i stripped out all the other stuff form the official example that is addon / nice to have.)
here with an analogWrite added:

#include <DMXSerial.h> 

const int ledPin = 9;
 void setup() {     DMXSerial.init(DMXReceiver);
   // setup pin 9 as output..
    pinMode(ledPin, OUTPUT); }  void loop() {     int this_channel_value = DMXSerial.read(theDMXchannelToRead);     // do something with the value stored in *this_channel_value*
    // for example set an LED brightness:
    analogWrite(ledPin, this_channel_value); }

i did not test it. but i think it is the minimum needed to read only one channel and set an led to the received value.

Stefan Krüger

unread,
Jan 12, 2022, 1:48:59 PM1/12/22
to open-lighting

now with correct indentation in the code...
sorry for the multi-posts..

michael

unread,
Jan 12, 2022, 2:17:39 PM1/12/22
to open-l...@googlegroups.com
Hi Marcus

Most moving lights have a home Position which is straight up, open iris, no gobos, dimmer off.
These default values might be used if no dmx is received for one second.

Michael

Von meinem Samsung Galaxy Smartphone gesendet.

-------- Ursprüngliche Nachricht --------
Von: Marcus Haines <mar...@mmcentral.net>
Datum: 12.01.22 17:32 (GMT+01:00)

Marcus Haines

unread,
Jan 12, 2022, 2:29:56 PM1/12/22
to open-lighting
Hi Michael and thank you for this input. To my understanding, this home position is defined beginning on line 61 of the demo code in the else statement. For now, I have decided to exclude these "default values" from my draft code which I will post below for y'all to take a look at. I just wrote this today and haven't brought the console into school yet to test this but I'm hoping it will work.


#include <Servo.h>
#include <DMXSerial.h>

const int RLED = 9;
const int GLED = 10;
const int BLED = 11;
const int enPIN = 13;
Servo PAN;
Servo TILT;
Servo ZOOM;

const int startChannel = 1;   //start reading at DMX channel 1

#define RedDefaultLevel   0   //If DMX is lost, return to these values
#define GreenDefaultLevel 0   //^
#define BlueDefaultLevel 0   //^

void setup() {
  DMXSerial.init(DMXReceiver);
 
  PAN.attach(3);
  TILT.attach(5);
  ZOOM.attach(6);

  pinMode(RLED, OUTPUT);
  pinMode(GLED, OUTPUT);
  pinMode(BLED, OUTPUT);

  digitalWrite(enPIN, LOW);
}

void loop() {
  unsigned long lastPacket = DMXSerial.noDataSince();

  if (lastPacket < 5000) {
    analogWrite(RLED, DMXSerial.read(startChannel));
    analogWrite(GLED, DMXSerial.read(startChannel + 1));
    analogWrite(BLED, DMXSerial.read(startChannel + 2));
    PAN.write(DMXSerial.read(startChannel + 3));
    TILT.write(DMXSerial.read(startChannel + 4));
    ZOOM.write(DMXSerial.read(startChannel + 5));
  }

  else {
    analogWrite(RLED, RedDefaultLevel);
    analogWrite(GLED, GreenDefaultLevel);
    analogWrite(BLED, BlueDefaultLevel);
    PAN.write(135);
    TILT.write(135);
    ZOOM.write(135);
  }
}

michael

unread,
Jan 12, 2022, 4:25:14 PM1/12/22
to open-l...@googlegroups.com
Hi Marcus,
I don't know much about arduino but from the logical point of view this looks right. And if it work it is much fewer work than with the raspberryPi and python.

Michael


Von meinem Samsung Galaxy Smartphone gesendet.

-------- Ursprüngliche Nachricht --------
Von: Marcus Haines <mar...@mmcentral.net>
Datum: 12.01.22 20:29 (GMT+01:00)

Peter Stuge

unread,
Jan 13, 2022, 4:11:23 AM1/13/22
to open-lighting
Marcus Haines wrote:
> To my understanding, this home position is defined beginning on
> line 61 of the demo code in the else statement.

Yes and no. setup() runs exactly once, before loop() is called the first time.

I believe the else statement in loop() only runs after DMX frame reception.

If no home position is set in setup() then the fixture will stay in
some random state until it receives a DMX frame, including lights
possibly being on.

That's not critical, but probably not something you want in the final result.


//Peter

Marcus Haines

unread,
Jan 13, 2022, 9:14:29 AM1/13/22
to open-l...@googlegroups.com
Oh ok interesting. The way I had thought of the code was basically it saying “if I receive DMX, do it. Else, go to a home position” but what you are saying makes sense and I'll have to play around with that once I get the MA1 in which will hopefully be Tuesday.

Because this project will eventually end with me writing a paper, what would you all like me to do to cite your help? I know I’ll do one for the DMXSimple GitHub but is there any special way that anyone that has responded here would like to be cited?

--
The Open Lighting Project: open-l...@googlegroups.com, #openlighting (irc.freenode.org)
To unsubscribe from this group, send email to open-lightin...@googlegroups.com
For more options, visit https://groups.google.com/groups/opt_out?hl=en
---
You received this message because you are subscribed to the Google Groups "open-lighting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-lightin...@googlegroups.com.

michael

unread,
Jan 13, 2022, 12:20:44 PM1/13/22
to open-l...@googlegroups.com
From my perspective it is ok if convention OLA and add a link to the open lighting mailing list. We just gave you some info and support that you used for your decision making and for writing You code.

In.my Diploma I had a chapter where I wrote down all the possible designs with its implications and one chapter with the decision and the reason for my decision.

One thing you can do is to show the outcome. Make some photos or a video with the final setup. That would be great. Btw I also learned something.

Michael


Von meinem Samsung Galaxy Smartphone gesendet.

-------- Ursprüngliche Nachricht --------
Von: Marcus Haines <mar...@mmcentral.net>
Datum: 13.01.22 15:14 (GMT+01:00)
Betreff: Re: [open-lighting] Controlling an LED with DMX

Stefan Krüger

unread,
Jan 14, 2022, 3:51:45 PM1/14/22
to open-lighting

The way I had thought of the code was basically it saying “if I receive DMX, do it. Else, go to a home position”

thats exactly what the code does!

sunny greetings
stefan

Peter Stuge

unread,
Jan 14, 2022, 6:30:10 PM1/14/22
to open-lighting
Peter Stuge wrote:
> Yes and no. setup() runs exactly once, before loop() is called the first time.
>
> I believe the else statement in loop() only runs after DMX frame reception.

So to not believe anymore I looked closer, and my belief was wrong.

The noDataSince() call does not block (wait for frame) as I thought,
it immediately returns the milliseconds since the last received DMX
frame.


> If no home position is set in setup() then the fixture will stay in
> some random state until it receives a DMX frame, including lights
> possibly being on.

The way I read the code this still seems to hold true however, at
least for five seconds, because DMXSerialClass::init() sets
_dmxLastPacket to the current time, creating the appearance that a
frame was successfully received when the firmware starts up, meaning
that the example code only goes to home 5000 ms after starting.


Marcus Haines wrote:
> Oh ok interesting. The way I had thought of the code was basically it
> saying “if I receive DMX, do it. Else, go to a home position” but what you
> are saying makes sense and I'll have to play around with that once I get
> the MA1 in which will hopefully be Tuesday.

Close! It's rather "if I received a DMX frame less than 5000 ms ago, do it.
Else, go to a home position."


Any simple citation mentioning the project is fine for me as well.

//Peter

Stefan Krüger

unread,
Jan 15, 2022, 6:05:15 AM1/15/22
to open-lighting

i did not think of this initial case…

i thikn that is the case why the original example sets some initial values to the internal dmx slots..
and i think it is more consitent if he would usethe default values at this place to:

void setup() {
  DMXSerial.init(DMXReceiver);

  // set some default values

  DMXSerial.write(1, RedDefaultLevel);
  DMXSerial.write(2, GreenDefaultLevel);
  DMXSerial.write(3, BlueDefaultLevel);

  // enable pwm outputs
  pinMode(RedPin,   OUTPUT); // sets the digital pin as output
  pinMode(GreenPin, OUTPUT);
  pinMode(BluePin,  OUTPUT);
}

a cite / link here is also fine for me!
and i love to see some photos from your final build :-)

sunny greetings
stefan

Marcus Haines

unread,
Jan 21, 2022, 1:55:21 PM1/21/22
to open-lighting
Thank you all so much for all of your help! Today, I was able to plug everything together and the code has worked flawlessly, although I ran out of time to test the "home" code we've previously been discussing. Attached is a link to the video of the successful test!

I did run into some interesting problems I was not expecting along the way. Namely, the red and green channels of the LED did not dim at all but the blue channel did. Additionally, as the second video shows, the LED does not like turning white. If I set the red and green channels to full and then slowly fade up the blue channel, the LED will get dimmer and dimmer and eventually turn off once the signal for the blue channel reaches 100%, as the video shows (the GrandMA1 denotes 100% as "FF"). I believe this is an issue with power and not with cooling or the code because all seems to be working properly. Next week I will test current draw and voltage levels across all three channels to verify this. Do you all have any thoughts on this issue?

Here are the videos (I hope I shared this link properly)

michael

unread,
Jan 21, 2022, 3:18:14 PM1/21/22
to open-l...@googlegroups.com
I am happy to see that it works. Have you opened a end sheet on grandma1 to see if the choosen fixture outputs dmx as expected. The grandma2 has a dmx tester function in the dmx sheet. I do not remember if the grandma1 also has it.

It smells like there is a problem with the current.
Can you draw a small schematic that shows how you connected the LEDs? You need to make a schematic anyway.
Each led color must have its own series resistor between the led and the port. If the LEDs are to strong and draw too much current you need to add a transistor for each colour to drive it. You can use a mosfet or a bipolar transistor. The internet will show you how to drive an led via a transistor, if necessary.



Von meinem Samsung Galaxy Smartphone gesendet.

-------- Ursprüngliche Nachricht --------
Von: Marcus Haines <mar...@mmcentral.net>
Datum: 21.01.22 19:55 (GMT+01:00)
An: open-lighting <open-l...@googlegroups.com>
Betreff: Re: [open-lighting] Controlling an LED with DMX

--
The Open Lighting Project: open-l...@googlegroups.com, #openlighting (irc.freenode.org)
To unsubscribe from this group, send email to open-lightin...@googlegroups.com
For more options, visit https://groups.google.com/groups/opt_out?hl=en
---
You received this message because you are subscribed to the Google Groups "open-lighting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-lightin...@googlegroups.com.

Marcus Haines

unread,
Jan 21, 2022, 3:28:22 PM1/21/22
to open-l...@googlegroups.com
I do have a schematic, but it is outdated and I should redraw it, you’re right. However, A relevant schematic can be found here:

This is the driver I am using for the LED. Using an external power supply to drive the light, this board accepts the 5V signal from the arduino and steps it up to the 30V signal the LED expects. Each channel when tested individually works fine, and even two channels at a time works fine. It’s just that when any third channel is added everything flakes out. Next class, I will do some testing on the power draw and see if I can come to any conclusions. I also talked to some of my friends and they mentioned that I could use the analog pins as an output from the arduino instead of the digital pins I am using now (9,10,11 on the UNO for R,G, and B respectively). I will try that and see if it fixes the red and green not dimming issue.

For additional information, I made my own custom fixture profile on a mostly fresh show file on the MA1 (I was rushing and forgot how to create a blank show file so I duplicated an old one and cleared out the patch and fixture schedule and called it good enough). Red, green, and blue are channels 1, 2, and 3 with pan, tilt, zoom on 4,5,6. And these match what I hard coded in the arduino software.

-Marcus

Stefan Krüger

unread,
Jan 22, 2022, 1:33:16 PM1/22/22
to open-lighting

woow cool to see progress!!! thanks for sharing the videos with us!
i would suggest to use tree individual simple small LEDs on the arduino output pins (with series resistors of course…(150R should be fine for testing with the 5V output…)
that way you know that your software is working…

and i just hat a look at the led-driver:

Apply logic level PWM signal (3.3V or 5V, 100-2000 Hz) to RED, GREEN and BLUE pins to display colors and change brightness. If no control signal is present the RGB-LED won’t turn on.

if you have a oscilloscope this would help to check how the pwm signal looks that gets to the driver board..
check at the arduino documentation - maybe its possible to use a slower pwm frequency -(i don’t know out of my head..)
that also could help…

sunny greetings
stefan

Thomas White

unread,
Jan 23, 2022, 5:20:15 PM1/23/22
to open-l...@googlegroups.com
Hi Marcus,

Is the DMX line terminated? There must be a 120 Ohm resistor between
the DMX signal lines at the far end of the run (i.e. close to your test
fixture). If not, there will be signal reflections leading to all
kinds of shenanigans, including behaviour similar to what you seem to
have.

Best wishes,

Tom


On Fri, 21 Jan 2022 10:55:21 -0800 (PST)
Marcus Haines <mar...@mmcentral.net> wrote:

> Thank you all so much for all of your help! Today, I was able to plug
> everything together and the code has worked flawlessly, although I
> ran out of time to test the "home" code we've previously been
> discussing. Attached is a link to the video of the successful test!
>
> I did run into some interesting problems I was not expecting along
> the way. Namely, the red and green channels of the LED did not dim at
> all but the blue channel did. Additionally, as the second video
> shows, the LED does not like turning white. If I set the red and
> green channels to full and then slowly fade up the blue channel, the
> LED will get dimmer and dimmer and eventually turn off once the
> signal for the blue channel reaches 100%, as the video shows (the
> GrandMA1 denotes 100% as "FF"). I believe this is an issue with power
> and not with cooling or the code because all seems to be working
> properly. Next week I will test current draw and voltage levels
> across all three channels to verify this. Do you all have any
> thoughts on this issue


--
Thomas White <t...@bitwiz.me.uk> <t...@physics.org>

Marcus Haines

unread,
Jan 24, 2022, 9:11:57 AM1/24/22
to open-l...@googlegroups.com
Hi Tom and thanks for that question. Yes, I do have a DMX terminator installed and it is functioning properly. 

I am also in contact with the guy that made the LED controller I am using and he is helping me diagnose the problem by sending me some arduino code to help function check everything.

--
The Open Lighting Project: open-l...@googlegroups.com, #openlighting (irc.freenode.org)
To unsubscribe from this group, send email to open-lightin...@googlegroups.com
For more options, visit https://groups.google.com/groups/opt_out?hl=en
---
You received this message because you are subscribed to the Google Groups "open-lighting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-lightin...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages