DMX Lights not working when using IrReceiver.begin and DmxSimple

Hi there,
I'm using Arduino Mega2560, IR sensor 1838 (working fine), and some DMX lights (working fine) on port27.
May you tell me please why when I uncomment line 24 IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK, USE_DEFAULT_FEEDBACK_LED_PIN); lights DOESN'T works and when I comment that line lights works as expected ?.
I read about timer handling IR and NeoPixel…and I suppose DmxSimple goes through same way.
I use frequently this kind of DMX lights but now I need to control effects using a IR remote control. I’m very confortable using DmxSimple library…so I must keep using it.

TIA !

#define DECODE_NEC

#include <Arduino.h>
#include <Wire.h> // Start the I2C interface
#include <DmxSimple.h>
#include "PinDefinitionsAndMore.h"
#include <IRremote.h>

const int z_chan1 = 27;
const int lights_uni1 = 10; // amount of lights in universe #1
const int REDRED = 1;
const int GREENGREEN = 2;
const int BLUEBLUE = 3;
int brightness;
int channels;
int y;
unsigned long time_now = 0;

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

// Start the receiver, enable feedback LED and take LED feedback pin from the internal boards definition
// IR_RECEIVE_PIN = pin2
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK, USE_DEFAULT_FEEDBACK_LED_PIN);

}

void loop() {

// RED UNI #1
DmxSimple.usePin(z_chan1);
for (y = 0; y <= lights_uni13; y = y+3){ // lights go 0% brightness
DmxSimple.write(REDRED+y, 0);
DmxSimple.write(GREENGREEN+y, 0);
DmxSimple.write(BLUEBLUE+y, 0);
}
time_now = millis();
while (millis() < time_now + 500) {
}
for (y = 0; y <= lights_uni1
3; y = y+3){
DmxSimple.write(REDRED+y, 255); // lights go 100% brightness
}
time_now = millis();
while (millis() < time_now + 500) {
}

// GREEN UNI #1
DmxSimple.usePin(z_chan1);
for (y = 0; y <= lights_uni13; y = y+3){ // lights go 0% brightness
DmxSimple.write(REDRED+y, 0);
DmxSimple.write(GREENGREEN+y, 0);
DmxSimple.write(BLUEBLUE+y, 0);
}
time_now = millis();
while (millis() < time_now + 500) {
}
for (y = 0; y <= lights_uni1
3; y = y+3){
DmxSimple.write(GREENGREEN+y, 255); // lights go 100% brightness
}
time_now = millis();
while (millis() < time_now + 500) {
}

// BLUE UNI #1
DmxSimple.usePin(z_chan1);
for (y = 0; y <= lights_uni13; y = y+3){ // lights go 0% brightness
DmxSimple.write(REDRED+y, 0);
DmxSimple.write(GREENGREEN+y, 0);
DmxSimple.write(BLUEBLUE+y, 0);
}
time_now = millis();
while (millis() < time_now + 500) {
}
for (y = 0; y <= lights_uni1
3; y = y+3){
DmxSimple.write(BLUEBLUE+y, 255); // lights go 100% brightness
}
time_now = millis();
while (millis() < time_now + 500) {
}
}

But it disables interrupts for the time it is sending the frame, causing the IRremote not to receive properly.
The DmxSimple library is the most inefficient library for sending DMX.
You should switch to a library that utilizes the UART to send DMX frames, like Conceptinetics And your issues will dissolve.

The problem (and a possible solution) is explained here.

short version: change the IRremote timer.

If interrupts get disabled in the DMX library, changing timers will not solve the problem.

Good that you exactly know, what the problem is ;-).

There may be more issues of course, but DmxSimple is bit-banging the DMX frame (which is of course 250kbps, separated by a minimum of 80us break, and inverted logic to normal Serial 8N1, but that usually is corrected in the output of the MAX485 by switching the D+ & D-)

Google the definition of 'if'

Thank you everyone!. I was applied solution explained in

about modifying the comments in private/IRTimer.cpp.h and working as I need and not interfiering with other libs.
Of course, big comment in this ---> "The modification must be renewed for each new IRremote library version, or you use an IDE like [Sloeber. For other platforms you must modify the approriate section guarded by e.g. #elif defined(ESP32)"
but works for me.
Again, cheers everyone.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.