Hallo.
Dies ist mein erster Beitrag. Feedback willkommen ![]()
Ich hab ein Problem beim Empfangen/Verarbeiten eines DMX-Signals mit der genannter Hardware.
Mit meinem jetzigen Sketch, welcher auf das Input-example des SparkFunDMX-Library basiert.
/*
Reads DMX data from channel 1
By: Dryw Wade
SparkFun Electronics
Date: 10/3/2023
License: GNU. See license file for more information but you can
basically do whatever you want with this code.
This example runs two servos and a number of LED's off of 5 DMX channels
Feel like supporting open source hardware?
Buy a board from SparkFun! https://www.sparkfun.com/products/15110
Hardware Connections:
Connect a Thing Plus board to the SparkFun DMX Shield, and connect a DMX XLR-3
cable between the shield and another device that inputs DMX data. You can use
a second board and shield running Example 1!
*/
// Inlcude DMX library
#include <SparkFunDMX.h>
// Inlcude FastLED library
#include <FastLED.h>
// Create DMX object
SparkFunDMX dmx;
// Create serial port to be used for DMX interface. Exact implementation depends
// on platform, this example is for the ESP32
HardwareSerial dmxSerial(1);
// Enable pin for DMX shield (Free pin on Thing Plus or Feather pinout)
uint8_t enPin = 4;
// Number of DMX channels, can be up to 512
//ex uint16_t numChannels = 3;
//Channel Definitions
//#define TOTAL_CHANNELS 3
uint16_t TOTAL_CHANNELS = 3;
#define HUE_CHANNEL 1
//#define SATURATION_CHANNEL 2
//#define VALUE_CHANNEL 3
//Fixture Hardware Definitions
// How many leds in your strip? Uncomment the corresponding line
#define NUM_LEDS 20 //1 Inch
// The LuMini rings need two data pins connected
#define DATA_PIN 19
#define CLOCK_PIN 18
// Define the array of leds
CRGB ring[NUM_LEDS];
void setup()
{
Serial.begin(115200);
Serial.println("initialzed...");
// Begin DMX serial port
dmxSerial.begin(DMX_BAUD, DMX_FORMAT);
// Begin DMX driver
dmx.begin(dmxSerial, enPin, TOTAL_CHANNELS);
// Set communicaiton direction, which can be changed on the fly as needed
dmx.setComDir(DMX_READ_DIR);
Serial.println("DMX initialized!");
// Begin LED driver
LEDS.addLeds<APA102, DATA_PIN, CLOCK_PIN, BGR>(ring, NUM_LEDS);
LEDS.setBrightness(32); //LEDs dimmed for testing purposes
}
void loop()
{
dmx.update();
// Wait until dmx-data has been received
while(dmx.dataAvailable() == false)
{
// Must call update() to actually check for received data
dmx.update();
}
// Data has been received, read out channels
uint8_t hue = dmx.readByte(HUE_CHANNEL);
//uint8_t saturation = dmx.readByte(SATURATION_CHANNEL);
//uint8_t value = dmx.readByte(VALUE_CHANNEL);
if(hue > 0 ){ //without this if-condition most readings are = 0 resulting in wrong hue on LED-ring
Serial.print("DMX: read value from hue channel: ");
Serial.println(hue);
for (int led = 0; led < NUM_LEDS; led++)
{
//ring[led] = CHSV(hue, saturation, value);
ring[led] = CHSV(hue, 255, 255); //saturation and value set to 255 just for testing
}
FastLED.show();
}
}
Ein eingehendes Signal ĂŒber DMX Kanal 1 (Ă€ndernde Werte 0-255) kommt an, aber die meiste Zeit wird der Wert als 0 interpretiert. Siehe Serial:
Der Wert soll im genannten Sketch die Farbe(=hue) eines LED-Rings verÀndern. Dies gelingt nur annÀhernd, wenn ich behelfmÀssig ein if(hue!=0) -Bedingung stelle. Siehe Serial:
Leider leidet dabei die Reaktionsgeschwindigkeit der FarbÀnderung: vermutlich weil halt nach wie vor die meisten Werte als 0 gelesen werden.
Sieht jemensch, wo die Ursache liegen könnte?
Vielen Dank!

Libraries:
SparkfunDMX v2.0.1
https://github.com/sparkfun/SparkFunDMX
FastLED v3.6.0
https://github.com/FastLED/FastLED
SparkFun-DMX to LED-Shield
https://learn.sparkfun.com/tutorials/sparkfun-esp32-dmx-to-led-shield/all
Sparkfun Thing Plus ESP32 Wroom USB-C
https://learn.sparkfun.com/tutorials/esp32-thing-plus-usb-c-hookup-guide?_gl=154k98a_gaMjExODgzMDY1Ni4xNzA2MDI2NDUz_ga_T369JS7J9N*MTcwOTg5NTQ1Mi4xNS4xLjE3MDk4OTU1NDQuMzcuMC4w&_ga=2.268942390.611241178.1709895454-2118830656.1706026453



