Teensy3.0 and Wiz812MJ

Status
Not open for further replies.
@Paul well at least that takes the time pressure off me! I was going to try and get it done in time for an up coming gig, I'm using 2811's, the ones on a string rathe than a strip, and all are working great, can't have more than 100 per pin without voltage drop, but they seem pretty sturdy, no dead pixels out of 1000, some of them would only do data from 1 end and not the other, but apart from that they're great!
I dont think I'm going to be able to help you speed up the ethernet though, too newby for that just yet, especially given that I can't even get a regulator to work!
 
This last board has no headers, I just powered it from the 2 pin + in a circle pins...
Do you want me to try other pins?
 
I havent put the jumpers on, but that just routes to the output headers I think?
Nothing else is connected
 
That 2 pin with a circle around it is a symbol for a Capacitor to decouple the 3.3V output. You should not connect the 5V to these two pins.
You need to connect power to the two most upper pins as shown in the image. then you should be able to measure 3.3V between GND and the 3.3 pin as indicated.
The attached image shows you what is powered and where to measure what. No wonder you're breaking stuff!!!*
WIZ821Adapter.jpg
 
Headroom's picture is correct. You must apply the power to the 2 pins on the corners. Those are the GND and +5V pins on Teensy2. Remember, this thing is meant to mount on top of a Teensy2 board.

Here's my image from #2. The +5V is the wire without insulation (actually, several leftover leads from through-hole parts). Notice how it goes to the corner of the adaptor....

View attachment 673
 
Last edited:
Ah! 3.3V
Thats better!
Well I'm sorry for taking up so much bandwidth, and thank you all for your help...
At least I can solder smd now, so at least I've learnt something ;)
And I do like to know why things work, or don't work, I have to troubleshoot in my job a lot
Thanks again!
 
The maximum USB cable length is 5 meters. But the actual USB spec is based on signal delay using USB 1.1 hubs. So much longer cables are possible, especially at the 12 Mbit/sec speed Teensy uses. You still can't go nearly as far as ethernet's 100 meter limit.

Later this year I'm planning to publish a project using ethernet (E1.31 protocol) to a Beaglebone Black, which then distributes data to several Teensy3s running OctoWS2811.
 
daisy-chained hubs (aka USB extension cables) - something like 5 or 6 max as I recall - excluding a hub that might be inside the PC.
 
As to the Ethernet Benchmark, Paul, once I have my Frankenduino running - hopefully within the next 2-3 weeks - I hope I can enlist Adrian Freed's help in coming up with a form of Benchmark. While it likely is some form of OSC it should be very well transferable to other areas, such as this as well.

We shall see how much performance we can squeeze out of the Teensy3 WIZ820io partnership ;-)
 
Just so you know, with the power correctly connected (eh-hum !:eek:) The boards work, the wiz board that got the 7.5V is obviously dead, but the first board that got 5v is fine!
Webserver compiled as expected and all is good, so thank you again for putting up with my pestering!
 
Just been looking into udp now...
Currently the UDP buffer seems to recieve the whole packet, ie packet size is reported as 300 or 1000 or what ever, but if you print this to the serial viewer, you only get the first 24bytes
Googling led me to this article, which has some patches available for udp, regarding packets sizes
google code link
but I dont currently now how to apply the patches, so I thought I'd leave it here in case anyone else is wondering about this too...

Ah found that you can set the max buffer in the EtherentUDP.h and so get the whole buffer, I've changed it to 2048...
This is the video display code I'm using, I'm sure I've probably ignored something in here and broken it, needless to say no LED's light up at the moment!

Code:
/*  OctoWS2811 VideoDisplay.ino - Video on LEDs, from a PC, Mac, Raspberry Pi
    http://www.pjrc.com/teensy/td_libs_OctoWS2811.html
    Copyright (c) 2013 Paul Stoffregen, PJRC.COM, LLC

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.

 
  Required Connections
  --------------------
    pin 2:  LED Strip #1    OctoWS2811 drives 8 LED Strips.
    pin 14: LED strip #2    All 8 are the same length.
    pin 7:  LED strip #3
    pin 8:  LED strip #4    A 100 to 220 ohm resistor should used
    pin 6:  LED strip #5    between each Teensy pin and the
    pin 20: LED strip #6    wire to the LED strip, to minimize
    pin 21: LED strip #7    high frequency ringining & noise.
    pin 5:  LED strip #8
    pin 15 & 16 - Connect together, but do not use
    pin 4:  Do not use
    pin 3:  Do not use as PWM.  Normal use is ok.
    pin 12: Frame Sync

    When using more than 1 Teensy to display a video image, connect
    the Frame Sync signal between every board.  All boards will
    synchronize their WS2811 update using this signal.

    Beware of image distortion from long LED strip lengths.  During
    the WS2811 update, the LEDs update in sequence, not all at the
    same instant!  The first pixel updates after 30 microseconds,
    the second pixel after 60 us, and so on.  A strip of 120 LEDs
    updates in 3.6 ms, which is 10.8% of a 30 Hz video frame time.
    Doubling the strip length to 240 LEDs increases the lag to 21.6%
    of a video frame.  For best results, use shorter length strips.
    Multiple boards linked by the frame sync signal provides superior
    video timing accuracy.

    A Multi-TT USB hub should be used if 2 or more Teensy boards
    are connected.  The Multi-TT feature allows proper USB bandwidth
    allocation.  Single-TT hubs, or direct connection to multiple
    ports on the same motherboard, may give poor performance.
*/

#include <OctoWS2811.h>
#include <SPI.h>         // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h>         // UDP library from: bjoern@cs.stanford.edu 12/30/2008



// The actual arrangement of the LEDs connected to this Teensy 3.0 board.
// LED_HEIGHT *must* be a multiple of 8.  When 16, 24, 32 are used, each
// strip spans 2, 3, 4 rows.  LED_LAYOUT indicates the direction the strips
// are arranged.  If 0, each strip begins on the left for its first row,
// then goes right to left for its second row, then left to right,
// zig-zagging for each successive row.
#define LED_WIDTH      50   // number of LEDs horizontally
#define LED_HEIGHT     8   // number of LEDs vertically (must be multiple of 8)
#define LED_LAYOUT     0    // 0 = even rows left->right, 1 = even rows right->left

// The portion of the video image to show on this set of LEDs.  All 4 numbers
// are percentages, from 0 to 100.  For a large LED installation with many
// Teensy 3.0 boards driving groups of LEDs, these parameters allow you to
// program each Teensy to tell the video application which portion of the
// video it displays.  By reading these numbers, the video application can
// automatically configure itself, regardless of which serial port COM number
// or device names are assigned to each Teensy 3.0 by your operating system.
//#define VIDEO_XOFFSET  0
//#define VIDEO_YOFFSET  0       // display entire image
//#define VIDEO_WIDTH    100
//#define VIDEO_HEIGHT   100

//#define VIDEO_XOFFSET  0
//#define VIDEO_YOFFSET  0     // display upper half
//#define VIDEO_WIDTH    100
//#define VIDEO_HEIGHT   50

#define VIDEO_XOFFSET  0
#define VIDEO_YOFFSET  50    // display lower half
#define VIDEO_WIDTH    100
#define VIDEO_HEIGHT   50


const int ledsPerStrip = LED_WIDTH * LED_HEIGHT / 8;

DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];
elapsedMicros elapsedUsecSinceLastFrameSync = 0;

const int config = WS2811_800kHz; // color config is on the PC side

OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);
//udp
byte mac[] = {  
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177);

unsigned int localPort = 8888;      // local port to listen on

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
//char  ReplyBuffer[] = "acknowledged";       // a string to send back

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;
//udp

void setup() {
 // pinMode(12, INPUT_PULLUP); // Frame Sync
  Serial.setTimeout(50);
  leds.begin();
  leds.show();
  // start the Ethernet and UDP:
  Ethernet.begin(mac,ip);
  Udp.begin(localPort);
}

void loop() {
Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);

  int startChar = (int)packetBuffer; //Serial.read();

  if (startChar == '*') {
    // receive a "master" frame - we send the frame sync to other boards
    // the sender is controlling the video pace.  The 16 bit number is
    // how far into this frame to send the sync to other boards.
    unsigned int startAt = micros();
    unsigned int usecUntilFrameSync = 0;
 //   int count = Udp.readBytes((char *)&usecUntilFrameSync, 2);
  //  if (count != 2) return;
  int  count = Udp.readBytes((char *)drawingMemory, sizeof(drawingMemory));
    if (count == sizeof(drawingMemory)) {
      unsigned int endAt = micros();
      unsigned int usToWaitBeforeSyncOutput = 100;
//      if (endAt - startAt < usecUntilFrameSync) {
 //       usToWaitBeforeSyncOutput = usecUntilFrameSync - (endAt - startAt);
 //     }
   //   digitalWrite(12, HIGH);
    //  pinMode(12, OUTPUT);
      delayMicroseconds(usToWaitBeforeSyncOutput);
   //   digitalWrite(12, LOW);
      // WS2811 update begins immediately after falling edge of frame sync
      digitalWrite(13, HIGH);
      leds.show();
      digitalWrite(13, LOW);
    }

  } else if (startChar == '$') {
    // receive a "master" frame - we send the frame sync to other boards
    // we are controlling the video pace.  The 16 bit number is how long
    // after the prior frame sync to wait until showing this frame
    unsigned int usecUntilFrameSync = 0;
    int count = Serial.readBytes((char *)&usecUntilFrameSync, 2);
    if (count != 2) return;
    count = Serial.readBytes((char *)drawingMemory, sizeof(drawingMemory));
    if (count == sizeof(drawingMemory)) {
      digitalWrite(12, HIGH);
      pinMode(12, OUTPUT);
      while (elapsedUsecSinceLastFrameSync < usecUntilFrameSync) /* wait */ ;
      elapsedUsecSinceLastFrameSync -= usecUntilFrameSync;
      digitalWrite(12, LOW);
      // WS2811 update begins immediately after falling edge of frame sync
      digitalWrite(13, HIGH);
      leds.show();
      digitalWrite(13, LOW);
    }

  } else if (startChar == '%') {
    // receive a "slave" frame - wait to show it until the frame sync arrives
    pinMode(12, INPUT_PULLUP);
    unsigned int unusedField = 0;
    int count = Serial.readBytes((char *)&unusedField, 2);
    if (count != 2) return;
    count = Serial.readBytes((char *)drawingMemory, sizeof(drawingMemory));
    if (count == sizeof(drawingMemory)) {
      elapsedMillis wait = 0;
      while (digitalRead(12) != HIGH && wait < 30) ; // wait for sync high
      while (digitalRead(12) != LOW && wait < 30) ;  // wait for sync high->low
      // WS2811 update begins immediately after falling edge of frame sync
      if (wait < 30) {
        digitalWrite(13, HIGH);
        leds.show();
        digitalWrite(13, LOW);
      }
    }

  } else if (startChar == '@') {
    // reset the elapsed frame time, for startup of '$' message playing
    elapsedUsecSinceLastFrameSync = 0;

  } else if (startChar == '?') {
    // when the video application asks, give it all our info
    // for easy and automatic configuration
    Serial.print(LED_WIDTH);
    Serial.write(',');
    Serial.print(LED_HEIGHT);
    Serial.write(',');
    Serial.print(LED_LAYOUT);
    Serial.write(',');
    Serial.print(0);
    Serial.write(',');
    Serial.print(0);
    Serial.write(',');
    Serial.print(VIDEO_XOFFSET);
    Serial.write(',');
    Serial.print(VIDEO_YOFFSET);
    Serial.write(',');
    Serial.print(VIDEO_WIDTH);
    Serial.write(',');
    Serial.print(VIDEO_HEIGHT);
    Serial.write(',');
    Serial.print(0);
    Serial.write(',');
    Serial.print(0);
    Serial.write(',');
    Serial.print(0);
    Serial.println();

  } else if (startChar >= 0) {
    // discard unknown characters
  }
}
 
Last edited:
The ethernet frame buffer on the 812MJ/5100 will, assuming it's empty enough, accept and store the incoming UDP packet and set a status bit that a new packet arrived. The host micro needs to copy any still present bytes from a prior packet and all or most from the current packet, before the next UDP packet arrives. there's no flow control inherent in UDP - if there is any, it's up to the application programs on each end of the link to do flow control to prevent buffer overrun.
 
As to the Ethernet Benchmark, Paul, once I have my Frankenduino running - hopefully within the next 2-3 weeks - I hope I can enlist Adrian Freed's help in coming up with a form of Benchmark. While it likely is some form of OSC it should be very well transferable to other areas, such as this as well.

We shall see how much performance we can squeeze out of the Teensy3 WIZ820io partnership ;-)

Here are some TCP and UDP performance numbers on Teensy3 with wiznet WIZ820io, also DUE, UNO, and maple numbers.
https://github.com/manitou48/DUEZoo/blob/master/wizperf.txt

teensy sketches at
https://github.com/manitou48/teensy3
 
BBB to multiple Teensy3 "edge devices"

Paul, what will be the interface BBB to Teensy3? (Sorry, thought this would show up as a sub-thread to your BBB-Teensy3-LED project mention.) We are looking at a similar architecture for a commercial kiosk where the BBB does the Ethernet to the back office, and each Kiosk has at least 4 Teensy3, one for each of four shelves. Each shelf has up to 3 compartments with its own lighting and heating controls. Each compartment has a small OLED or LCD to display status, price, etc. If we give each shelf its own power supply too (24V at up to 10 Amps max) then a shelf can be swapped out in the field. If each compartment has its own Teensy that is up to twelve per kiosk which seems a bit of overkill; but each shelf typically has three compartments each with its own lighting and heat needs. So one Teensy 3 could in that case need to control 3 displays (via buffered SPI since wires are over a meter long) plus three heat and lighting schedules. Displays will be small OLED monocolor (low cost) or 3.5 to 4.3" LCD touch screens perhaps using new FTDI FT800 chips (best features). Lights and heat and sensors will be I2C again using I2C extender/buffer since each shelf is a meter long. We have not settled on the interface to connect the four Teensy3 to the BBB. Something party-line using RS485 or 422 and Modbus? We are not sure. BBB would send commands to the shelves (not often) and the shelves would send periodic status or alarms to the BBB. The BBB has a 7-inch touchscreen for admin use and monitoring the whole kiosk.
 
Last edited:
Status
Not open for further replies.
Back
Top