Ah... differences between 3.2 and 4.1 regarding DMX

SteveCS

Well-known member
Hello all

I have a small project that runs on a 3.2

Need to move it over to a 4.1, but the DMX.Simple library I am using throws up this error:

DmxSimple.cpp:82:11: error: cannot convert 'volatile uint32_t* {aka volatile long unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment
dmxPort = portOutputRegister(digitalPinToPort(dmxPin));

What is different on the 4.1 from the 3.2 and how do I fix this?

Thank you!
 
OK...Just binned the working code on the 3.2 and started again with <TeensyDMX.h>

But... cannot get it to talk to the Arduino DMX shield (through a level shifter). I hate these things when nothing works
 
Code:
#include <TeensyDMX.h>                                                                                            // DMX library
#include <Audio.h>
#include <SD.h>
#include <SPI.h>
#include <Wire.h>
#include <SerialFlash.h>
#include <Encoder.h>

namespace teensydmx = ::qindesign::teensydmx;

// GUItool: begin automatically generated code
AudioPlaySdWav           playSdWav1;     //xy=220,240
AudioPlaySdWav           playSdWav2;     //xy=222,302
AudioMixer4              mixer1;         //xy=434,271
AudioOutputI2S           i2s1;           //xy=632,265
AudioConnection          patchCord1(playSdWav1, 0, mixer1, 0);
AudioConnection          patchCord2(playSdWav1, 1, mixer1, 1);
AudioConnection          patchCord3(playSdWav2, 0, mixer1, 2);
AudioConnection          patchCord4(playSdWav2, 1, mixer1, 3);
AudioConnection          patchCord5(mixer1, 0, i2s1, 0);
AudioConnection          patchCord6(mixer1, 0, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=372,166
// GUItool: end automatically generated code

#define SDCARD_CS_PIN 10                        // SD card pins
#define SDCARD_MOSI_PIN 11
#define SDCARD_MISO_PIN 12
#define SDCARD_SCK_PIN 13

// Any pins used under the audio card seem to be corrupted with regards output

#define startbutton 31
#define stopbutton 32
#define encoderSW 33

Encoder encoderknob(34, 35);
long encoderposition  = -999;
long newencoderposition;

constexpr uint8_t kTXPin = 36;                 // Pin for enabling or disabling the DMX board

teensydmx::Sender dmxTx{Serial7};              // Create the DMX sender on Serial7.

//----------------------------------------------------------------------------------------------------------------
void setup() {

  pinMode(startbutton, INPUT_PULLUP);
  pinMode(stopbutton, INPUT_PULLUP);
  pinMode(encoderSW, INPUT_PULLUP);
  pinMode(kTXPin, OUTPUT);
  digitalWriteFast(kTXPin, HIGH);              // Switch on the DMX board

  Serial.begin(115200);

  Wire.begin();
  //dmxTx.begin();

  AudioMemory(8);                                                                         // Audio setup
  sgtl5000_1.enable();
  sgtl5000_1.volume(0.5);

  //---------------- SD CARD ---------------

  SPI.setMOSI(SDCARD_MOSI_PIN);                                                           // SD card setup
  SPI.setSCK(SDCARD_SCK_PIN);

  if (!(SD.begin(SDCARD_CS_PIN)))
  {
    while (1)
    {
      Serial.println(F("Unable to access the SD card"));                                     // Flash the cistern leds if SD card is unavailable
      delay(1000);
    }
  }

  Serial.println(F("ONLINE....."));
  playSdWav1.play("SDTEST1.WAV");

  dmxTx.set(4, 255);      // Turn the light on
  delay(500);
  dmxTx.set(3, 255);      // Make it blue
  delay(500);
  dmxTx.begin();


  // uint8_t data[3]{0x44, 0x88, 0xcc};
  // dmxTx.set(10, data, 3);       // Set channels 10-12 to the 3 values in 'data'

}
//################################################################################################################
void loop() {


  //-------- Check Address rotary encoder-------------------------

  newencoderposition = encoderknob.read();

  if (newencoderposition != encoderposition) {
    Serial.print("Encoder = ");
    Serial.println(newencoderposition);
    encoderposition = newencoderposition;

  }

  //----------- Buttons -------------

  if (digitalRead(startbutton) == LOW) {
    Serial.println(F("START"));
    do {} while (digitalRead(startbutton) == LOW);
  }

  if (digitalRead(stopbutton) == LOW) {
    Serial.println(F("STOP"));
    do {} while (digitalRead(stopbutton) == LOW);
  }

  if (digitalRead(encoderSW) == LOW) {
    Serial.println(F("ENCODER BUTTON"));
    do {} while (digitalRead(encoderSW) == LOW);
  }

}
//##############################################################################################################

TX of the DMX signal is leaving on pin 29. Goes on the Arduino DMX shield RX pin. RX and TX set to UART (therefore RX = pin 0) on the shield. Board jumper on slave, EN in place.

Nothing. Used this shield before with a 3.2 and fine, so no idea what the issue is.
 
Back in post 1.... any ideas how I fix that error?
I can't get this TeensyDMX library to work at all. At least I know the DMXsimple one worked
 
@SteveCS: I am not knowledgeable specifically with DMX, so I will ask a "dumb outsider looking in" type of question: the T3.2 is a short 28-pin device, whereas the T4.1 is the longer 40-pin device. Since the sketch that you posted seems to indicate that you have your DMX TX setup for pin 29, how are you connecting that output signal from the T4.1 to whichever pin the T3.2 previously used to send DMX data to the Arduino DMX shield ?? Hardware wiring/setup pictures might be helpful in taking a look at your configuration . . .

Mark J Culross
KD5RXT
 
Teensy 3.2 has 10 GPIO pins and 4 analog only pins accessible on the bottom side.

teensy32_card7b_rev3.png
 
I am sure it's all connected fine.

I know all the pins are different between the two. Use both all the time.

I am using Serial7 for the DMX board. Any reason that would not work?

This breadboard was tidy until it didn't work. Sound is fine, it's the DMX being a pain. That level shifter is not in use

20221022_134813[1].jpg
 
Back in post 1.... any ideas how I fix that error?
I can't get this TeensyDMX library to work at all. At least I know the DMXsimple one worked

I have seen those types of errors before. My solution was to change the library to use digitalWriteFast statements. It is just as fast or faster than the direct port manipulation macros.



Code:
LCD5110::LCD5110(int SCK, int MOSI, int DC, int RST, int CS)
{ 
	/*
        P_SCK	= portOutputRegister(digitalPinToPort(SCK));
	B_SCK	= digitalPinToBitMask(SCK);
	P_MOSI	= portOutputRegister(digitalPinToPort(MOSI));
	B_MOSI	= digitalPinToBitMask(MOSI);
	P_DC	= portOutputRegister(digitalPinToPort(DC));
	B_DC	= digitalPinToBitMask(DC);
	P_RST	= portOutputRegister(digitalPinToPort(RST));
	B_RST	= digitalPinToBitMask(RST);
	P_CS	= portOutputRegister(digitalPinToPort(CS));
	B_CS	= digitalPinToBitMask(CS);
        */
	pinMode(SCK,OUTPUT);
	pinMode(MOSI,OUTPUT);
	pinMode(DC,OUTPUT);
	pinMode(RST,OUTPUT);
	pinMode(CS,OUTPUT);
	SCK_Pin=SCK;
	RST_Pin=RST;
       MOSI_Pin = MOSI;
       DC_Pin = DC;
       CS_Pin = CS;
}



void LCD5110::_LCD_Write(unsigned char data, unsigned char mode)
{
   
        digitalWriteFast(CS_Pin,LOW);  //cbi(P_CS, B_CS);

	if (mode==LCD_COMMAND)
		digitalWriteFast(DC_Pin,LOW); //cbi(P_DC, B_DC);
	else
		digitalWriteFast(DC_Pin,HIGH); //sbi(P_DC, B_DC);

	for (unsigned char c=0; c<8; c++)
	{
		if (data & 0x80)
			digitalWriteFast(MOSI_Pin,HIGH);  //sbi(P_MOSI, B_MOSI);
		else
			digitalWriteFast(MOSI_Pin,LOW);  //cbi(P_MOSI, B_MOSI);
		data = data<<1;
                
                pulseClock; 
	}

	digitalWriteFast(CS_Pin,HIGH);   //sbi(P_CS, B_CS);
}
 
Well I don't know.
The DMX light works from a cheap Ebay desk... fade channel 4 to full (255) and then channel 3 to full (255 = full blue).
Doesn't work with that code from the 4.1

Literally tried everything I can think of. What a waste of a day
 
TeensyDMX is not the issue.
When I comment out the lines in red from your code in message #4, DMX is outputted correctly.
Code:
#include <TeensyDMX.h>                                                                                            // DMX library
#include <Audio.h>
#include <SD.h>
#include <SPI.h>
#include <Wire.h>
#include <SerialFlash.h>
#include <Encoder.h>

namespace teensydmx = ::qindesign::teensydmx;

// GUItool: begin automatically generated code
AudioPlaySdWav           playSdWav1;     //xy=220,240
AudioPlaySdWav           playSdWav2;     //xy=222,302
AudioMixer4              mixer1;         //xy=434,271
AudioOutputI2S           i2s1;           //xy=632,265
AudioConnection          patchCord1(playSdWav1, 0, mixer1, 0);
AudioConnection          patchCord2(playSdWav1, 1, mixer1, 1);
AudioConnection          patchCord3(playSdWav2, 0, mixer1, 2);
AudioConnection          patchCord4(playSdWav2, 1, mixer1, 3);
AudioConnection          patchCord5(mixer1, 0, i2s1, 0);
AudioConnection          patchCord6(mixer1, 0, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=372,166
// GUItool: end automatically generated code

#define SDCARD_CS_PIN 10                        // SD card pins
#define SDCARD_MOSI_PIN 11
#define SDCARD_MISO_PIN 12
#define SDCARD_SCK_PIN 13

// Any pins used under the audio card seem to be corrupted with regards output

#define startbutton 31
#define stopbutton 32
#define encoderSW 33

Encoder encoderknob(34, 35);
long encoderposition  = -999;
long newencoderposition;

constexpr uint8_t kTXPin = 36;                 // Pin for enabling or disabling the DMX board

teensydmx::Sender dmxTx{Serial7};              // Create the DMX sender on Serial7.

//----------------------------------------------------------------------------------------------------------------
void setup() {

  pinMode(startbutton, INPUT_PULLUP);
  pinMode(stopbutton, INPUT_PULLUP);
  pinMode(encoderSW, INPUT_PULLUP);
  pinMode(kTXPin, OUTPUT);
  digitalWriteFast(kTXPin, HIGH);              // Switch on the DMX board

  Serial.begin(115200);

  Wire.begin();
  //dmxTx.begin();

  AudioMemory(8);                                                                         // Audio setup
  sgtl5000_1.enable();
  sgtl5000_1.volume(0.5);

  //---------------- SD CARD ---------------

  SPI.setMOSI(SDCARD_MOSI_PIN);                                                           // SD card setup
  SPI.setSCK(SDCARD_SCK_PIN);

  if (!(SD.begin(SDCARD_CS_PIN)))
  {
[COLOR="#FF0000"]//    while (1)
//    {
//      Serial.println(F("Unable to access the SD card"));                                     // Flash the cistern leds if SD card is unavailable
//      delay(1000);
//    }[/COLOR]
  }

  Serial.println(F("ONLINE....."));
[COLOR="#FF0000"]//  playSdWav1.play("SDTEST1.WAV");[/COLOR]

  dmxTx.set(4, 255);      // Turn the light on
  delay(500);
  dmxTx.set(3, 255);      // Make it blue
  delay(500);
  dmxTx.begin();


  // uint8_t data[3]{0x44, 0x88, 0xcc};
  // dmxTx.set(10, data, 3);       // Set channels 10-12 to the 3 values in 'data'

}
//################################################################################################################
void loop() {


  //-------- Check Address rotary encoder-------------------------

  newencoderposition = encoderknob.read();

  if (newencoderposition != encoderposition) {
    Serial.print("Encoder = ");
    Serial.println(newencoderposition);
    encoderposition = newencoderposition;

  }

  //----------- Buttons -------------

  if (digitalRead(startbutton) == LOW) {
    Serial.println(F("START"));
    do {} while (digitalRead(startbutton) == LOW);
  }

  if (digitalRead(stopbutton) == LOW) {
    Serial.println(F("STOP"));
    do {} while (digitalRead(stopbutton) == LOW);
  }

  if (digitalRead(encoderSW) == LOW) {
    Serial.println(F("ENCODER BUTTON"));
    do {} while (digitalRead(encoderSW) == LOW);
  }

}

DSview.jpg
[logic analyzer measuring on pin 29 of Teensy 4.1]

Hope this helps,
Paul
 
Extra note: Those delays here don't do anything other than make setup() take 1 second longer:

Code:
  dmxTx.set(4, 255);      // Turn the light on
  delay(500);
  dmxTx.set(3, 255);      // Make it blue
  delay(500);
  dmxTx.begin();

If DMX hasn't been started yet, then those `set()` calls just set the initial values when DMX does start sending.
 
Thank you for your help, and testing the output Paul. Had a day away from it yesterday

I suspect these DMX shields (I have 2 and neither work).

I have a MAX481 here, so I will make my own interface today.
 
Oh my God this goddam thing

Still no luck

If I plug the DMX light into a desk, you fade the 4th channel to full, then the 3rd channel to full and it gives you a blue light.
My code should achieve the same, yet it does not. Pretty sure it's my interface, but just cannot get it working.

Thing is... the 3.2 worked out the door first time. Just don't get it. Is the 4.1 serial 7 output significantly lower in signal strength?
 
Can anyone recommend a DMX programmable controller?
I need to run a set of several DMX lights through some pre-programmed fading sequences.

It needs to be button triggerable, and reliable (which this Teensy approach clearly isn't going to be).
 
Is the 4.1 serial 7 output significantly lower in signal strength?
Don't think so.
Made a setup with a Teensy 3.2 with the following code:
Code:
// https://github.com/ssilverman/TeensyDMX/
#include <TeensyDMX.h>

namespace teensydmx = ::qindesign::teensydmx;
teensydmx::Sender dmxTx{Serial1};                             // TX1 on pin 1

uint8_t data[7] {0x02, 0x02, 0x02, 0x02, 0x02, 0xFF, 0x00};   // 7 channel DMX fixture
//    data[7] = {red, green, blue, amber, white, dimmer, strobe}

void setup() {
  pinMode(17, OUTPUT);          // RS485 transmitter enable
  digitalWrite(17, HIGH);

  dmxTx.set(1, data, 7);        // set channels 1-7 with data
  dmxTx.begin();
}

void loop() {
}
T32.jpg

Works fine on my Eurolite fixture.

Then made a setup with a Teensy 4.1 with the following code:
Code:
// https://github.com/ssilverman/TeensyDMX/
#include <TeensyDMX.h>

namespace teensydmx = ::qindesign::teensydmx;
teensydmx::Sender dmxTx{Serial7};                             // TX7 on pin 29

uint8_t data[7] {0x02, 0x02, 0x02, 0x02, 0x02, 0xFF, 0x00};   // 7 channel DMX fixture
//    data[7] = {red, green, blue, amber, white, dimmer, strobe}

void setup() {
  pinMode(36, OUTPUT);          // RS485 transmitter enable
  digitalWrite(36, HIGH);

  dmxTx.set(1, data, 7);        // set channels 1-7 with data
  dmxTx.begin();
}

void loop() {
}
T41.jpg

And also working fine on the Eurolite fixture.

The RS485 board I'm using is this one.

Perhaps double-check your wiring? Does the enable line for the DMX board indeed make it all the way to the DMX board? (couldn't tell from the photo).

Paul
 
My suggestion would be to build the most basic circuit using the CTC-DRA-10-R2 Uno DMX module and measure the voltages on pin 29 & 36. And check the VCC & GND on the DMX board ofcourse.
Perhaps pin 29 of the Teensy 4.1 is broken? Or one of the patch wires is broken?

Paul
 
I made my own interface last night with 6n137 opto isolators and a Max481

All up and running. I think it was both a dodgy DMX shield and a rubbish breadboard
Thanks all
 
To save starting a new thread.... can anyone recommend a UK based pcb manufacturer?
I have the files ready to send to JLCPCB, but using a UK company would be nice. Not huge volumes to be made (10x of each board. 3 different boards)

Thanks
 
Back
Top