Sending serial commands to RS232 device

jonesyro

Active member
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.
 
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
 
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.
 
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.
 
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:

image001.png

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/B091TN2ZPY/ref=ppx_yo_dt_b_asin_title_o03_s00?ie=UTF8&psc=1 but it's not working.

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

and this:

https://www.amazon.com/gp/product/B09BCKWL8V/ref=ppx_yo_dt_b_asin_title_o00_s00?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.
 
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
 
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:
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.
 
Back
Top