EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  <20252026  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  <20252026 
<== Date ==> <== Thread ==>

Subject: Re: Modbus asyn issue with RS485 connection (maybe hardware related)
From: "Heinz Junkes \(FHI\) via Tech-talk" <[email protected]>
To: Mark Rivers via Tech-talk <[email protected]>
Date: Wed, 13 Aug 2025 17:26:35 +0200
Hi,

as so often when you have written something here ;-)

The hardware board offers two modes via jumpers : RS485-RX and RS485-TX.

In Mode RS485-TX (in our case without jumper)

asynSetOption("DISCM",0,"rs485_enable", "Y”)

works as the sole option.

We had previously set the RS485-RX mode with a jumper and then
SER_RS485_RTS_AFTER_SEND must be set
(and SER_RS485_RTS_ON_SEND must not be set).

Viele Grüße
Heinz


> On 13. Aug 2025, at 16:19, Heinz Junkes (FHI) via Tech-talk <[email protected]> wrote:
>
> Hi,
> we want to operate a motor (https://www.omc-stepperonline.com/de/icl-serie-nema-17-integrierter-rs485-schrittmotor-mit-geschlossenem-regelkreis-0-4nm-56-64oz-in-20-36vdc-mit-14-bit-encoder-icl42-rs06) directly via RS485 (https://jetwaycomputer.com/spec/expansion/ADPIE1COM4.pdf) with modbus.
>
> In order to be able to operate the motor with our hardware setup, we need to set the serial interface to
> SER_RS485_ENABLED and SER_RS485_RTS_AFTER_SEND.
>
> We do this via asynSetOption():
>
> asynSetOption("DISCM",0,"rs485_enable", "Y")
> asynSetOption("DISCM",0,"rs485_rts_after_send", "Y”)
>
> This can be found in the Linux kernel:
>
> +/* We should do proper H/W transceiver setting before change to RS485 mode */
> +static int f81504_rs485_config(struct uart_port *port,
> +       struct serial_rs485 *rs485)
> +{
> + u8 setting;
> + u8 *index = (u8 *)port->private_data;
> + struct pci_dev *pci_dev = container_of(port->dev, struct pci_dev, dev);
> +
> + pci_read_config_byte(pci_dev, UART_START_ADDR + UART_OFFSET * *index +
> + UART_MODE_OFFSET, &setting);
> +
> + if (!rs485)
> + rs485 = &port->rs485;
> + else if (rs485->flags & SER_RS485_ENABLED)
> + memset(rs485->padding, 0, sizeof(rs485->padding));
> + else
> + memset(rs485, 0, sizeof(*rs485));
> +
> + /* F81504/508/512 not support RTS delay before or after send */
> + rs485->flags &= SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND;
> +
> + if (rs485->flags & SER_RS485_ENABLED) {
> + /* Enable RTS H/W control mode */
> + setting |= RTS_CONTROL_BY_HW;
> +
> + if (rs485->flags & SER_RS485_RTS_ON_SEND) {
> + /* RTS driving high on TX */
> + setting &= ~RTS_INVERT;
> + } else {
> + /* RTS driving low on TX */
> + setting |= RTS_INVERT;
> + }
> +
>
> This means that when SER_RS485_ENABLED (0x01) is set, SER_RS485_RTS_ON_SEND (0x02) is also set automatically.
>
> However, in order to be able to communicate with the motor via Modbus (with our hardware), we need the flag 0x05
> (SER_RS485_ENABLED | SER_RS485_RTS_AFTER_SEND) // SER_RS485_RTS_AFTER_SEND == 0x04
>
> We have implemented this as a workaround. If this is of general interest, I will make a pull-request to asyn.
>
> epics@epics-gate14:~/EPICS/epics-support/asyn$ git diff
> diff --git a/asyn/drvAsynSerial/drvAsynSerialPort.c b/asyn/drvAsynSerial/drvAsynSerialPort.c
> index 1ed6ab47..97078a5d 100644
> --- a/asyn/drvAsynSerial/drvAsynSerialPort.c
> +++ b/asyn/drvAsynSerial/drvAsynSerialPort.c
> @@ -529,6 +529,7 @@ setOption(void *drvPvt, asynUser *pasynUser, const char *key, const char *val)
>     else if (epicsStrCaseCmp(key, "rs485_rts_after_send") == 0) {
>         if (epicsStrCaseCmp(val, "Y") == 0) {
>            tty->rs485.flags |= SER_RS485_RTS_AFTER_SEND;
> +           tty->rs485.flags &= ~(SER_RS485_RTS_ON_SEND);
>         }
>         else if (epicsStrCaseCmp(val, "N") == 0) {
>            tty->rs485.flags &= ~(SER_RS485_RTS_AFTER_SEND);
>
>
>
> Heinz
>
> ------------------------------------------------------------------------------
> Fritz-Haber-Institut    | Phone:         (+49 30) 8413-4270
> Heinz Junkes             | Fax (G3+G4):   (+49 30) 8413-5900
> Faradayweg 4-6        | VC: https://zoom.fhi.berlin/junkes
> D - 14195 Berlin        | E-Mail:        [email protected]
> ------------------------------------------------------------------------------
> “Sorry I’m a bit late, had a terrible time…
> All sort of things cropping up at the last moment. Uh, how are we for time?”
> —Zarquon's address to Milliways
>

Attachment: smime.p7s
Description: S/MIME cryptographic signature


References:
Modbus asyn issue with RS485 connection (maybe hardware related) Heinz Junkes (FHI) via Tech-talk

Navigate by Date:
Prev: Modbus asyn issue with RS485 connection (maybe hardware related) Heinz Junkes (FHI) via Tech-talk
Next: Re: synchronizing the value of a read/write record Johnson, Andrew N. via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  <20252026 
Navigate by Thread:
Prev: Modbus asyn issue with RS485 connection (maybe hardware related) Heinz Junkes (FHI) via Tech-talk
Next: Announcing linStat 1.0.0 Michael Davidsaver via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  <20252026 
ANJ, 19 Mar 2026 · Home · News · About · Talk · Base · Modules · Extensions ·
· Distributions · Download · Documents · Links · Licensing ·