Jump to content

mdituro

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by mdituro

  1. Hello Ofir,

    The addition of Timout and Retries in the default MODBUS operations will be a large help.

    I Often need the ability to Auto-Detect Slaves in a network - which is why I need the ability to change slave ID's.  The Addresses could be from 1-255, and I don't want to have to set up 255 different combinations of possible reads(Last I knew, you could only even set up 32 slaves as a time anyway).  I also need to often read multiple different register locations/lengths while switching between slaves - so i am really limited on this by the simple mode, and must use the Advanced Modbus functions.

    Thanks again for a great software and hardware.  I'm sure these abilities will be introduced again eventually.

    -Matt

    • Upvote 2
  2. Hey guys,

    I'm often needing to use advanced modbus features because ill need to have dynamically adddressed slave ID's, or changing registers etc, etc and i cant use the built in configuration to do so.  Also - the Advanced modbus still require a good bit of logic to be built in order to achieve a good Tx and Rx.

    I built this UDFB to be used as a single operation which accepts 4 Function In parameters, and one Function out.

    Example Ladder Note how the function is called, Param 'D' must be reset immediately after the function call:

    Ladder Image

    Input A is a struct with 4 members (Note that only one Arr at a time will be filled with the result data, based on your input to parameter 'B')

    resultBits[0-50]

    resultInts[0-50]

    resultUInts[0-50]

    resultRaw[0-99]

    The results of your query are stored here, depending on what value you use for input 'B'

    1 = result store in resultsBits

    2= result stored in resultInts

    3= result stored in resultUints

    4= result stored in raw buffer( for parsing floating point values etc, etc)

    Input 'C' is your input parameters for the MB request - Don't worry about the Modbus request, and request descriptor - these are handled inside the function 

    Input 'C' is a struct with the following members

    slaveId

    functionCode = Standard codes...holding register = 3, etc

    startReg = starting register in slave

    length = how many registers(Keep in mind length of buffers etc, you can always change this)

    Retries = how many times to retry read request

    Timeout = how long to wait for response(5000 = 5 seconds -- 3 retries at 5sec each would be 15 secs for a failed attempt)

    Input 'D' is the Enable bit for the function to run - make sure to reset this immediately after the function call.(See image above)

    Output 'A' is a number with the following values

    1 = read successful

    5 = timeout (timeout * retries)

    255 = ladder Error

    Let me know if i made a glaring mistake, or if you have any improvements!  I'm sure i didnt do this as effeciently as possible - but, it does work for my purposes.  I may add some more error checking and things later.  Let me know what you think!

    Thanks,

    Matt

    MBR.ulle

×
×
  • Create New...