Teensy 4.1, Ethernet, Art-Net and OctoWS2811

Steffe82

New member
Hello everyone, I have a question about Teensy 4.1, Ethernet, Art-Net and OctoWS2811.

I started with an Arduino Mega 2650 and was able to output two universes each with an Ethernet shield on two pins. Then I noticed that the computing power was nowhere near enough and compared several boards and ended up with the Teensy 4.1. I use this with an Ethernet kit which is also sold via pjrc. Now I have adapted my code a little and am stuck with the following problem:

The code won't compile - I keep getting error messages saying that something is being initialized twice. If I comment out the Ethernet.h library (and also the EthernetUDP.h ) my code compiles and is uploaded. Logically, I can't receive Art-Net then - so my LEDs remain dark. I tried to switch to a different Ethernet library - NativeEthernet, and the NativeEthernetUDP to go with it. The code then compiles but I don't get a signal on any subnet in any universe. The only thing I see is the pattern that is generated by the init() function.

I loaded the OctoWS2811 basic test without Art-Net, modified it and tested it with 3 strips. That worked, which means that my strips are wired correctly.

I also tried working without the OctoWS2811 library.
I wrote everything together by hand (the hardest part was probably how to receive subnet data). The problem with this solution, which worked quite well, was that I had individual if loops and I think these are processed one after the other. So everything arrived slightly later on the second than on the first and everything arrived again later on the third than on the second and so on.

My questions:
Is it true that the OctoWS2811 library in conjunction with the appropriate adapter assigns the pins on the Teensy itself? So strip one with length X on pin 2...

How do I regulate in the programming that subnet 1 universe 0 arrives at pin 7 (out 3)? Since you can send a maximum of 16 universes per subnet, it should look like this schematically: Out 1 - Pin 2 - Sub 0 - Universe 0-7, Out 1 - Pin 12 - Sub 0 - Universe 8-15, Out 3 - Pin 7- Sub 1 - Universe 0-7 and so on... in my attempt without the Octo library it worked like this:
Code:
const byte dataPinOut1 = 2; // 0 - 7 / sub 0
const byte dataPinOut2 = 14; // 8 - 15 / sub 0
byte SubnetID1 = {0}; // for PinOut1
byte UniverseID1 = {0}; // for PinOut1
short selectStartUniverse1 = ((SubnetID1*16)+UniverseID1); // for PinOut1
byte SubnetID2 = {0}; // for PinOut2
byte UniverseID2 = {8}; // for PinOut2
short selectStartUniverse2 = ((SubnetID2*16)+UniverseID2); // for PinOut2
In setup:
Code:
artnet.begin(mac, ip);
ledsOut1.begin();
ledsOut2.begin();
artnet.setBroadcast(broadcast);
and in the loop:
Code:
if(r == ART_DMX && uni == startUniverseOut1){
 data = artnet.getDmxFrame();
 for (int i = 0; i < numLedsOut1; i++){
 ledsOut1.setPixelColor(i, data[i * channelsPerLed], data[i * channelsPerLed + 1], data[i * channelsPerLed + 2]);
 }
 ledsOut1.show();
 }
 if(r == ART_DMX && uni == startUniverseOut2){
 data = artnet.getDmxFrame();
 for (int i = 0; i < numLedsOut2; i++){
 ledsOut2.setPixelColor(i, data[i * channelsPerLed], data[i * channelsPerLed + 1], data[i * channelsPerLed + 2]);
 }
 ledsOut2.show();
 }

Can someone help? Even if I delete all Ethernet libraries and install the Ethernet by Paul Stoffregen specifically for the Teensy, I still can't get it to compile.

Attached a .txt-file with the errors copied from the arduino ide
 

Attachments

  • errors.txt
    62.3 KB · Views: 13
Hello again, just tried some things in the morning. Deleted everything in relationship with arduino ide and librarys and boards. After that reinstalled arduino ide. In boards manager filled in the link to add additional boards. Then installed teensy via boards manager. Deinstalled the ethernet library and installed the one from @Paul Stoffregen loaded from github.

Webserver Sample can‘t find hardware ( shield ) - nothing happens.

After that tried NativeEthernet Sample Webserver and the RJ-45 green led starts to blink. Ping is okay.

Now tried OctoWS2811 ArtNet sample with NativeEthernet and NativeEthernetUdp and still the errors occur.

What can i do?

Again tried OctoWS2811 basic sample with success - but without ethernet / ArtNet
 
What can i do?

We're much better at helping with compiler errors when we can reproduce the error. Maybe tell us specifically which libraries to install and which example program to open, or give us a copy of the program you're compiling if it's not any of the examples.

Try to imagine you're someone else reading your question. Would you be able to follow the steps to get the same compiler error?
 
Hi @Paul - thanks for your reply.

I can imagine that - sorry!

What i try is to compile octows2811 library sample ArtNet …only changed ip, number of strips and LEDs per strip. Saving to teensy 4.1 works but no ethernet.

Changing to NativeEthernet lib i gets a lot of errors - as shown in post before.

Ethernet lib for teensy - downloaded from github ( by PaulStoffregen ) using the Webserver sample throws „can’t find ethernet shield“

Sample Webserver from NativeEthernet without anything else runs - i can ping it and the led on the rj45 is on.

NativeEthernet with ArtNet lib from natcl and neoPixel lib works - but i have the problem that only the first pinouts are working synchron ( i think it is because my if statements are working one after one

Is there a Tutorial - anywhere - to get informations? When i‘m not using OctoWS2811 lib - how to output all out synced?

Very confusing and hard to find anderes for this topic. Hope you or another member has an idea …
 
Changing to NativeEthernet lib i gets a lot of errors - as shown in post before.

Even if the changes are "trivial", please copy the complete program here, so I or anyone else can copy it into Arduino IDE and get the same errors.

Please understand, over and over when I try to help but I have to alter a program, usually I do something different and I only waste time not achieving the same error message. Usually I do not even begin to investigate the problem if you do not give the exact code to copy into Arduino IDE to reproduce the same errors.

I want to help you. But I also want to spend my time efficiently, so please understand I will only attempt to solve your compile error if you give the exact code so I can reproduce the error without guesswork.
 
OctoWS2811 Sample Artnet - in three different versions of ethernet libs.
Only changes are ledsPerStrip, numStrips and IP

Code:
// Receive multiple universes via Artnet and control a strip of ws2811 leds via OctoWS2811
//
// This example may be copied under the terms of the MIT license, see the LICENSE file for details
//  https://github.com/natcl/Artnet
//
// http://forum.pjrc.com/threads/24688-Artnet-to-OctoWS2811?p=55589&viewfull=1#post55589

#include <Artnet.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>
#include <OctoWS2811.h>

// Ideas for improving performance with WIZ820io / WIZ850io Ethernet:
// https://forum.pjrc.com/threads/45760-E1-31-sACN-Ethernet-DMX-Performance-help-6-Universe-Limit-improvements

// OctoWS2811 settings
const int ledsPerStrip = 150; // change for your setup
const byte numStrips= 8; // change for your setup
DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];
const int config = WS2811_GRB | WS2811_800kHz;
OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);

// Artnet settings
Artnet artnet;
const int startUniverse = 0; // CHANGE FOR YOUR SETUP most software this is 1, some software send out artnet first universe as zero.
const int numberOfChannels = ledsPerStrip * numStrips * 3; // Total number of channels you want to receive (1 led = 3 channels)
byte channelBuffer[numberOfChannels]; // Combined universes into a single array

// Check if we got all universes
const int maxUniverses = numberOfChannels / 512 + ((numberOfChannels % 512) ? 1 : 0);
bool universesReceived[maxUniverses];
bool sendFrame = 1;

// Change ip and mac address for your setup
byte ip[] = {192, 168, 2, 200};
byte mac[] = {0x04, 0xE9, 0xE5, 0x00, 0x69, 0xEC};

void setup()
{
  Serial.begin(115200);
  artnet.begin(mac, ip);
  leds.begin();
  initTest();

  // this will be called for each packet received
  artnet.setArtDmxCallback(onDmxFrame);
}

void loop()
{
  // we call the read function inside the loop
  artnet.read();
}

void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data)
{
  sendFrame = 1;

  // Store which universe has got in
  if (universe < maxUniverses)
    universesReceived[universe] = 1;

  for (int i = 0 ; i < maxUniverses ; i++)
  {
    if (universesReceived[i] == 0)
    {
      //Serial.println("Broke");
      sendFrame = 0;
      break;
    }
  }

  // read universe and put into the right part of the display buffer
  for (int i = 0 ; i < length ; i++)
  {
    int bufferIndex = i + ((universe - startUniverse) * length);
    if (bufferIndex < numberOfChannels) // to verify
      channelBuffer[bufferIndex] = byte(data[i]);
  }     

  // send to leds
  for (int i = 0; i < ledsPerStrip * numStrips; i++)
  {
    leds.setPixel(i, channelBuffer[(i) * 3], channelBuffer[(i * 3) + 1], channelBuffer[(i * 3) + 2]);
  }     
 
  if (sendFrame)
  {
    leds.show();
    // Reset universeReceived to 0
    memset(universesReceived, 0, maxUniverses);
  }
}

void initTest()
{
  for (int i = 0 ; i < ledsPerStrip * numStrips ; i++)
    leds.setPixel(i, 127, 0, 0);
  leds.show();
  delay(500);
  for (int i = 0 ; i < ledsPerStrip * numStrips  ; i++)
    leds.setPixel(i, 0, 127, 0);
  leds.show();
  delay(500);
  for (int i = 0 ; i < ledsPerStrip * numStrips  ; i++)
    leds.setPixel(i, 0, 0, 127);
  leds.show();
  delay(500);
  for (int i = 0 ; i < ledsPerStrip * numStrips  ; i++)
    leds.setPixel(i, 0, 0, 0);
  leds.show();
}

Complies and uploads with no errors but nothing happened on Teensy ( LED at RJ45 is off - ping is not possible )

Code:
// Receive multiple universes via Artnet and control a strip of ws2811 leds via OctoWS2811
//
// This example may be copied under the terms of the MIT license, see the LICENSE file for details
//  https://github.com/natcl/Artnet
//
// http://forum.pjrc.com/threads/24688-Artnet-to-OctoWS2811?p=55589&viewfull=1#post55589

#include <Artnet.h>
#include <NativeEthernet.h>
#include <NativeEthernetUdp.h>
#include <SPI.h>
#include <OctoWS2811.h>

// Ideas for improving performance with WIZ820io / WIZ850io Ethernet:
// https://forum.pjrc.com/threads/45760-E1-31-sACN-Ethernet-DMX-Performance-help-6-Universe-Limit-improvements

// OctoWS2811 settings
const int ledsPerStrip = 150; // change for your setup
const byte numStrips= 8; // change for your setup
DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];
const int config = WS2811_GRB | WS2811_800kHz;
OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);

// Artnet settings
Artnet artnet;
const int startUniverse = 0; // CHANGE FOR YOUR SETUP most software this is 1, some software send out artnet first universe as zero.
const int numberOfChannels = ledsPerStrip * numStrips * 3; // Total number of channels you want to receive (1 led = 3 channels)
byte channelBuffer[numberOfChannels]; // Combined universes into a single array

// Check if we got all universes
const int maxUniverses = numberOfChannels / 512 + ((numberOfChannels % 512) ? 1 : 0);
bool universesReceived[maxUniverses];
bool sendFrame = 1;

// Change ip and mac address for your setup
byte ip[] = {192, 168, 2, 200};
byte mac[] = {0x04, 0xE9, 0xE5, 0x00, 0x69, 0xEC};

void setup()
{
  Serial.begin(115200);
  artnet.begin(mac, ip);
  leds.begin();
  initTest();

  // this will be called for each packet received
  artnet.setArtDmxCallback(onDmxFrame);
}

void loop()
{
  // we call the read function inside the loop
  artnet.read();
}

void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data)
{
  sendFrame = 1;

  // Store which universe has got in
  if (universe < maxUniverses)
    universesReceived[universe] = 1;

  for (int i = 0 ; i < maxUniverses ; i++)
  {
    if (universesReceived[i] == 0)
    {
      //Serial.println("Broke");
      sendFrame = 0;
      break;
    }
  }

  // read universe and put into the right part of the display buffer
  for (int i = 0 ; i < length ; i++)
  {
    int bufferIndex = i + ((universe - startUniverse) * length);
    if (bufferIndex < numberOfChannels) // to verify
      channelBuffer[bufferIndex] = byte(data[i]);
  }     

  // send to leds
  for (int i = 0; i < ledsPerStrip * numStrips; i++)
  {
    leds.setPixel(i, channelBuffer[(i) * 3], channelBuffer[(i * 3) + 1], channelBuffer[(i * 3) + 2]);
  }     
 
  if (sendFrame)
  {
    leds.show();
    // Reset universeReceived to 0
    memset(universesReceived, 0, maxUniverses);
  }
}

void initTest()
{
  for (int i = 0 ; i < ledsPerStrip * numStrips ; i++)
    leds.setPixel(i, 127, 0, 0);
  leds.show();
  delay(500);
  for (int i = 0 ; i < ledsPerStrip * numStrips  ; i++)
    leds.setPixel(i, 0, 127, 0);
  leds.show();
  delay(500);
  for (int i = 0 ; i < ledsPerStrip * numStrips  ; i++)
    leds.setPixel(i, 0, 0, 127);
  leds.show();
  delay(500);
  for (int i = 0 ; i < ledsPerStrip * numStrips  ; i++)
    leds.setPixel(i, 0, 0, 0);
  leds.show();
}



Does not compile and throwing the errors shown in the file in my first post.



Code:
// Receive multiple universes via Artnet and control a strip of ws2811 leds via OctoWS2811
//
// This example may be copied under the terms of the MIT license, see the LICENSE file for details
//  https://github.com/natcl/Artnet
//
// http://forum.pjrc.com/threads/24688-Artnet-to-OctoWS2811?p=55589&viewfull=1#post55589

#include <Artnet.h>
#include <QNEthernet.h>
#include <SPI.h>
#include <OctoWS2811.h>

// Ideas for improving performance with WIZ820io / WIZ850io Ethernet:
// https://forum.pjrc.com/threads/45760-E1-31-sACN-Ethernet-DMX-Performance-help-6-Universe-Limit-improvements

// OctoWS2811 settings
const int ledsPerStrip = 150; // change for your setup
const byte numStrips= 8; // change for your setup
DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];
const int config = WS2811_GRB | WS2811_800kHz;
OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);

// Artnet settings
Artnet artnet;
const int startUniverse = 0; // CHANGE FOR YOUR SETUP most software this is 1, some software send out artnet first universe as zero.
const int numberOfChannels = ledsPerStrip * numStrips * 3; // Total number of channels you want to receive (1 led = 3 channels)
byte channelBuffer[numberOfChannels]; // Combined universes into a single array

// Check if we got all universes
const int maxUniverses = numberOfChannels / 512 + ((numberOfChannels % 512) ? 1 : 0);
bool universesReceived[maxUniverses];
bool sendFrame = 1;

// Change ip and mac address for your setup
byte ip[] = {192, 168, 2, 200};
byte mac[] = {0x04, 0xE9, 0xE5, 0x00, 0x69, 0xEC};

void setup()
{
  Serial.begin(115200);
  artnet.begin(mac, ip);
  leds.begin();
  initTest();

  // this will be called for each packet received
  artnet.setArtDmxCallback(onDmxFrame);
}

void loop()
{
  // we call the read function inside the loop
  artnet.read();
}

void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data)
{
  sendFrame = 1;

  // Store which universe has got in
  if (universe < maxUniverses)
    universesReceived[universe] = 1;
  for (int i = 0 ; i < maxUniverses ; i++)
  {
    if (universesReceived[i] == 0)
    {
      //Serial.println("Broke");
      sendFrame = 0;
      break;
    }
  }

  // read universe and put into the right part of the display buffer
  for (int i = 0 ; i < length ; i++)
  {
    int bufferIndex = i + ((universe - startUniverse) * length);
    if (bufferIndex < numberOfChannels) // to verify
      channelBuffer[bufferIndex] = byte(data[i]);
  }    
  // send to leds
  for (int i = 0; i < ledsPerStrip * numStrips; i++)
  {
    leds.setPixel(i, channelBuffer[(i) * 3], channelBuffer[(i * 3) + 1], channelBuffer[(i * 3) + 2]);
  }

  if (sendFrame)
  {
    leds.show();
    // Reset universeReceived to 0
    memset(universesReceived, 0, maxUniverses);
  }
}

void initTest()
{
  for (int i = 0 ; i < ledsPerStrip * numStrips ; i++)
    leds.setPixel(i, 127, 0, 0);
  leds.show();
  delay(500);
  for (int i = 0 ; i < ledsPerStrip * numStrips  ; i++)
    leds.setPixel(i, 0, 127, 0);
  leds.show();
  delay(500);
  for (int i = 0 ; i < ledsPerStrip * numStrips  ; i++)
    leds.setPixel(i, 0, 0, 127);
  leds.show();
  delay(500);
  for (int i = 0 ; i < ledsPerStrip * numStrips  ; i++)
    leds.setPixel(i, 0, 0, 0);
  leds.show();
}


Compiling and uploading but the teensy reset himself every few seconds.1
 
Last edited by a moderator:
Looks like you’ll need to update that Art-Net library. On Teensy 4.1, it looks like it’s always using NativeEthernet, which might not work well with the latest Teensyduino core. You can also remove the Ethernet includes from your main program.

In that library, replace the Ethernet includes with just <QNEthernet.h> and then just below that, add using namespace qindesign::network;.

Be sure, as well, to install the latest version of the QNEthernet library.
 
Back
Top