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

Thread: midi to dmx on teensy 3.5

  1. #1
    Junior Member
    Join Date
    Aug 2018
    Posts
    8

    midi to dmx on teensy 3.5

    iím trying to build a fast, jitter-free MIDI to DMX box. i made one following this: https://imgur.com/a/vhwt9
    and it works, but itís a bit laggy.

    since i had a teensy 3.5 laying around, i thought iíd give it a go, and when i tried a basic midi receive example program:

    Code:
    int ledPin = 13;
    
    void OnNoteOn(byte channel, byte note, byte velocity) {
      digitalWrite(ledPin, HIGH); // Any Note-On turns on LED
    }
    
    void OnNoteOff(byte channel, byte note, byte velocity) {
      digitalWrite(ledPin, LOW);  // Any Note-Off turns off LED
    }
    
    void setup() {
      pinMode(ledPin, OUTPUT);
      usbMIDI.setHandleNoteOff(OnNoteOff);
      usbMIDI.setHandleNoteOn(OnNoteOn);
      digitalWrite(ledPin, HIGH);
      delay(400);                 // Blink LED once at startup
      digitalWrite(ledPin, LOW);
    }
    
    void loop() {
      usbMIDI.read(5);
    }
    it proved to be way more responsive, at least visually (LED flashing).

    iím a newbie and iím struggling to get the hang of Shawn Silvermanís examples in the TeensyDMX library. i wanted to use midi noteOn data from the example above be sent to one DMX channel, which seems rather simple, but i insist: iím a total noob, so not so easy for me.

    if anybody could give me any pointers on how to do this, perhaps using the basic send example in the TeensyDMX library (see code below), as i assume is the most basic one? BUT equally important, i need some pointers on hardware, cause i may have missed the info in the library files, and this may be a very silly question, but: how do i make these DMX messages go out via a DMX/XLR cable from my Teensy 3.5??? i read it goes over serial pins, but any example diagrams out there?

    MANY MANY THANKS!!!

    Code:
    /*
     * A basic toy send example.
     *
     * (c) 2019 Shawn Silverman
     */
    
    #include <TeensyDMX.h>
    
    namespace teensydmx = ::qindesign::teensydmx;
    
    // Pin for enabling or disabling the transmitter.
    constexpr uint8_t kTXPin = 17;
    
    // Create the DMX sender on Serial1.
    teensydmx::Sender dmxTx{Serial1};
    
    // Data for 3 channels.
    uint8_t data[3]{0x44, 0x88, 0xcc};
    
    void setup() {
      // Turn on the LED, for indicating activity
      pinMode(LED_BUILTIN, OUTPUT);
      digitalWriteFast(LED_BUILTIN, HIGH);
    
      // Set the pin that enables the transmitter
      pinMode(kTXPin, OUTPUT);
      digitalWriteFast(kTXPin, HIGH);
    
      dmxTx.begin();
    
      // Set some channel values. These are being set in setup() to illustrate that
      // values are 'sticky'. They stay set until changed. There's no special
      // function to call for each iteration of loop().
    
      // Set channel 1 to 128
      dmxTx.set(1, 128);
    
      // Set channels 10-12 to the 3 values in 'data'
      dmxTx.set(10, data, 3);
    }
    
    void loop() {
      // Do something, maybe alter channel values.
    }

  2. #2

  3. #3
    Junior Member
    Join Date
    Aug 2018
    Posts
    8
    certainly!!!!

  4. #4
    Member
    Join Date
    Mar 2017
    Location
    Oakland, CA, USA
    Posts
    97
    Try this:

    Code:
    namespace teensydmx = ::qindesign::teensydmx;
    
    // Create the DMX sender on Serial1.
    teensydmx::Sender dmxTx{Serial1};
    
    void OnNoteOn(byte channel, byte note, byte velocity) {
      digitalWrite(ledPin, HIGH); // Any Note-On turns on LED
    
      // Write this note to some channel, this example uses channel 17 and a value of 255 for ON.
      dmxTx.set(17, 255);
    }
    
    void OnNoteOff(byte channel, byte note, byte velocity) {
      digitalWrite(ledPin, LOW);  // Any Note-Off turns off LED
    
      // Write this note to some channel, this example uses channel 17 and a value of 0 for OFF.
      dmxTx.set(17, 0);
    }
    
    void setup() {
      pinMode(ledPin, OUTPUT);
      usbMIDI.setHandleNoteOff(OnNoteOff);
      usbMIDI.setHandleNoteOn(OnNoteOn);
      digitalWrite(ledPin, HIGH);
      delay(400);                 // Blink LED once at startup
      digitalWrite(ledPin, LOW);
    
      // Initialize DMX
      // NOTE: Depending on your setup, you may or may not have to enable TX with a write to a pin
      dmxTx.begin();
    }
    
    void loop() {
      // I'm not sure what you're doing with this value. Is it needed if you have those callbacks?
      usbMIDI.read(5);
    }
    A couple of notes:
    1. Depending on your setup, you may need to enable the TX driver with a write to a pin.
    2. You need to choose which 1-based channel to write to, and which values to use for the note values.


    The basic steps for using TeensyDMX send are:
    1. Create an object of type `Sender` with one argument containing the serial port you're using.
    2. Set any pins, depending on your hardware, to enable the TX. This step may not be needed.
    3. Initialize the sender using its `begin()` method.
    4. Call `set` whenever you need to set something on a channel. Also remember that channel numbers are 1-based.
    Last edited by shawn; 08-13-2019 at 07:43 AM.

Posting Permissions

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