Skip to main content

 

What is it?

If there’s a requirement to attach equipment to machines, one possible method would be to consider using an RS-232 interface.

RS-232 is a serial interface that can have a minimum of two or three wires (depending on if you need single direction or bidirectional communication!) with voltage levels of up to around +15V and -15V.

Once the connections have been made, it is possible to easily send and receive data using Linux, by using the /lib/ttyUSB0 device on the M.2 Eval System.

 

Connections on the M.2 Eval System

The Axelera M.2 Eval System has a connector that exposes this interface.  The photo here shows the pin connections.

Note that the connector also has a 5V supply output, but it’s best to avoid using that. The board could easily be damaged if too much current is attempted to be drawn from the 5V output. I don't know the limit, so personally I would not use it at all, or, restrict usage to just 10-20 mA.

The connector has a 2mm pitch pin spacing. I didn’t have a mating connector, so I soldered wires.

 

Interfacing to a Microcontroller

The RS-232 voltage levels cannot directly connect to a microcontroller.

An RS-232 transceiver board such as Adafruit RS232 Pal is used to convert to the levels, and automatically invert the signal, to become suitable for a microcontroller.

 

Source Code

Here is an example SerialComms.py file, which can be used to send text data.

To use, type:

python SerialComms.py "Hello there"
 

Alternatively, use it from within Python code:

from SerialComms import SerialComms

comms = SerialComms()

comms.send("Hello there")

 

Thanks for reading!

 

Great idea ​@shabaz ! It’s so cool that after all these years, RS-232 is still useful! Wasn’t it developed in the ‘60s, or something?!


Hi! It's amazing how long it's lasted as a standard. 

Machines might be plugging in their RS-232 ports in a totally AI world even in the 2060's : )

 


I think the reason RS232 (or it’s TTL/CMOS equivalent “UART”) have lasted such a long time is because they are very simple and yet so versatile.

  • Connections are VERY simple (just TX, RX to take care of)
  • Data throughput is enough for most use cases 
  • Data on the bus can be very easily made human-readable (not the case for some others like I2C, SPI, CAN etc which will always need some decoding. This is very good for logging/debugging
  • The protocol is asynchronous and does not limit message sizes - this keeps things simple, flexible and easy.
  • Cheap (hardware wise) to implement.

Can’t think of any other protocol that comes close :)


That’s true! Goes to show that the simplest solutions can last the longest!

Feels like there’s an analogy for everyday life in there somewhere...


Reply