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

Thread: Receiving DMX with a RS-485 and Teesny 4.1

  1. #1

    Receiving DMX with a RS-485 and Teesny 4.1

    I'm trying to receive DMX from a GrandMA2 lighting console but every packet is generating a "FramingError" and it seems like dmxRx.connected() is constantly alternating between true and false.
    If I re plug in the cable on the RE pin while it's running it will receive a single valid packet with the correct values SOMETIMES. This only happens at the exact moment I break or establish the connection.

    I'm using a Teensy 4.1, these RS-485 modules and the basic receive example from the TeensyDMX library

    Here's a schematic and picture
    Click image for larger version. 

Name:	Scheme_Recieve.jpg 
Views:	20 
Size:	106.8 KB 
ID:	23490 Click image for larger version. 

Name:	Untitled.jpg 
Views:	16 
Size:	106.1 KB 
ID:	23491

    The A/B is connected to a 6 foot XLR cable I cut in half, could it be the fact that I'm not using proper DMX cable?

    I've tried the following things with the same behavior:
    • Switching A/B on the RS-485 transceiver
    • Using the 3.3v rail
    • Disconnecting the TX
    • Sending LOW to DE and RE from a GPIO pin
    • Sending LOW to DE and RE using 2 separate GPIO pins
    • Connecting DE and RE to ground


    I'm new to all this stuff and I'm not sure what else to try so any help or tips is greatly appreciated.

    Thanks!

  2. #2
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    533
    The RS485 module you are using is a 5V part. Meaning it will output a too high voltage on the RO line that could kill your Teensy 4.1 [Teensy 4.1 pins are 3V3 tolerant only].
    You should look for a module that uses the MAX3485 part and will be powered by 3V3.

    Not sure whether this solves your problem but this is a first observation.

    Paul

  3. #3
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    533
    This module will be OK for Teensy 4.1: SparkFun Transceiver Breakout - RS-485.

    Paul

  4. #4
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    533
    Tried the Sparkfun DMX board on a Teensy 4.1 and it's working fine with the TeensyDMX library.
    Here is the setup:

    Click image for larger version. 

Name:	T4-DMXreceive.jpg 
Views:	21 
Size:	247.0 KB 
ID:	23499
    Pin 2 of the XLR plug connects to pin A on the SF board, XLR pin 3 to SF pin B, XLR pin 1 to SF pin G.

    My DMX source sends out 7 channels. A DMX frame is sent every 76-78 msecs. The Teensy LED shows DMX activity.

    The code I used:
    Code:
    #include <TeensyDMX.h>
    namespace teensydmx = ::qindesign::teensydmx;
    
    teensydmx::Receiver dmxRx{Serial1};
    uint8_t buf[7] {0};
    uint32_t previousMillis = 0;
    uint32_t currentMillis = 0;
    
    void setup() {
      pinMode(LED_BUILTIN, OUTPUT);
      Serial.println("Starting DMX receive");
      dmxRx.begin();
    }
    
    void loop() {
      currentMillis = millis();
      if (dmxRx.readPacket(buf, 1, 7) == 7) {
        digitalToggle(LED_BUILTIN);
        Serial.print(currentMillis - previousMillis); Serial.print("\t");
        previousMillis = currentMillis;
        Serial.printf("R G B A W D C: %03d %03d %03d %03d %03d %03d %03d\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
      }
    }
    shows this on the serial monitor:

    Click image for larger version. 

Name:	Serial.png 
Views:	18 
Size:	22.7 KB 
ID:	23500

    Paul

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,072
    Ugh, looks like the forum attachment bug struck again. Please repost.

  6. #6
    First off thank you so much for helping me with this.

    I went out and got the correct transceiver this morning but I still can't seem to get it working.


    Here's a schematic and image to make sure I'm following along correctly.
    Click image for larger version. 

Name:	schemeatic2.png 
Views:	19 
Size:	312.4 KB 
ID:	23519Click image for larger version. 

Name:	sdfgsdfg.jpg 
Views:	15 
Size:	85.6 KB 
ID:	23518

    I added a little bit of code to print out the error stats
    Code:
    #include <TeensyDMX.h>
    namespace teensydmx = ::qindesign::teensydmx;
    
    teensydmx::Receiver dmxRx{Serial1};
    uint8_t buf[7] {0};
    uint32_t previousMillis = 0;
    uint32_t currentMillis = 0;
    
    void setup() {
      pinMode(LED_BUILTIN, OUTPUT);
      Serial.println("Starting DMX receive");
      dmxRx.begin();
    }
    
    void loop() {
      currentMillis = millis();
      if (dmxRx.readPacket(buf, 1, 7) == 7) {
        digitalToggle(LED_BUILTIN);
        Serial.print(currentMillis - previousMillis); Serial.print("\t");
        previousMillis = currentMillis;
        Serial.printf("R G B A W D C: %03d %03d %03d %03d %03d %03d %03d\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
      } else {
        Serial.printf("FramingErrors: %d | PacketTimeouts: %d | ShortPackets: %d | LongPackets: %d | Connected: %d\n", 
          dmxRx.errorStats().framingErrorCount,
          dmxRx.errorStats().packetTimeoutCount,
          dmxRx.errorStats().shortPacketCount,
          dmxRx.errorStats().longPacketCount,
          dmxRx.connected()
         );
      }
    }
    This is what it's outputting.
    Click image for larger version. 

Name:	2.png 
Views:	18 
Size:	30.7 KB 
ID:	23517

    In the picture it looks like you have RX connected to the DI pin and the TX connected to the RO pin but it says "connect TX to the Driver Input and RX to the Receiver Output of the transceiver" under the hardware connection section in the libraries readme. I'm probably not understanding the transceiver circuit
    Edit: I think I'm understanding the transceiver circuit better.

    I've tried some other serial ports incase I fried Serial1 while I was using the 5v part. I also ran some basic sketches to make sure I didn't fry the teensy too.

    Thanks again

  7. #7
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    533
    and RX to the Receiver Output of the transceiver
    Yeah, the Receiver Output of the transceiver is called "TX-O" on the Sparkfun board [it got me confused too initially...]. Anyway, you hooked it up correctly.

    When I run your exact sketch, this is what is shown on the serial monitor:

    Click image for larger version. 

Name:	Serial.png 
Views:	19 
Size:	38.1 KB 
ID:	23521

    Looks OK again.

    Well, 2 things to check now:
    1. Teensy Serial port 1 might be broken.
    Try another serial port: connect the yellow wire to Teensy pin 7 [RX2] and the green wire to pin 8 [TX2] and change the constructor line to "teensydmx::Receiver dmxRx{Serial2};". You should see the correct data in the serial monitor. I just tried and it works.

    2. DMX source/controller might be the source of the problem.
    Can you verify one way or another that your DMX source is outputting valid data, either by connecting to a DMX spot or checking the DMX signal on an oscilloscope?

    Here is what my scope shows on the TX-O output of the SF transceiver:

    Click image for larger version. 

Name:	SDS00040.png 
Views:	11 
Size:	18.7 KB 
ID:	23522

    Paul

  8. #8
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    533
    Quote Originally Posted by PaulStoffregen View Post
    Ugh, looks like the forum attachment bug struck again. Please repost.
    Huh, I don't see an issue?

    Paul

  9. #9
    Senior Member
    Join Date
    Mar 2017
    Location
    Oakland, CA, USA
    Posts
    190
    I have to comment that 3-pin XLR is disallowed by the DMX standard. But having said that, it looks like your non-inverting input (A) is connected to pin 2 and B is connected to pin 3. Try swapping those. After some searching, it appears that pin 2 should be connected to B and pin 3 should be connected to A. This also matches the 5-pin pinout, where B goes to pin 2 and A goes to pin 3.

  10. #10
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    533
    Quote Originally Posted by shawn View Post
    I have to comment that 3-pin XLR is disallowed by the DMX standard
    Correct. However, there are a lot of (semi)pro DMX spots out there with the 3-pin XLR. This is the spot I tested with.
    You're right, I mixed up the pin numbers in message #4. Pin 2 of the XLR plug connects to pin B on the SF board, XLR pin 3 to SF pin A, XLR pin 1 to SF pin G.

    Thanks,
    Paul

Posting Permissions

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