Teensy 4.0 DMX Lighting Control

I've spent three full days trying to get my Teensy 4.0 to control DMX lights using the ENTTEC protocol. The goal is to use a software package on a computer called Dragonframe to talk to the Teensy to control the DMX lights. There's a video link below of exactly this where someone shows it working on a Teensy 3.6 but I cannot get it to work on a Teensy 4.0 and others have had similar problems with the Teensy 4. The video talks about having baud rate issues and changing the baud from 57600 to 57601 which I have done among a million other things but haven't made any progress. Any suggestions on what I need to change to get this working would be greatly apprecaited.


Code:
/*
   ADDED CODE BY TALOFER99@HOTMAIL.COM
 
   DMXUSB_Simple.ino
   Originally created 11/21/2017 by Stefan Krüger (s-light)
   This is a simple example sketch for the DMXUSB Arduino/Teensy library.
   https://github.com/DaAwesomeP/dmxusb/
 
   Copyright 2017-present Stefan Krüger (s-light)
 
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
 
      http://www.apache.org/licenses/LICENSE-2.0
 
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
 
#include "DMXUSB.h"
 
 
const byte LED_PIN = 5;   //pin that outputs to rs485 module which goes to DMX lights
#define NUMBEROFCHANNELS 4
byte ChannelsPins[NUMBEROFCHANNELS] = {1, 2, 3, 4};
 
 
                                     // DMXUSB should receive and transmit data at the highest, most reliable speed possible
                                     // Recommended Arduino baud rate: 115200
                                     // Recommended Teensy 3 baud rate: 2000000 (2 Mb/s)
                                     // DMX baud rate: 250000
                                     // MIDI baud rate: 31250
#define DMXUSB_BAUDRATE 57601
#define DMX_SERIAL Serial
 
                                     // receive a DMX transmission
void myDMXCallback(int universe, char buffer[512]) {
  for (int index = 0; index < 512; index++) { // for each channel, universe starts at 0
    int channel = index + 1; // channel starts at 0, so index 0 is DMX channel 1 and index 511 is DMX channel 512
    int value = buffer[index]; // DMX value 0 to 255
    if (universe == 0 ) {
      if (index < NUMBEROFCHANNELS) {
        if (ChannelsPins[index]) {
          analogWrite(ChannelsPins[index], value);
        } //end if
      } //end if
    } //end if
  } //end for
}
 
DMXUSB myDMXUsb(
  // Stream serial,
  DMX_SERIAL,
  // int baudrate,
  DMXUSB_BAUDRATE,
  // int mode,
  0,
  // void (*dmxInCallback)(int universe, unsigned int index, char buffer[512])
  myDMXCallback
);
 
void setup() {
  pinMode(LED_PIN, OUTPUT);
  analogWriteFrequency(35, 20000);
  DMX_SERIAL.begin(DMXUSB_BAUDRATE);
}
 
void loop() {
  myDMXUsb.listen();
}
 
Using DMXUSB_Simple.ino I can dim the LED on the teensy board from my computer and that seems to work well. However, when I change
LED_PIN to 5 which outputs to a RS485 converter that goes to my DMX light it seems like there is very limited communication. When I try to change the brightess of channel 0 the light will shut off and come back on after a 30 seconds or so, no other channels have any effect.

I have used a different example teensy code to succesfully control the same light/setup over DMX with the serial port so I know my hardware is good but that code doesn't use the ENTTEC and won't interface with the software on my computer.

I tried to look at the serial signal coming out of the Teensy 4.0 with a logic analyyzer and DMX decoder but don't think I'm getting the right output. Here are some screenshots using the logic analyzer on pin 5 of the TEensy 4.0 using DMXUSB_Simple.ino:
1707026717018.png


Zoomed in view:
1707026747065.png
 
Fun fact: The USB Serial port on Teensy actually isn’t affected by the baud rate settings. The speed is whatever speed the USB connection can do.

A little while back, I wrote a library called TeensyDMX, and in that library, there’s a fairly full-featured example called USBProWidget. It converts from the ENTTEC protocol via USB (Serial) to one of the “true” serial ports, where the DMX protocol happens. It’s set to Serial3, but you can change that in the example code.

You should be able to install TeensyDMX from the Arduino IDE. Let me know if it works for you.

[Time passes...]

I watched some of the video (and looked at your code more closely) and realized you want to convert ENTTEC protocol to PWM (analogWrite()), not output DMX (your post says you want to control DMX lights). So... my comments above might not be relevant.

[More time passes...]

Maybe they are relevant because the second post mentions DMX? So now I'll ask: Are you trying to output DMX or PWM?
 
Last edited:
Sorry for the confusion, I'm trying to output DMX. Pretty neat about the USB serial port, there are always so many hidden secrets with every micro, or maybe that's common.


Block overview, should saw Teensy here instead or Arduino:
1707190074317.png


Apprecaite the advice Shawn, I had tried to run USBProWidget on my Teensy 4.0 but saw this error when I compiled and didn't get any farther.

Code:
C:\Users\Admin\Desktop\New folder\TeensyDMX-master\examples\USBProWidget\USBProWidget.ino: In function 'void handleMessage(const Message&)':
C:\Users\Admin\Desktop\New folder\TeensyDMX-master\examples\USBProWidget\USBProWidget.ino:509:15: error: 'class qindesign::teensydmx::Sender' has no member named 'setPacketSizeAndData'; did you mean 'setPacketSize'?
  509 |         dmxTx.setPacketSizeAndData(len, 0, msg.data, len);
      |               ^~~~~~~~~~~~~~~~~~~~
      |               setPacketSize

exit status 1

Compilation error: 'class qindesign::teensydmx::Sender' has no member named 'setPacketSizeAndData'; did you mean 'setPacketSize'?


If I change setPacketSizeAndData to setPacketSize I get additional errors:

Code:
C:\Users\Admin\Desktop\New folder\TeensyDMX-master\examples\USBProWidget\USBProWidget.ino: In function 'void handleMessage(const Message&)':
C:\Users\Admin\Desktop\New folder\TeensyDMX-master\examples\USBProWidget\USBProWidget.ino:509:30: error: no matching function for call to 'qindesign::teensydmx::Sender::setPacketSize(int&, int, const uint8_t [600], int&)'
  509 |           dmxTx.setPacketSize(len, 0, msg.data, len);
      |           ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from C:\Users\Admin\Desktop\New folder\TeensyDMX-master\examples\USBProWidget\USBProWidget.ino:14:
c:\Users\Admin\Documents\Arduino\libraries\TeensyDMX\src/TeensyDMX.h:808:8: note: candidate: 'bool qindesign::teensydmx::Sender::setPacketSize(int)'
  808 |   bool setPacketSize(int size);
      |        ^~~~~~~~~~~~~
c:\Users\Admin\Documents\Arduino\libraries\TeensyDMX\src/TeensyDMX.h:808:8: note:   candidate expects 1 argument, 4 provided

exit status 1

Compilation error: no matching function for call to 'qindesign::teensydmx::Sender::setPacketSize(int&, int, const uint8_t [600], int&)'

Based on the error I though I needed to modify setPacketSize to only use one argument instead of passing 4 arguments? So I tried using only passing len but still cannot control the DMX light soI must've done something wrong and the logic anylzer set to DMX mode shows what looks like a PWM signal on pin 13:

Code:
 if (len != dmxTx.packetSize()) {
  dmxTx.setPacketSize(len);

        } else {
          dmxTx.set(0, msg.data, len);
        }

        if (dmxState != DMXStates::kTx) {
          startTx();
          dmxState = DMXStates::kTx;
        }

        resetToInput = false;

        break;
      }


To keep things simple I'm starting off with only one DMX light which is set to DMX mode (D001) and has the following channel mapping:
Channel 1: Master Dimmer
Channel 2: Red dimming
Channel 3: Green Dimming
Channel 4: Blue Dimming
Channel 5: White Dimming (Not used)
Channel 6: Feature selection- strobe, voice control, etc (Not used)
Channel 7: Feature Duration (Not Used)
 
Last edited:
I see what happened. It’s because I haven’t created a latest release, and that’s where the changes are. Check out the latest on GitHub.

If you don’t usually use git, it’s easy to click on “Download ZIP” from the main project page (it might be under the “Code” button). You can unzip that over top of the inside of the TeensyDMX library folder. (It’s in the standard Arduino library place.)

See: https://github.com/ssilverman/TeensyDMX
 
Using that link with the latest files I still have the same problem compiling USB Pro widget. I do have TeensyDMX lib installed and am using Arduino IDE 2.2.2-nightly-20240120.

Code:
C:\Users\Admin\Desktop\New folder\TeensyDMX-master\TeensyDMX-master\examples\USBProWidget\USBProWidget.ino: In function 'void handleMessage(const Message&)':
C:\Users\Admin\Desktop\New folder\TeensyDMX-master\TeensyDMX-master\examples\USBProWidget\USBProWidget.ino:509:15: error: 'class qindesign::teensydmx::Sender' has no member named 'setPacketSizeAndData'; did you mean 'setPacketSize'?
  509 |         dmxTx.setPacketSizeAndData(len, 0, msg.data, len);
      |               ^~~~~~~~~~~~~~~~~~~~
      |               setPacketSize

exit status 1

Compilation error: 'class qindesign::teensydmx::Sender' has no member named 'setPacketSizeAndData'; did you mean 'setPacketSize'?


1707192762948.png
 
I take it back. When I open USB Pro widget file up from the location where I unzipped it and open it in the Arduino IDE I get that error when I try to compile, when I'm already in the Arduino IDE and go to files-->examples and select USB Pro widget it compiles fine. Interesting :)
 
It doesn’t look like you have the library installed or installed correctly.

First, install TeensyDMX via the Arduino Library Manager. (It looks like you’ve done this.) Next, download the ZIP file and overwrite the contents of wherever TeensyDMX is installed for your platform. Perhaps you have several copies of the downloaded library in different locations?
 
I take it back. When I open USB Pro widget file up from the location where I unzipped it and open it in the Arduino IDE I get that error when I try to compile, when I'm already in the Arduino IDE and go to files-->examples and select USB Pro widget it compiles fine. Interesting :)
Ah, yes. I have a feeling there’s a few copies of the library files in various places. Perhaps even one inside the example folder or something. I’d have to look more closely at where all your files are to be sure. I’m glad you got it working compiling.
 
Awesome thank you, making progress! You are correct. As I had been reading through threads I would download the latest links and had libs all over the place which is bad practice on my part. The software that talks to my Teensy 4.0 is called Dragonframe. Dragonframe will succesfully recognize and connect to the teensy (green means it connected) and when I connect the yellow LED on the Teensy starts blinking about twice a second:

1707194120661.png


I setup channels on my computer to control the light but don't have any control of the light and channel mapping is right. Not that that screenshot helps but you get the idea with using the sliders to control DMX channels:

1707194027917.png


Probing pins 7 or 8 to look at serial 3 I don't see anything. Line stays low all the time,I see no coms from the computer:
1707194049022.png
 
Oh man, that's bad...I misread those pin numbers. Apprecaite your patience. I was in bed almost asleep and saw your message, got out of bed to try it and IT TOTALLY WORKS!

You are my freakin hero shawn!! I am overjoyed. Spent over 20 hours trying all different types of code, libraries, and everything I could think of and you nailed it, thank you so much!
 
Back
Top