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

Subject: modbus
From: wang Ewen via Tech-talk <tech-talk at aps.anl.gov>
To: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Thu, 25 May 2023 10:59:22 +0800

Hi ,

I got a question, I want to read the value of a instrument via MOXA Nport5650-16

serial device server,The EPICS server connect to the serial server through internet cable.

Now I cannot get the value,please help me to check the problem ,thank you very much!!!

Note:The Moxa team tell me the address of the firt port is 4001,the second is 4002…

Note:I can get the respond when I use a modbus tool to send the request:

[2023-05-25 10:52:43.927]# The server is connected from local 192.168.127.100:54649

 

[2023-05-25 10:53:05.731]# SEND HEX>

01 03 00 00 00 02 C4 0B

 

[2023-05-25 10:53:05.794]# RECV HEX>

01 03 04 02 60 00 F4 FA 12

 

[2023-05-25 10:53:06.515]# SEND HEX>

01 03 00 00 00 02 C4 0B

 

[2023-05-25 10:53:06.579]# RECV HEX>

01 03 04 02 60 00 F4 FA 12

 

Here is the parameter of the instrument :

Host inquiry frame structure:

Address code Function code Register start address Register length Check code low check code high

1 byte 1 byte 2 bytes 2 bytes 1 byte 1 byte

Slave response frame structure:

Address code Function code Effective number of bytes First data area Second data area Nth data area Check code

1 byte 1 byte 1 byte 2 bytes 2 bytes 2 bytes 2 bytes

4.3 Register address

Register address PLC or configuration address Content Operation

0000 H 40001 Humidity Read only

0001 H 40002 Temperature Read only

4.4 Communication Protocol Example and Explanation

Example: Read the temperature and humidity value of device address 0x01

Inquiry frame (hexadecimal):

Temperature and Humidity Transmitter Instruction Manual (Model 485) V2.1

 

Address code Function code Start address Data length Check code low check code high

0x01 0x03 0x00 0x00 0x00 0x02 0xC4 0x0B

Response frame (hexadecimal): (for example, the read temperature is -10.1°C and the humidity is 65.8%RH)

Address code Function code

return valid bytes

number

Humidity value Temperature value

Check code low

check code high

0x01 0x03 0x04 0x02 0x92 0xFF 0x9B 0x5A 0x3D

Temperature calculation:

When the temperature is lower than 0 ℃, the temperature data is uploaded in the form of complement code.

Temperature: FF9B H(Hex)= -101 => Temperature = -10.1℃

Humidity calculation:

Humidity: 292 H (Hex) = 658 => Humidity = 65.8RH

 

 

 

############################################################

# ai record template for temperature

record(longin, "$(P)$(R)_temp") {

    field(DTYP, "asynUInt32Digital")

    field(INP, "@asynMask($(PORT) 1 0xFFFF)")

    field(SCAN, "$(SCAN)")

}

 

# ai record template for humidity

record(longin, "$(P)$(R)_humidity") {

    field(DTYP, "asynUInt32Digital")

    field(INP, "@asynMask($(PORT) 0 0xFFFF)")

    field(SCAN, "$(SCAN)")

############################################################

root@wft:/usr/local/EPICS/ioc01/iocBoot/iocmoxa01# ./st.cmd

#!../../bin/linux-x86_64/moxa01

< envPaths

epicsEnvSet("IOC","iocmoxa01")

epicsEnvSet("TOP","/usr/local/EPICS/ioc01")

epicsEnvSet("ASYN","/usr/local/EPICS/support/asyn")

epicsEnvSet("MODBUS","/usr/local/EPICS/support/modbus")

epicsEnvSet("EPICS_BASE","/usr/local/EPICS/base")

cd "/usr/local/EPICS/ioc01"

## Register all support components

dbLoadDatabase "dbd/moxa01.dbd"

moxa01_registerRecordDeviceDriver pdbbase

drvAsynIPPortConfigure("Nport1","192.168.127.254:4001",0,0,0)

modbusInterposeConfig("Nport1" ,1,5000,0)

drvModbusAsynConfigure("port1","Nport1",1,3,040001,2,0,100,"Moxa")

## Load record instances

#dbLoadRecords("db/xxx.db","user=root")

dbLoadRecords("db/longin.template","P=M,R=V,PORT=Nport1,SCAN=1 second")

cd "/usr/local/EPICS/ioc01/iocBoot/iocmoxa01"

iocInit

Starting iocInit

############################################################################

## EPICS R7.0.6.1

## Rev. 2023-05-23T14:33+0800

############################################################################

MV_temp devAsynUInt32Digital::initCommon findInterface asynUInt32DigitalType

MV_humidity devAsynUInt32Digital::initCommon findInterface asynUInt32DigitalType

iocRun: All initialization complete

## Start any sequence programs

#seq sncxxx,"user=root"

epics> dbl

MV_temp

MV_humidity

epics> dbpr MV_temp 2

ACKS: NO_ALARM      ACKT: YES           ADEL: 0             AFTC: 0

AMSG:               ASG :               BKPT: 00            DESC:

DISA: 0             DISP: 0             DISS: NO_ALARM      DISV: 1

DTYP: asynUInt32Digital                 EGU :               EVNT:

FLNK: CONSTANT      HHSV: NO_ALARM      HIGH: 0             HIHI: 0

HOPR: 0             HSV : NO_ALARM      HYST: 0

INP : INST_IO @asynMask(Nport1 1 0xFFFF)                    LCNT: 41

LLSV: NO_ALARM      LOLO: 0             LOPR: 0             LOW : 0

LSV : NO_ALARM      MDEL: 0             NAME: MV_temp       NAMSG:

NSEV: INVALID       NSTA: LINK          PACT: 1             PHAS: 0

PINI: NO            PRIO: LOW           PUTF: 0             RPRO: 0

SCAN: 1 second      SDIS: CONSTANT      SDLY: -1            SEVR: INVALID

SIML: CONSTANT      SIMM: NO            SIMS: NO_ALARM      SIOL: CONSTANT

SSCN: <nil>         STAT: UDF           SVAL: 0             TIME: <undefined>

TPRO: 0             TSE : 0             TSEL: CONSTANT      UDF : 1

UDFS: INVALID       VAL : 0

epics> dbpr MV_humidity 2

ACKS: NO_ALARM      ACKT: YES           ADEL: 0             AFTC: 0

AMSG:               ASG :               BKPT: 00            DESC:

DISA: 0             DISP: 0             DISS: NO_ALARM      DISV: 1

DTYP: asynUInt32Digital                 EGU :               EVNT:

FLNK: CONSTANT      HHSV: NO_ALARM      HIGH: 0             HIHI: 0

HOPR: 0             HSV : NO_ALARM      HYST: 0

INP : INST_IO @asynMask(Nport1 0 0xFFFF)                    LCNT: 66

LLSV: NO_ALARM      LOLO: 0             LOPR: 0             LOW : 0

LSV : NO_ALARM      MDEL: 0             NAME: MV_humidity   NAMSG:

NSEV: INVALID       NSTA: LINK          PACT: 1             PHAS: 0

PINI: NO            PRIO: LOW           PUTF: 0             RPRO: 0

SCAN: 1 second      SDIS: CONSTANT      SDLY: -1            SEVR: INVALID

SIML: CONSTANT      SIMM: NO            SIMS: NO_ALARM      SIOL: CONSTANT

SSCN: <nil>         STAT: UDF           SVAL: 0             TIME: <undefined>

TPRO: 0             TSE : 0             TSEL: CONSTANT      UDF : 1

UDFS: INVALID       VAL : 0

epics> asynReport 1

Nport1 multiDevice:No canBlock:Yes autoConnect:Yes

    enabled:Yes connected:Yes numberConnects 1

    nDevices 0 nQueued 0 blocked:No

    asynManagerLock:No synchronousLock:Yes

    exceptionActive:No exceptionUsers 1 exceptionNotifys 0

    traceMask:0x1 traceIOMask:0x0 traceInfoMask:0x1

    Port 192.168.127.254:4001: Connected

port1 multiDevice:Yes canBlock:Yes autoConnect:Yes

    enabled:Yes connected:Yes numberConnects 1

    nDevices 1 nQueued 0 blocked:No

    asynManagerLock:No synchronousLock:No

    exceptionActive:No exceptionUsers 0 exceptionNotifys 0

    traceMask:0x1 traceIOMask:0x0 traceInfoMask:0x1

    addr 0 autoConnect Yes enabled Yes connected No exceptionActive No

        exceptionActive No exceptionUsers 0 exceptionNotifys 0

        blocked No

        traceMask:0x1 traceIOMask:0x0 traceInfoMask:0x1

modbus port: port1

    initialized:        true

    asynOctet server:   Nport1

    modbusSlave:        1

    modbusFunction:     3

    modbusStartAddress: 040001

    modbusLength:       02

    absoluteAddressing: false

    dataType:           0 (INT16)

    plcType:            Moxa

    I/O errors:         0

    Read OK:            569

    Write OK:           0

    pollDelay:          0.100000

    Time for last I/O   75 msec

    Max. I/O time:      80 msec

    Time per hist. bin: 1 msec

Port: port1

  Timestamp: <undefined>

  Input EOS[0]:

  Output EOS[0]:

Parameter list 0

Number of parameters is: 12

Parameter 0 type=asynInt32, name=MODBUS_DATA, value is undefined

Parameter 1 type=asynInt32, name=MODBUS_READ, value is undefined

Parameter 2 type=asynUInt32Digital, name=ENABLE_HISTOGRAM, value is undefined

Parameter 3 type=asynInt32, name=READ_HISTOGRAM, value is undefined

Parameter 4 type=asynInt32, name=HISTOGRAM_BIN_TIME, value is undefined

Parameter 5 type=asynInt32Array, name=HISTOGRAM_TIME_AXIS, value is undefined

Parameter 6 type=asynFloat64, name=POLL_DELAY, value is undefined

Parameter 7 type=asynInt32, name=READ_OK, value=569, status=0

Parameter 8 type=asynInt32, name=WRITE_OK, value=0, status=0

Parameter 9 type=asynInt32, name=IO_ERRORS, value=0, status=0

Parameter 10 type=asynInt32, name=LAST_IO_TIME, value=75, status=0

Parameter 11 type=asynInt32, name=MAX_IO_TIME, value=80, status=0

epics>

 

Windows 邮件发送

 


Replies:
Re: modbus Mark Rivers via Tech-talk

Navigate by Date:
Prev: RE: warning: multiple interrupt callbacks between processing when running testAsynPortDriverApp Mark Rivers via Tech-talk
Next: Re: modbus Mark Rivers 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  <20232024 
Navigate by Thread:
Prev: Re:Re: Re:Re: Re:Re: Re:Re: Re:Re: some motor driver 3 questions lynn via Tech-talk
Next: Re: modbus Mark Rivers 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  <20232024 
ANJ, 08 Jun 2023 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·