Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: New TeensyDMX library for Teensy 3

  1. #1
    Member
    Join Date
    Mar 2017
    Location
    Oakland, CA, USA
    Posts
    23

    New TeensyDMX library for Teensy 3

    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.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    15,720
    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?

  3. #3
    Member
    Join Date
    Mar 2017
    Location
    Oakland, CA, USA
    Posts
    23
    I've tested this with a Teensy 3.2. Thanks for posting it!
    (Side note: I think the link to DmxSimple needs to be corrected; it currently points to this thread.)
    (The link: https://www.pjrc.com/teensy/td_libs_DmxSimple.html)
    Last edited by shawn; 03-28-2017 at 08:40 PM. Reason: Adding a link to DmxSimple

  4. #4
    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!

  5. #5
    Member
    Join Date
    Mar 2017
    Location
    Oakland, CA, USA
    Posts
    23
    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()?

  6. #6
    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
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Screen Shot 2017-04-05 at 5.56.41 PM.png 
Views:	38 
Size:	37.1 KB 
ID:	10221  

  7. #7
    Member
    Join Date
    Mar 2017
    Location
    Oakland, CA, USA
    Posts
    23
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •