Search the Community
Showing results for tags 'udfb'.
Found 2 results
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
Hi there! I'm using UDFBs many times in my program, but today I need to create an UDFB that allow or not allow to continue the ladder depending on the result inside the block. Using clear terms : I want an UDFB working as a Compare Block. You chose some "In Tag", and then the block compare it (using the way you ask it to) and allow power flows or not. Can we currently make it? Of course, today, I can make an UDFB with a bit as an "Out Tag", and use this bit with a direct contact. Just asking Thank you.