Connect Omega 2 to UART tx1 and rx1 using Mini Dock



  • I can't figure out how to connect a MAX RS-485 chip to Omega 2 using the UART tx1 and rx1 pins when the Omega 2 is placed on the Mini Dock.

    Is it pin 45 and 46? Will I get ac /dev/tty-something device in Linux?

    Thanks for any pointing in the right directions!



  • Yes, those pins are for UART1 which is used for serial communication with other devices, but are the signal levels of the MAX RS-485 correct for the Omega2?? If not, you will need some level conversion. Onion has information about UART1 vs UART0 here.

    On the Mini Dock you could connect to those pins by soldering wires to the bottom of the dock. For testing, an Expansion Dock or Breadboard dock would enable easier connections via jumper wires.



  • I have an Expansion Dock as well , but I can't find RX1 and TX1 there. (yes I can).

    What do you mean by signal levels? I'm sorry, but I'm a bit new to this.



  • @Lars-Tobias-Skjong-Børsting I haven't used the MAX485 ... the RS-485 communication standard is from dozens of year ago. Please confirm that this chip will work with the 3.3 volt logic level of the Omegas and not supply a signal above 3.3 volts that the Omega UART is designed for. I mention this because the original RS-232 etc standard worked at 12 volts and other similar chips operate at 5 volt logic level. If this is the case for the MAX485 (I haven't had the chance to find and read the datasheet) then the higher voltage could damage the Omega UART.



  • @Ken-Conrad It says on the MAX485 that operating power to the chip is 5V. The RS-485 voltages are higher, but it is designed to work with the Raspberry Pi UART, so I guess it should be compatible with the Omega 2.

    I have this TTL UART to RS-485 board: https://www.aliexpress.com/item/5PCS-MAX485-RS-485-Module-TTL-to-RS-485-module-Raspberry-pi/32579369267.html



  • I could try to connect the 3.3V to the RS-485 board and see if it runs on it.



  • @Lars-Tobias-Skjong-Børsting I see no harm in trying 3.3V, but the Omega may not supply enough current for the device. Can you check the documentation for that board to learn what power it is designed for? Now I see the link to the board you are using. It is powered at 5V and made to work with the Raspberry Pi, which has 3.3 volt signal levels, so the signal levels are correct for the Omega.

    This is what I would try - supply the board with 5V and connect the board's TX to the Omega RX1, board's RX to Omega's TX1, open a serial console to the Omega and see if the pair can communicate.



  • @Ken-Conrad Thanks!

    I have now connected it up with 5V and put it on the RS485 line with minimalmodbus (python).

    However, I can't get anything from the serial /dev/ttyS1. I read that the Omega 2 has set a default baud rate of 115200, but I can't figure out how to change it.

    According to:

    root@Omega-AAAA:/# dmesg|grep -i baud
    [ 0.307914] 10000c00.uartlite: ttyS0 at MMIO 0x10000c00 (irq = 28, base_baud = 2500000) is a 16550A
    [ 0.332361] 10000d00.uart1: ttyS1 at MMIO 0x10000d00 (irq = 29, base_baud = 2500000) is a 16550A
    [ 0.341872] 10000e00.uart2: ttyS2 at MMIO 0x10000e00 (irq = 30, base_baud = 2500000) is a 16550A

    it looks like the baud rate is 2500000? It seems to be 9600, after what stty tells me.

    I need to use 19200 baud, no parity, for my modbus slave (Systemair HVAC). Will I have to change this in the boot parameters to the Linux kernel or can I change it after boot? How can I do it?

    Update: I tried to set it using stty, and from what I can tell from stty it is now set correctly. But still no reply from modbus.



  • stty is the tool to use.

    Note that it may actually handle send and receive speeds distinctly, though the hardware may not make a difference, still something to check.

    It would probably be good to do some tests with a plain logic level serial peripheral before you worry about the RS845.

    Also need to make sure your program is doing everything needed to access the serial port; there are a lot of details to get right. In theory it's not different than another Linux, but the default line settings vary from system to system, so code that makes any assumptions about how things are already set may fail when moved to a new one.



  • Thanks, Chris. stty does indeed seem to help out with the serial settings.

    Now, I've found out that my MAX485 chip is actually half duplex, and I didn't know that, but I guess I should have. The MAX488 chip is apparently full duplex, and I should have gotten that instead. So, I have to set a pair of pins to HIGH right before transmitting the command over RS-485, and then setting it to LOW immediately after, so that I can receive a response. HIGH is TX-mode and LOW is RX-mode

    I ran out of time to get it working today, but I plan to make some more time during the next few days.



  • Shared transmit and receive is a feature of RS485, even apart from whatever line driver/receiver chip you use. It does sometime gets popularly confused with RS422, which is similar but usually uses a distinct pair in each direction.

    To do RS485 with the direction signal controlled in software, you have to make sure that you leave the transmitter enabled not just until the last character is loaded into the UART, but until it is actually clocked out on the wire. Some UARTs can generate an interrupt for that, while others cannot - not sure which this is.

    Alternatively if you know the baud rate and can enforce a minimum time before a reply in your protocol, you may be able to use a timer to do it, either a software one, or else a sort of external electrical timeout timer repeatedly re-triggered by the data, that will then expire a bit over a character time after the last one and switch things around to receive.



  • @Lars-Tobias-Skjong-Børsting said in Connect Omega 2 to UART tx1 and rx1 using Mini Dock:

    I have this TTL UART to RS-485 board: https://www.aliexpress.com/item/5PCS-MAX485-RS-485-Module-TTL-to-RS-485-module-Raspberry-pi/32579369267.html

    I think your module is same or very similar like this: MAX485 MODULE RS-485 TO TTL CONVERTER
    so it is not designed for Raspberry Pi.

    On Omega2 at least at the RO pin of MAX485 some kind of 5V to 3.3V level shifting is needed.
    The simplest solution: put a voltage divider between RO and RX1.
    And you should connect the pull-up resistors of input pins (DI, DE, RE) to 3.3V.

    RS-485 can be made full-duplex by using four wires ie. two twisted pairs.
    Is your Modbus slave full-duplex?

    BTW you could build also full duplex config with two of your MAX485 modules. ;)


Log in to reply
 

Looks like your connection to Onion Community was lost, please wait while we try to reconnect.