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

Thread: Sending serial commands to RS232 device

  1. #1

    Sending serial commands to RS232 device

    Hi -

    I'm trying to send commands from a Teensy 4.1 to a RS232 light controller and it's not working.

    The light controller serial settings are: 115200baud, no parity, 8 data bits and 1 stop bit. The chip inside the controller used for serial communications is a Max3221 (Datasheet here)

    The wiring is as follow:

    RS232 DEVICE:

    Pin 5 = GND connected to Teensy Ground
    Pin 2 = TX connected to Teensy pin 7 (RX2)
    Pin 3 = RX connected to Teensy pin 8 (TX2)

    For testing I installed 2 push buttons on a breadboard with the Teensy and used the code below to send these commands:

    Button 1 command: RT1,0.1μS,0.500,700;
    Button 2 command: RT1,0.1μS,0.500,0;

    Code:
    #include <ezButton.h>
    
    ezButton button1(2);  // create ezButton object that attach to pin
    ezButton button2(3);  // create ezButton object that attach to pin
    
    
    void setup() {
      Serial2.begin(115200);
      button1.setDebounceTime(50); // set debounce time to 50 milliseconds
      button2.setDebounceTime(50); // set debounce time to 50 milliseconds
      
    }
    void loop() {
      button1.loop(); // MUST call the loop() function first
      button2.loop(); // MUST call the loop() function first
    
      
     
      if(button1.isReleased())
        Serial2.write("RT1,0.1μS,0.500,700;\r\n");
    
      if(button2.isReleased())
        Serial2.write("RT1,0.1μS,0.500,0;\r\n");
    
     }
    I tried using Serial.print, Serial.println etc but the controller doesn't respond.

    If I connect a USB to Serial Adapter Cable from the controller to my PC and use the Arduino Serial monitor, I can successfully send the commands to the controller.

    Thanks for looking at this.

  2. #2
    Researching more about the issue looks like I need something like a MAX3232 chip to convert RS232 signal to TTL logic on Teensy - is that a correct assumption? I would have thought the max3221 on the controller side would work with Teensy without max3232

  3. #3
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,229
    Yes, a suitable converter is needed - watch the voltage before making any connection.

    From Wiki Voltage levels:
    The RS-232 standard defines the voltage levels that correspond to logical one and logical zero levels for the data transmission and the control signal lines. Valid signals are either in the range of +3 to +15 volts or the range −3 to −15 volts with respect to the "Common Ground" (GND) pin;
    Those voltages are not Teensy UART pin compatible.

  4. #4
    Quote Originally Posted by defragster View Post
    Yes, a suitable converter is needed - watch the voltage before making any connection.

    From Wiki Voltage levels:


    Those voltages are not Teensy UART pin compatible.
    thx for looking at this - I ordered some converters will get them tomorrow.

  5. #5
    Quote Originally Posted by defragster View Post
    Yes, a suitable converter is needed - watch the voltage before making any connection.

    From Wiki Voltage levels:


    Those voltages are not Teensy UART pin compatible.

    I got this reply from the light controller manufacturer:

    Hello

    That should be just fine. We use a Max3221 device in the controller:

    Click image for larger version. 

Name:	image001.png 
Views:	19 
Size:	142.3 KB 
ID:	28307

    As you can see this will operate quite happily at these voltage levels.

    I hope that helps.

    Regards
    I got this module: https://www.amazon.com/gp/product/B0...?ie=UTF8&psc=1 but it's not working.

    I have this also coming in:
    https://www.amazon.com/gp/product/B0...?ie=UTF8&psc=1

    and this:

    https://www.amazon.com/gp/product/B0...?ie=UTF8&psc=1

    I don't understand why I would need any converters when the chip (max3221)in the light controller has 3.3v

    But regardless, I can't send any commands from an Arduino or Teensy.. with or without the first module I linked to. Will try the other modules when I get them.

  6. #6
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,229
    Maybe this helps? quora.com/What-is-difference-between-RS232-and-UART

    UART is hardware detecting 0v as LOW or logic HIGH. It works with short wires directly feeding the MCU.

    RS232 uses +V and -V and defines a protocol that works over longer distances.

    RS232 needs a converter to take the RS232 signal levels and protocol into suitable Teensy logic signals

  7. #7
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    806
    If you originally connected the light controller to the Teensy WITHOUT the RS232/TTL level converter then you will have killed those Teensy inputs. +/-12V into a 3.3v device results in sudden death of the device or device inputs.
    EDIT:
    You might try a different Teensy Serial port.
    Last edited by BriComp; 05-07-2022 at 10:21 AM.

  8. #8
    Quote Originally Posted by BriComp View Post
    If you originally connected the light controller to the Teensy WITHOUT the RS232/TTL level converter then you will have killed those Teensy inputs. +/-12V into a 3.3v device results in sudden death of the device or device inputs.
    EDIT:
    You might try a different Teensy Serial port.

    Finally got it to work with one of the converter module. The teensy and all its serial ports are fine. Thx everyone for helping.

  9. #9
    Junior Member
    Join Date
    Jun 2020
    Location
    Massachusetts
    Posts
    7
    Quote Originally Posted by jonesyro View Post
    Finally got it to work with one of the converter module. The teensy and all its serial ports are fine. Thx everyone for helping.
    Which one?

Posting Permissions

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