Skip to content

Alignment issue on ESP32-S2 Thing Plus #15

Open

Description

@flupke

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?

Activity

  1. changed the title [-]Stride issue on ESP32-S2?[/-] [+]Alignment issue on ESP32-S2[/+] on May 1, 2024
  2. changed the title [-]Alignment issue on ESP32-S2[/-] [+]Alignment issue on ESP32-S2 Thing Plus[/+] on May 1, 2024
  3. sfe-SparkFro commented on Jun 24, 2024

    @sfe-SparkFro
    Contributor

    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 suspect dmx.update(); isn't being called frequently enough, causing the RX buffer to be overflowed by a random amount before dmx.update(); is called again.

  4. flupke commented on Jul 25, 2024

    @flupke
    Author

    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 suspect dmx.update(); isn't being called frequently enough, causing the RX buffer to be overflowed by a random amount before dmx.update(); is called again.

    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 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions