Giter VIP home page Giter VIP logo

sparkfundmx's Introduction

SparkFun DMX Library

SparkFun ESP32 DMX to LED Shield

SparkFun ESP32 DMX to LED Shield(DEV-15110)

The SparkFun ESP32 DMX to LED Shield is capable of DMX output, input, as well as Artnet input. The shield is electrically isolated to keep with DMX spec. This library has been written to control DMX output and input.

Library written by Andy England (SparkFun) with help from code written by Matt Tong.

Repository Contents

  • /examples - Example sketches for the library (.ino). Run these from the Arduino IDE.
  • /src - Source files for the library (.cpp, .h).
  • keywords.txt - Keywords from this library that will be highlighted in the Arduino IDE.
  • library.properties - General library properties for the Arduino package manager.

Documentation

License Information

This product is open source!

Various bits of the code have different licenses applied. Anything SparkFun wrote is beerware; if you see me (or any other SparkFun employee) at the local, and you've found our code helpful, please buy us a round! Anything Maxim wrote has its own license. Anything that was co-writing with Peter Jansen is BSD.

Please use, reuse, and modify these files as you see fit. Please maintain attribution to SparkFun Electronics and release anything derivative under the same license.

Distributed as-is; no warranty is given.

  • Your friends at SparkFun.

sparkfundmx's People

Contributors

andyengland521 avatar blinxfox avatar sfe-sparkfro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sparkfundmx's Issues

Wrong Enable Pin declared in library

This has cost me soooooo much time :-S
The actual pin used on the Sparkfun DMX Shield for DMX Enable via UART Port1 are:

//SparkFunDMX.cpp
...
int enablePin = 4;		// <--- not 21!!! 
int rxPin = 16;
int txPin = 17;
...

and not GPIO21 as the DMX library code (line 18) suggests.

Thanks for updating this!

Simultaneous send & receive operation

I'd like to send and receive DMX data in the same sketch. It looks to me like the library is only intended for one or the other so it definitely will need modification but I think the only issue would be making sure it doesn't receive the same data it transmitted. So just turn off the receiving while sending?

PIN 13 usage

SparkFunDMX.cpp:80 configures pin 13 as output:
pinMode(13, OUTPUT)

but that pin looks unused. Is it intended? And why is the 13 hardcoded?

authorship and licensing

The README.md file says:

Library written by Andy England (SparkFun) with help from code written by Matt Tong.

And the LICENSE.md file says the code is licensed under the MIT license.

However, SparkFunDMX.h and SparkFunDMX.cpp contain the text:

// Copyright (C) 2015  Rick <[email protected]>
// This work is licensed under a GNU style license.

This is a completely different author and license. I am confused. (Also, it is not clear what is meant by "GNU style". Either it's under some specific version of the GPL or LGPL, or it's not.)

Unable to control a DMX PAR light

I've set up a Sparkfun DMX controller board with a Thing Plus ESP32 WROOM. That's wired to a single EasyDancer DMX Par light with an XLR cable and a terminator. Have tried loading a basic test program but it doesn't seem to work.

The documentation on the light lists:

CH1=brightness
CH2=red
CH3=green
CH4=blue

You can also set a value called "DMX Mode" to 001-512. I've kept it at the default 001 to keep things simple.

The code on the ESP32 is as follows:

#include <SparkFunDMX.h>
SparkFunDMX dmx;

#define TOTAL_CHANNELS 4
// For EasyDancing Par light
//
#define BRIGHTNESS_CHANNEL 1
#define RED_CHANNEL 2
#define GREEN_CHANNEL 3
#define BLUE_CHANNEL 4

char buffer[1000];
char value = 0;

void setup() {
  Serial.begin(115200);
  delay(3000);
  dmx.initWrite(TOTAL_CHANNELS);
  Serial.println("initialized...");
}

void loop() {
    value += 1;
    if (value == 255) {
      value = 0;
    }
    dmx.write(BRIGHTNESS_CHANNEL, value);
    dmx.write(RED_CHANNEL, 128);
    dmx.write(GREEN_CHANNEL, 0);
    dmx.write(BLUE_CHANNEL, 0);
    dmx.update();

    sprintf(buffer, "Channel: %d - Value: %d\n", BRIGHTNESS_CHANNEL, value);
    Serial.print(buffer);
    delay(100);
}

The idea was for this to set the light to red and then gradually raise brightness level from 0 to 255 and then start over again. But instead no light comes on and then every once in a while get a flash of blue or red.

Then I put the output of the DMX shield under a Saleae logic analyzer and this is what I got:

Time [s] | Decoded Protocol Result
4.23998214 | BREAK
4.43996637 | Mark After Break
4.44005949 | start bit
4.44006349 | START CODE: '248' (0xF8)
4.44009548 | stop bits
4.44010349 | MARK Time after Slot
4.44011143 | start bit
4.44011543 | Slot 1: '250' (0xFA)
4.44014742 | stop bits
4.44015543 | start bit
4.44015943 | Slot 2: '254' (0xFE)
4.44019142 | stop bits
4.44019943 | start bit
4.44020343 | Slot 3: '254' (0xFE)
4.44023542 | stop bits
4.44024343 | start bit
4.44024743 | Slot 4: '254' (0xFE)
4.44027942 | stop bits
4.44028743 | start bit
4.44029143 | Slot 5: '254' (0xFE)
4.44032342 | stop bits
4.44033143 | MARK Time after Slot
4.44053893 | BREAK
4.4411789 | Mark After Break
4.44309893 | start bit
4.44310293 | START CODE: '0' (0x00)
4.44313492 | stop bits
4.44314292 | BREAK
4.53985066 | Mark After Break
4.53994015 | start bit
4.53994415 | START CODE: V (0x56)
4.53997614 | stop bits
4.53998415 | MARK Time after Slot
4.53998425 | start bit
4.53998825 | Slot 1: r (0x72)
4.54002024 | stop bits
4.54002825 | start bit
4.54003225 | Slot 2: & (0x26)
4.54006424 | stop bits
4.54007225 | start bit
4.54007625 | Slot 3: '158' (0x9E)
4.54010824 | stop bits
4.54011625 | start bit
4.54012025 | Slot 4: 2 (0x32)
4.54015224 | stop bits
4.54016025 | start bit
4.54016425 | Slot 5: '186' (0xBA)
4.54019624 | stop bits
4.54020425 | start bit
4.54020825 | Slot 6: '224' (0xE0)
4.54024024 | stop bits
4.54024825 | MARK Time after Slot
4.54054756 | start bit
4.54055156 | Slot 7: '0' (0x00)
4.54058355 | stop bits
4.54059155 | BREAK
4.54118755 | Mark After Break
4.54150759 | start bit
4.54151159 | START CODE: '0' (0x00)
4.54154358 | stop bits
4.54155158 | BREAK
4.63985031 | Mark After Break
4.63993984 | start bit
4.63994384 | START CODE: b (0x62)
4.63997583 | stop bits
4.63998384 | start bit
4.63998784 | Slot 1: '242' (0xF2)
4.64001983 | stop bits
4.64002784 | start bit
4.64003184 | Slot 2: '158' (0x9E)
4.64006383 | stop bits
4.64007184 | start bit
4.64007584 | Slot 3: '178' (0xB2)
4.64010783 | stop bits
4.64011584 | MARK Time after Slot
4.64011593 | start bit
4.64011993 | Slot 4: '138' (0x8A)
4.64015192 | stop bits
4.64015993 | start bit
4.64016393 | Slot 5: b (0x62)
4.64019592 | stop bits
4.64020393 | MARK Time after Slot
4.64022724 | BREAK
4.64118721 | Mark After Break
4.64150725 | start bit
4.64151125 | START CODE: '0' (0x00)
4.64154324 | stop bits
4.64155124 | BREAK
4.73984997 | Mark After Break
4.73993946 | start bit
4.73994346 | START CODE: j (0x6A)
4.73997545 | stop bits
4.73998346 | MARK Time after Slot
4.73998356 | start bit
4.73998756 | Slot 1: '170' (0xAA)
4.74001955 | stop bits
4.74002756 | start bit
4.74003156 | Slot 2: '158' (0x9E)
4.74006355 | stop bits
4.74007156 | start bit
4.74007556 | Slot 3: r (0x72)
4.74010755 | stop bits
4.74011556 | start bit
4.74011956 | Slot 4: '150' (0x96)
4.74015155 | stop bits
4.74015956 | start bit
4.74016356 | Slot 5: f (0x66)
4.74019555 | stop bits
4.74020356 | MARK Time after Slot
4.7402269 | BREAK
4.74118687 | Mark After Break
4.7418269 | start bit
4.7418309 | START CODE: '0' (0x00)
4.74186289 | stop bits
4.74187089 | BREAK
4.74214686 | Mark After Break
4.7427869 | start bit
4.7427909 | START CODE: '0' (0x00)
4.74282289 | stop bits
4.74283089 | BREAK
4.83984963 | Mark After Break
4.83993915 | start bit
4.83994315 | START CODE: '178' (0xB2)
4.83997514 | stop bits
4.83998315 | start bit
4.83998715 | Slot 1: . (0x2E)
...

I'm fairly new to DMX but shouldn't the output be more like:

Slot 1: 0
Slot 2: 128
Slot 3: 0
Slot 4: 0

I'll keep banging at it but the code examples in the repo don't show an example of connecting the DMX shield to an existing DMX light.

A working example would be handy.

update() crashing when using WiFi.softAP

dmx.update() never completes when i'm using softAP to run an access point on the esp32.

Having debugged as far as i can, the important line in the library seems to be:

pinMatrixOutDetach(txPin, false, false); //Detach our

in the update() function.

If i comment this line (and subsequent lines) my program continues to run. but the moment this line is re-enabled, the whole thing halts.

I'm obviously going to keep digging to see if i can find a workaround to make them both play nicely together.

Starting Data still not working?

Seeing weird behavior. On a cheap 24 channel light board when I send data on 7 channels I mostly get good data. However, when I put values on the higher channels I get random junk.

When I connect to a big light board I get all kinds of junk data in the read values.

I don't know for sure, but it looks like the packet start is not working.

How can I diagnose this?

DMX read example not working for me

I can't seem to get correct values from a DMX bus.

I'm using an ESP32.

I can put my Saleae logic analyzer on the rx pin and it decodes the DMX values fine. But, dmx.read() in the read example, never returns the correct value. Always 0.

Questions:

  • after calling the initRead() it attaches the rxPin to the startcode() interrupt routine.
    The interrupt routine finds the break, then calls DMXSerial.begin().
    Doesn't the interrupt still continue? Or does DMXSerial.begin() usurp the rxPin?

  • how does it determine it found the 0 frame of the DMX transmission?

Any idea what I'm doing wrong?

Alignment issue on ESP32-S2 Thing Plus

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?

error: 'U2TXD_OUT_IDX' was not declared in this scope

Hi,

I'm trying to use this library with an esp32 Feather S2 from Unexpected Maker and I'm getting this issue when compiling the project.

SparkFun_DMX_Shield_Library/src/SparkFunDMX.cpp: In member function 'void SparkFunDMX::update()':
/SparkFun_DMX_Shield_Library/src/SparkFunDMX.cpp:127:31: error: 'U2TXD_OUT_IDX' was not declared in this scope
pinMatrixOutAttach(txPin, U2TXD_OUT_IDX, false, false);
^~~~~~~~~~~~~
SparkFun_DMX_Shield_Library/src/SparkFunDMX.cpp:127:31: note: suggested alternative: 'U1TXD_OUT_IDX'
pinMatrixOutAttach(txPin, U2TXD_OUT_IDX, false, false);
^~~~~~~~~~~~~
U1TXD_OUT_IDX

Example2-DMXInput needs all DMX channels in universe to have a value?

When testing example 2 with my lighting controller (in my case QuickDMX) I noticed that all of the 512 dmx channels need to have set a value on my dmx output device (D512) instead of being blank (No DMX value -> DMX value 0?) in order for the ESP to correctly read out, in this case, DMX channel 1... So it now takes up a whole universe to be able to read DMX channel input on the ESP. How can this be solved and what causes this? Does it have something to do that the channel bytes cannot be left empty?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.