Repository navigation
Open
Description
Starting from Example2-DMXInput and after finding this comment I changed the example to dmxSerial(1) and enPin = 3 and started receiving values from my DMX controller.
However the values read on channel 1 was changing constantly in a seemingly random way.
I tried to display 192 channels with this code from another comment in the same issue:
#include <SparkFunDMX.h>
SparkFunDMX dmx;
HardwareSerial dmxSerial(1);
uint8_t enPin = 3;
uint16_t numChannels = 192;
void setup()
{
Serial.begin(115200);
Serial.println("SparkFun DMX Example 2 - Input");
dmxSerial.begin(DMX_BAUD, DMX_FORMAT);
dmx.begin(dmxSerial, enPin, numChannels);
dmx.setComDir(DMX_READ_DIR);
Serial.println("DMX initialized!");
}
void loop()
{
while(dmx.dataAvailable() == false)
{
dmx.update();
}
uint8_t data[numChannels];
dmx.readBytes(data, numChannels, 1);
for (int i=0; i < numChannels; i++) {
if (i%32 == 0) {
Serial.printf("\n(%3d) ", i+1);
}
Serial.printf("%3d ", data[i]);
}
Serial.printf("\n");
delay(1000);
}I see values are "shifted" after each read, for example look at how the 134 89 22 sequence moves around between two reads:
1) 0 0 0 0 0 0 0 0 0 0 255 255 160 244 0 0 0 0 0 0 0 0 0 0 0 0 255 255 160 244 0 0
( 33) 0 0 0 0 0 0 0 0 0 0 255 255 160 244 0 0 0 0 0 0 0 0 0 0 0 0 255 255 160 244 0 0
( 65) 0 0 0 0 0 0 0 0 0 0 255 255 160 244 0 0 0 0 0 0 0 0 0 0 0 0 255 255 160 244 0 0
( 97) 0 0 0 0 0 0 0 0 0 0 255 255 160 244 0 0 0 0 0 0 0 0 0 0 0 0 255 255 160 244 0 0
(129) 0 0 0 0 0 0 0 0 0 0 0 0 0 255 247 0 134 89 22 0 0 0 0 0 0 0 0 0 255 255 160 244
(161) 0 0 0 0 0 0 0 0 0 0 0 0 255 255 160 244 0 0 0 0 0 0 0 0 0 0 0 0 255 255 160 244
( 1) 0 0 0 0 0 0 0 0 0 0 255 255 160 244 0 0 0 0 0 0 0 0 0 0 0 0 255 255 160 244 0 0
( 33) 0 0 0 0 0 0 0 0 0 0 255 255 160 244 0 0 0 0 0 0 0 0 0 0 0 0 255 255 160 0 255 255
( 65) 160 244 0 0 0 0 0 0 0 0 0 0 0 0 255 255 160 244 0 0 0 0 0 0 0 0 0 0 0 0 0 0
( 97) 0 255 247 0 134 89 22 0 0 0 0 0 0 0 0 0 255 255 160 244 0 0 0 0 0 0 0 0 0 0 0 0
(129) 255 255 160 244 0 0 0 0 0 0 0 0 0 0 0 0 255 255 160 244 0 0 0 0 0 0 0 0 0 0 0 0
(161) 255 255 160 244 0 0 0 0 0 0 0 0 0 0 0 0 255 255 160 244 0 0 0 0 0 0 0 0 0 0 0 0
Does that ring a bell?
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]Stride issue on ESP32-S2?[/-][+]Alignment issue on ESP32-S2[/+][-]Alignment issue on ESP32-S2[/-][+]Alignment issue on ESP32-S2 Thing Plus[/+]sfe-SparkFro commentedon Jun 24, 2024
Hi there, apologies for the long response time!
This looks like a synchronization issue, which is probably caused by the large percentage of zeros sent by your controller. Could you please try removing the delay from your
loop()? I suspectdmx.update();isn't being called frequently enough, causing the RX buffer to be overflowed by a random amount beforedmx.update();is called again.flupke commentedon Jul 25, 2024
The result is the same without sleep, and the amount of zeros is not something we can control.
It's too late now unfortunately, for my next project (actually the same one but hopefully we'll get it to work this time), I think I'll just use another protocol, dmx seems very hacky and unreliable 🙂