brightnight
Member
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();
}