DMX strobo controller

Hi!

I am playing a bit around with a DMX shield from conceptinetics, and trying to control a light spot to react as a strobo. I have written the following code, which in principle works, but it works rather erratically.

Anybody can spot a reason why this code would not behave correctly?

#include <Conceptinetics.h>

#define DMX_MASTER_CHANNELS   1 

#define RXEN_PIN              2

DMX_Master  dmx_master  (DMX_MASTER_CHANNELS, RXEN_PIN);

int StroboDelay = 0;

void setup() {   
  dmx_master.enable ();  
  dmx_master.setChannelRange (1,25,127);
}


void loop() {
  int Pote = analogRead(A0);

  StroboDelay = map(Pote, 0, 4064, 1000, 10);
  
  dmx_master.setChannelValue (1, 255); 
  delay (10); 
  dmx_master.setChannelValue (1, 0); 
  delay (StroboDelay); 
}

DISCLAIMER - I've never used DMX but I know what it is... :wink:

Is it always erratic, or only with short delays?

Try making StroboDelay a fixed value. Of course you can try different values, but I'd start with a "long" delay like 1000ms.

If that's also erratic, the 10ms delay may be too short... I don't know how fast the DMX library is but you may need to allow more time between DMX messages. Try 100 or 1000ms. (I don't know if "message" is the correct terminology, but you know what I mean...)

If a fixed value works but it gets erratic reading the pot, send Pote to serial monitor (like the Analog Read Serial Example) to make sure it's stable. (It won't be perfectly stable but it shouldn't be erratic or random either.)

You can also send StroboDelay to the serial monitor to make sure that variable "looks good".

It's also possible that you have a hardware problem. Are other functions working? Does conceptinetics give you some known-good sample code, and is that working?

Troubleshooting something like this is very tricky because you have a light (and maybe just one?), a controller, cables (hopefully more than one), and software, and any one of those things can be causing the problem, or you can have multiple problems... In an ideal world, you'd have a known-good controller and a known good light so you can swap whatever you're working on into a known-good setup with only one new-unknown variable.

P.S.
You've probably already checked this but some DMX lamps have a built-in strobe command. Send it one command to start at some flash-rate, then send another command when you want it to stop or when you want to change the flash-rate.

camilozk:
but it works rather erratically.

Yes, I’d expect that, you are likely reading a floating analog pin, or perhaps expecting DMX512 updates to be instant when they take 23ms minimum - your delay may be beating against the DMX delay.

DVDdoug:
If that’s also erratic, the 10ms delay may be too short…

Ey thanks for your feedback! It seems you are right there. I got rid of the pote and realized that something like:

 dmx_master.setChannelValue (1, 255); 
  delay (10); 
  dmx_master.setChannelValue (1, 0); 
  delay (1000);

was also rather erratic. So I started pushing up the value until I saw that I have regularity. I am currently at 30ms

 dmx_master.setChannelValue (1, 255); 
  delay (30); 
  dmx_master.setChannelValue (1, 0); 
  delay (1000);

Having that in mind, I put back the potentiometer and I left the shortest delay at a minimum value of 50ms. It works much better, but it is still not what I was expecting. There is still something there fucking up regularily, specially at high speeds

#include <Conceptinetics.h>

#define DMX_MASTER_CHANNELS   1 

#define RXEN_PIN              2

DMX_Master  dmx_master  (DMX_MASTER_CHANNELS, RXEN_PIN);

int StroboDelay = 1000;

void setup() {   
  dmx_master.enable ();  
  dmx_master.setChannelRange (1,25,127);
}


void loop() {
  int Pote = analogRead(A0);

  StroboDelay = map(Pote, 0, 4064, 1000, 50);
  
  dmx_master.setChannelValue (1, 255); 
  delay (50); 
  dmx_master.setChannelValue (1, 0); 
  delay (StroboDelay); 
}

I have been reading the values from the potentiometer with serial monitor, and the values are correct. I used the following code:

void setup() {
  Serial.begin(9600);
}

void loop() {
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue);
  delay(1);   
}

BUT, I cannot add the Serial.begin(9600); instruction in my strobo code, the compilation doesnt works… I suppose the shield is using Serial to send DMX?

DVDdoug:
P.S.
You've probably already checked this but some DMX lamps have a built-in strobe command. Send it one command to start at some flash-rate, then send another command when you want it to stop or when you want to change the flash-rate.

yes, the light has a built-in strobe, which is rather shitty and not linear at all, that is why I wanted to try and make a very simple controller with arduino, dmx shield and a potentiometer in order to get faster and smoother. It is not working out so easy :slight_smile:

MarkT:
Yes, I'd expect that, you are likely reading a floating analog pin, or perhaps expecting DMX512 updates to be instant when they take 23ms minimum - your delay may be beating against the DMX delay.

Didnt know this... 44hz I read somewhere now...

BUT, I cannot add the Serial.begin(9600); instruction in my strobo code, the compilation doesnt works… I suppose the shield is using Serial to send DMX?

Yeah, you’re probably right… When you use someone else’s library (Conceptinetics.h) you don’t always know what it’s doing… I assume you’d know if they are sharing physical connections.

But, you can still test your pot & your variables by temporarily leaving-out (or “commenting out”) the DMX code.

yes, the light has a built-in strobe, which is rather shitty and not linear at all,

“Non-linear” can be taken care of (with software “calibration”) as long as the strobe rate is constant and covers the range you need.

It is not working out so easy :slight_smile:

It was worth a try! And, sometimes you can learn a lot by trying things that don’t work-out. :wink:

…In the end, you may have to live with whatever “works best” or get a different lamp or a dedicated strobe. I have a DMX controllable strobe (on old one with a Xenon bulb) but I’ve never owned a DMX controller. I just manually and “permanently” set the rate with the knob and I have a “remote” hard-wired power switch to turn it on & off.

And… If you have a multiple DMX lights, you probably shouldn’t be tying-up the DMX controller & bus while “multitasking” by trying to send continuous on/off messages to create a strobe effect while controlling other lamps at the same time. That will only contribute to the erratic behavior.

DVDdoug:
It was worth a try!

definitely. even I am not getting the outcome I was expecting, I am learning a lot about my posibilities for the future, regarding equipment and limitations, and also my own limitations when it comes to programming...

I am a basic user of arduino and I am creating some things with light fixtures, but I am no expert. Nevertheless, I am getting ready to prepare some stand alone systems with arduino / dmx shield and some fixtures, and all of this information is helping me a lot. Thank you very much for discussing!