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  <2025 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  <2025
<== Date ==> <== Thread ==>

Subject: Re: Modbus problem bit swap Wago PLC
From: "Brown, Garth via Tech-talk" <tech-talk at aps.anl.gov>
To: Jeffrey Gamsby <jfgamsby at lbl.gov>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>, Mark Rivers <rivers at cars.uchicago.edu>
Date: Thu, 15 May 2025 20:05:06 +0000
Hi Jeffery,
Do you use the same modbusFunction with both types in your drvModbusAsynConfigure command? A few years ago I was working with a Pilz PLC, and it surprised me to find that the bit order, but not the byte order, changed depending on which modbusFunction I specified.

-Garth Brown
SLAC National Accelerator Laboratory

From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Mark Rivers via Tech-talk <tech-talk at aps.anl.gov>
Sent: Friday, May 2, 2025 12:28 PM
To: Jeffrey Gamsby <jfgamsby at lbl.gov>; tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: RE: Modbus problem bit swap Wago PLC
 

Hi Jeffrey,

 

What do you mean by “bit-swap”?  Do you mean the values 0 and 1 are swapped, or that the order of the bits is swapped?

 

Mark

 

 

From: Tech-talk <tech-talk-bounces at aps.anl.gov> On Behalf Of Jeffrey Gamsby via Tech-talk
Sent: Friday, May 2, 2025 5:29 AM
To: tech-talk at aps.anl.gov
Subject: Modbus problem bit swap Wago PLC

 

Hi All,

 

 I am using a Wago PLC and Epics asyn-R4-43/Modbus R3-2, and I am seeing some differences in the FC2 reads depending on the Wago module that is used.   

 

If the 750-400/500 series module DO/DI are used, the reads come back as expected, but if the 750-1400/1500 series are used there is a bit swap when reading.

 

Here is my current Asyn port configuration, I have tried the different data types as enums and strings but that doesn't change anything.

 

I can make it work, just trying to understand why I get the bit swap when using different modules on the PLC. 

 

Here is my config:

 

cmd file:

# Bit read access, Function code 2
drvModbusAsynConfigure("FC2", "sim1", 0, 2,  0, 32, 0, 100, "Wago")

 

and the db record

# bi record template for register inputs
record(bi,"$(P)$(R)") {
    field(DTYP,"asynUInt32Digital")
    field(INP,"@asynMask($(PORT) $(OFFSET) 0x1)")
    field(SCAN,"$(SCAN)")
    field(ZNAM,"$(ZNAM)")
    field(ONAM,"$(ONAM)")
    field(ZSV,"$(ZSV)")
    field(OSV,"$(OSV)")
}

 

 

and my substitutions file:

 

# READ COILS - FUNCTION CODE 2
# Reads WAGO MB Output Bits
file "$(MODBUS)/db/bi_bit.jeff.template" { pattern
{P,        R,        PORT,    OFFSET,      ZNAM,   ONAM,  ZSV,       OSV,    SCAN}
{SIM1:,    FC2_0,     FC2,     0,        Low,    High,  NO_ALARM,  MAJOR,  "1 second"}
{SIM1:,    FC2_1,     FC2,     1,        Low,    High,  NO_ALARM,  MAJOR,  "1 second"}
{SIM1:,    FC2_2,     FC2,     2,        Low,    High,  NO_ALARM,  MAJOR,  "1 second"}
{SIM1:,    FC2_3,     FC2,     3,        Low,    High,  NO_ALARM,  MAJOR,  "1 second"}
{SIM1:,    FC2_4,     FC2,     4,        Low,    High,  NO_ALARM,  MAJOR,  "1 second"}
{SIM1:,    FC2_5,     FC2,     5,        Low,    High,  NO_ALARM,  MAJOR,  "1 second"}
{SIM1:,    FC2_6,     FC2,     6,        Low,    High,  NO_ALARM,  MAJOR,  "1 second"}
{SIM1:,    FC2_7,     FC2,     7,        Low,    High,  NO_ALARM,  MAJOR,  "1 second"}
{SIM1:,    FC2_8,     FC2,     8,        Low,    High,  NO_ALARM,  MAJOR,  "1 second"}
{SIM1:,    FC2_9      FC2,     9,        Low,    High,  NO_ALARM,  MAJOR,  "1 second"}
{SIM1:,    FC2_10,     FC2,     10,        Low,    High,  NO_ALARM,  MAJOR,  "1 second"}
{SIM1:,    FC2_11,     FC2,     11,        Low,    High,  NO_ALARM,  MAJOR,  "1 second"}
{SIM1:,    FC2_12,     FC2,     12,        Low,    High,  NO_ALARM,  MAJOR,  "1 second"}
{SIM1:,    FC2_13,     FC2,     13,        Low,    High,  NO_ALARM,  MAJOR,  "1 second"}
{SIM1:,    FC2_14,     FC2,     14,        Low,    High,  NO_ALARM,  MAJOR,  "1 second"}
{SIM1:,    FC2_15,     FC2,     15,        Low,    High,  NO_ALARM,  MAJOR,  "1 second"}
}


References:
Modbus problem bit swap Wago PLC Jeffrey Gamsby via Tech-talk
RE: Modbus problem bit swap Wago PLC Mark Rivers via Tech-talk

Navigate by Date:
Prev: Re: A $ in a PV name? Johnson, Andrew N. via Tech-talk
Next: Re: camonitor the PACT field 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  <2025
Navigate by Thread:
Prev: RE: Modbus problem bit swap Wago PLC Mark Rivers via Tech-talk
Next: aps epics site not accessible from Europe at the moment? Heinz Junkes (FHI) 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  <2025
ANJ, 15 May 2025 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions ·
· Download · Search · IRMIS · Talk · Documents · Links · Licensing ·