New TeensyDMX library for Teensy 3

Status
Not open for further replies.

shawn

Well-known member
I created a new DMX library for Teensy 3: https://github.com/ssilverman/TeensyDMX

I wrote it partly as an exercise to learn how to do this kind of thing on the Teensy. Comments are welcome.

Some features:
  1. Teensy's default serial buffer isn't used; the data goes directly to/from the DMX buffers from/to the ISR's.
  2. Simple API: After setup, there's only one read call (`readPacket`) and two forms of one write call (`set` for single and multiple channels).
  3. The library properly handles DMX packets containing less than 513 slots.
 
Great. I've added a link to this thread from the DmxSimple page. Hopefully that will help people interested in DMX find this one too.

Can you tell me which Teensy boards this library has been used with so far?
 
Hey Shawn,

Just wanted to say thank you. I'm testing a new board, my first that will be transmitting and receiving at the same time (different ports, don't worry). I tried switching to Chris's (et al)'s library but couldn't get it to work. Ward's version worked fine. Switched to yours and I'm receiving again. Next up, trying to add simultaneous transmit. Shouldn't be too hard.

Only thing I noticed is that while testing I often plug and unplug the DMX cable to test my receive indicator. Depending on where I am in the packet when I unplug, sometimes my next read shows all zeros. It's not a problem for me, but wanted to mention it.

I'm curious about RDM. I was going to experiment with it had I gotten Chris's library working. I still might try eventually. If you end up doing any work on that front I'd love to have a look and mess with it.

Thanks again!
 
Hey, jkoffman. Really glad you're finding it useful, and thank you for the feedback. RDM is planned but when I have a chance to get to it.

Can you tell me more about what happens when you unplug the DMX and you get all zeros? Curious, are you checking the length returned by readPacket()?
 
Hi Shawn,

Keep me posted, I'd be happy to help test RDM if that's useful.

Here's a snippet of code I'm running in my main loop:

Code:
  int read = dmxRx.readPacket(DMXRX_Buff, 1, 512);
  if (read > 0) 
  {
    LED_DMXRX_State = 4;
    digitalWrite(LED_DMXRX, HIGH);
    Serial.print(DMXRX_Buff[0]);
    Serial.print(", ");
    Serial.print(DMXRX_Buff[1]);
    Serial.print(", ");
    Serial.print(DMXRX_Buff[2]);
    Serial.print(",,, ");    
    Serial.println(DMXRX_Buff[511]);
  }

Basically I'm storing the whole packet, then printing the first three, then the last value. This was so I could double check I was receiving the correct values where I thought they should be. No issues there.

Attached (hopefully) is a screenshot of my serial monitor. The two anomalous areas you see are where I unplugged the XLR, then replugged, then unplugged again.

Like I said, I think it's based on when in the packet I happened to unplug. It isn't a huge deal for my purposes at the moment. In the future I'll probably put in a timeout that zeros the buffer if it detects a drop in DMX.

Let me know if the image didn't work, I will try to attach again.

Josh
 

Attachments

  • Screen Shot 2017-04-05 at 5.56.41 PM.png
    Screen Shot 2017-04-05 at 5.56.41 PM.png
    37.1 KB · Views: 241
jkoffman: Curious what the 'read' value is when receiving a packet. It will return the number of bytes actually read, up to and including the given length. Maybe the received packet, in the case of a disconnected cable in the middle of one, is actually much smaller?
 
@jkoffman: I believe I have a fix for the all-zeros issue. Let me know if you have some time to test a new branch.
 
A quick question: with this library I can handle more "universes" like having 4 DMX Outputs in one Teensy board?
Thank you @shawn
 
I just released v2.3.0 that contains better handling of packet boundaries and timeouts. I *think* this may solve @jkoffman's "unplugging problem".
 
Gents I wonder if you would help. I have failed to get DmxSimple to work on my Teensy 3.2 even using the basic built in examples and looking at the code it seems to be the exact opposite of Simple with hard coded timings etc. Shawn's library seems to me to be a much better option using the hardware properly but I have failed to find the way to use libraries that are not already compiled and provided via the IDE. Is there a How To or similar somewhere to help people like me get going. Thanks
 
What you are asking for, is a common standard procedure in the Arduino IDE...

First, you go on the GitHub page of the library which you want to install. There is a green button "Clone or download". When you click on it, a sub-menu opens and you click on "Download ZIP".

In a next step, you need to install that downloaded library in the Arduino IDE: In the "Sketch" menu, select "Include a library" => "Add a .zip File" (or similar, my menus are in French language and I translate freely...). Navigate to the just downloaded zip file (most probably in your Downloads folder), and click on the select button. Now, go again to the "Sketch" menu, select "Include a library" and browse the sub menu down to "Contributed Libraries" where you will find and click the freshly installed TeensyDMX library.
 
Thank you that worked perfectly. I tried following the Arduino - LibraryTurorial under hacking and that failed for reasons that I do not understand - maybe it's out of date.

I will let you know how I fair in a few days time.
 
Or, a better option sometimes, if you didn’t want the “in progress code”, go to the “Releases” section and download the latest zip version from there.
 
@FreekyFrank I added the TeensyDMX library to the main Arduino library list, so it should just be findable using the "Library Manager" in the Arduino IDE.
 
I just released v3.0.0-beta. It's been tested on all the serial ports on 3.2, 3.5, 3.6, and LC, which the exception of Serial6 on 3.6.

Serial6 on Teensy 3.6 "should" work, but I've never soldered onto the bottom. It's a slightly different code path because it uses LPUART0. Does anyone have any interest in testing Serial6 on 3.6 for me?

Testing equipment that I used:
  • DMXking ultraDMX2 PRO, both over Art-Net (because sACN doesn't yet support RDM) and USB
  • RS-485 Breakout from SparkFun
  • @brtaylor's RS-485 backpack

I tested DMX send and receive, along with some other special packet types, including SIP, text packets, and RDM.
 
It's never going to be perfect, so I just went ahead and released v3.0.0. There's a few minor fixes and improvements, but there aren't any major changes.
 
Hey Shawn,

Congratulations on another major release!

I'm curious if you have any examples of a project that implements an RDM responder and uses the data to say, change the DMX receive address.

I am looking at using RDM to allow configuration of a project without a display, so I'm starting to research how I can receive and transmit settings that are actually used by the project.

Thanks!
 
Last edited:
Gotcha. Well, should you decide you'd like someone to take a look, I'd be happy to.

I will check out Chris's library. I remember looking at it awhile back and I think I remember that he had an RDM querrier. I can't remember finding a responder, but I will check!

Thanks!
 
I just released v3.1.1. It contains some bug fixes and a better library description. It is my belief that the API is now complete enough to do most things you'd want to do with DMX. For example, RDM and SIP (via a synchronous operation mode), variable rates and packet sizes, and implementing a DMX USB Pro widget via serial. There's also a new section in the Readme that touches on how to connect an RS-485 transceiver, plus a section on how to make "connection detection" work.

I have plans for a DMX USB Pro widget example and possibly an RDM example in a future release. The USB Pro widget example allows the Teensy to behave as a DMX USB Pro via a serial protocol. I have it working, but haven't yet tested all the parts.

Testers (especially for Serial6 on the Teensy 3.6) and feedback are more than welcome.
 
I just released v3.2.1 that fixes the receive problems in v3.2.0. It's in a branch named `fix-dmx-receive-in-v3.2.0` and not `master`. I'm not sure if the Arduino Library Manager or PlatformIO will find it; if not, you can find the release at https://github.com/ssilverman/TeensyDMX/releases/tag/v3.2.1 and simply unzip its contents over the v3.2.0 library in your Arduino or PlatformIO library location.

The v4.0.0-alpha.1 release contains the same fixes, but some might be uncomfortable with "alpha" in the name.

Side question for anyone receiving 8N2 serial data on a Teensy LC: Do you find that R8 in UARTx_C3 never returns 1?
 
Last edited:
Status
Not open for further replies.
Back
Top