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.
# Bit read access, Function code 2
drvModbusAsynConfigure("FC2", "sim1", 0, 2, 0, 32, 0, 100, "Wago")
# 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"}
}
|