CM3-Home

RS-485 interface

The RS485 is commonly used to connect DMX512, Modbus or generic RS485 serial devices.

What is a RS485 ? What is a DMX512 ? What is a Modbus ?

Two RS485 lines are available on CM3-Home model Full and one on the model Basic. The lines are opto-isolated from the CPU and available on screw terminals as shown below.

How to use the RS485 ports

The ports are visible by Linux on /dev/ttyUSB0 (left port) and /dev/ttyUSB2 (right port) and can be managed by software like any other serial line. The DE signals required to get the bus are managed by the hardware on FTDI FT4232 chip.

Python example

Send and receive chars on the right RS485 port. To do the same on the left port change /dev/ttyUSB2 with /dev/ttyUSB0.

#!/usr/bin/python
import serial
import time

ser = serial.Serial(
    port='/dev/ttyUSB2',
    baudrate=115200,
    timeout=1,
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
    bytesize=serial.EIGHTBITS
)
ser.flushOutput()
ser.flushInput()

rx_counter=0
tx_counter=0
while True:
    tx_counter=tx_counter+1
    ser.write("Tx counter = %d | Rx counter = %d\n\r" % (tx_counter,rx_counter))
    print("Tx counter = %d | Rx counter = %d" % (tx_counter,rx_counter))

    a=ser.read(1)

    if a:
        rx_counter=rx_counter+1
        ser.write("Tx counter = %d | Rx counter = %d | Received: %s %02x\n\r" % (tx_counter,rx_counter,a,ord(a)))
        print("Tx counter = %d | Rx counter = %d | Received: %s %02x" % (tx_counter,rx_counter,a,ord(a)))

eShop

EUR 130.00


CM3-HOME-B - CM3-Home board basic edition

CM3-Home board basic edition

| Product description || CM3-Home catalog |

EUR 330.00


CM3-HOME-F - CM3-Home board full edition

CM3-Home board full edition

| Product description || CM3-Home catalog |

Author:
Sergio Tanzilli - tanzilli@acmesystems.it
http://www.tanzolab.it - http://www.tanzilli.com - https://github.com/tanzilli