• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Polling issue with high register number with Arduino via Modbus

    User help
    5
    27
    19.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      copytco
      last edited by

      Hi,

      I have connected Arduino to Mango via Modbus RTU protocol. When I had circa 6 - 10 registers set in Mango, it was all working pretty well - not ideally: I even made an empty loop and made Arduino running, while I occasionally got "aborted polls" error. When my number of registers increased to 49 I started to receive errors similar to following:

      'Modbus': com.serotonin.modbus4j.exception.ModbusTransportException: com.serotonin.messaging.TimeoutException: request=SerialMessage [modbusMessage=ReadHoldingRegistersRequest [slaveId=1, getFunctionCode()=3, toString()=ReadNumericRequest [startOffset=10, numberOfRegisters=10]]]

      With that, Arduino TX and RX diodes turn off and no communication is on the line for usually about 2 minutes and then it works for, like, 30 seconds.

      I have tried different update period, quantizing, max read/write register count but nothing is helping so far. I benchmarked it against other SCADA systems and there it works fine, but I would like to keep using Mango for many reasons. Any possible solutions? :)

      1 Reply Last reply Reply Quote 0
      • JoelHaggarJ
        JoelHaggar
        last edited by

        You probably need to adjust the Max Read Register values and or some of the other Modbus settings but I understand you have tried that. Did you try setting it to a low number?

        1 Reply Last reply Reply Quote 0
        • C
          copytco
          last edited by

          JoelHaggar, yes, I have tried that. My current settings are with 10 max read/write registers.

          The "funny thing" is that I am also having aborted polls when only 6 - 10 registers are involved in total.

          Nevertheless, my current settings for this data source with 49 registers is as shown below.

          mang_modbus.JPG

          1 Reply Last reply Reply Quote 0
          • S
            stensma
            last edited by stensma

            The update period of 1000 milliseconds could that collide when the timeout is twice as long ?

            The read bit count is that overall total ie the sum of all 10 registers ?

            1 Reply Last reply Reply Quote 0
            • JoelHaggarJ
              JoelHaggar
              last edited by

              I agree, you should not have the timeout X retries longer than your update rate. I would slow down your update rate to 5 or 10 seconds to see if things improve. You can also use the test tools to do one time reads and see if you get anything.

              1 Reply Last reply Reply Quote 0
              • hussamH
                hussam
                last edited by

                update rate must be >timeout*(retries+1),and max read bit count=16*register. just fyi

                1 Reply Last reply Reply Quote 0
                • C
                  copytco
                  last edited by

                  stensma, JoelHaggar, hussam, thanks for your answers, this helped a lot!

                  I changed update period to 1200 ms, timeout to 500 ms with 1 retry, max read bit count to 160 and max read/write register count to 10. No aborted polls and timeouts so far after 0,5 h run, nevertheless, I will test it further.

                  What is still present is error I see in log and command window, the content is as below:

                  (com.serotonin.io.serial.JsscSerialPortInputStream.serialEvent:134) - java.lang.NullPointerException

                  I get it every 5 - 8 ms, then there is ~50 ms break, and it starts again. I suppose the error occurs every time something is calculated/updated but I cannot get what might be wrong here.

                  1 Reply Last reply Reply Quote 0
                  • C
                    copytco
                    last edited by

                    I tested this settings further (and even some others) and the problem is still present. Just after launch of both Arduino and Mango it goes good for circa 40 minutes, then there is a series of 10 to 20 timeouts lasting from 1 to 3 minutes and then can be a 5 minutes break for normal working or even smaller. Sometimes errors start to appear even 5 minutes after launch.

                    I even tried 1000 ms retry and 3000 ms update period but no success, the rate of occurring errors is similar. Any hints what to do now?

                    1 Reply Last reply Reply Quote 0
                    • phildunlapP
                      phildunlap
                      last edited by

                      Can you print more of the stack trace for that NullPointerException?

                      1 Reply Last reply Reply Quote 0
                      • C
                        copytco
                        last edited by

                        phildunlap, thanks for your post.

                        Below, you can find my current settings (I believe they have an impact on error appearing rate). The whole log with started "Modbus" data source is here: http://pasted.co/7265b7d4

                        modbus_settings.JPG

                        1 Reply Last reply Reply Quote 0
                        • phildunlapP
                          phildunlap
                          last edited by phildunlap

                          Hi copytco,

                          I took a look at where those NullPointerExceptions are coming from. I'm not sure it will solve your problem, but it could help sort the issue out a little. I modified this JsscSerialPortInputStream to 1) check for a null buffer and return (where I believe that mess of Exceptions are coming from) and 2) output a better error message from errors during the read. Have you seen if there's anything interesting in your Modbus log?

                          You may also want to move your Mango/classes/debug-log4j.xml to Mango/classes/log4j.xml and rename the existing log4j configuration. This way you'll get debug messages for serial port receive events and whatnot.

                          If you place the attached .class file into your Mango/overrides/classes/com/infiniteautomation/mango/io/serial/ directory and restart Mango, it should use this modified class instead.

                          JsscSerialPortInputStream.class

                          Having this file could conflict with future upgrades, so consider removing it after testing. In general, we do not support overridden class situations. You may have to rename the file to "JsscSerialPortInputStream.class"

                          1 Reply Last reply Reply Quote 0
                          • C
                            copytco
                            last edited by

                            Thank you, phildunlap.

                            I did what you have written - moved debug-log4j.xml in place of log4j.xml, created overrides folder and subfolders, and placed the file provided by you in there. Here is the log I received: http://pasted.co/d6b935a0

                            I do not know much about how Modbus works "inside", but I here is the log I received for this session: http://pasted.co/10adedb5

                            1 Reply Last reply Reply Quote 0
                            • phildunlapP
                              phildunlap
                              last edited by phildunlap

                              How interesting! It looks like there is a duplicate class in sero-utils and my override isn't being loaded. sero-utils pulled our Jssc code! This is quite bizarre... nothing in Mango references com.serotonin.io.serial.JsscSerialPortInputStream!

                              Edit The below probably won't work, the package in the java is wrong! Sorry!


                              Well, that's probably your issue. Try placing a copy of that .class file I gave you in Mango/overrides/classes/com/serotonin/io/serial/ as well. I will investigate why it's using the Jssc from sero utils...

                              1 Reply Last reply Reply Quote 0
                              • C
                                copytco
                                last edited by

                                Hi, I tried placing the file into serotonin folder and when tried to enable my data source, got an error as shown below.

                                modbus_error.JPG

                                What could I do about it now?

                                1 Reply Last reply Reply Quote 0
                                • C
                                  copytco
                                  last edited by

                                  So is there any way of solving that problem? I see than I encounter the same error message even on fresh install of Mango when creating Modbus data source and defining at least one data point.

                                  1 Reply Last reply Reply Quote 0
                                  • phildunlapP
                                    phildunlap
                                    last edited by

                                    Hi copytco! Sorry for the delay.

                                    Let's try this again....
                                    JsscSerialPortInputStream.class

                                    This time it's the one for the Mango/overrides/classes/com/serotonin/io/serial/ directory. I am hoping the stack trace will shed more light on what could be null in that method. I'm thinking the origin is the native library for the jssc. If so, another thing to try would be to attempt communication from a different computer to the arduino. I hope being able to read the stack trace sheds some light, though.

                                    1 Reply Last reply Reply Quote 0
                                    • C
                                      copytco
                                      last edited by

                                      Thanks, phildunlap, I used your file and this is the log I received: http://pasted.co/6ac92888

                                      1 Reply Last reply Reply Quote 0
                                      • phildunlapP
                                        phildunlap
                                        last edited by

                                        Hi copytco, glad that class worked! I was able to get a little more information. Can you try this attached .class in that same location ( com/serotonin/io/serial ) and let me know if it's still occurring?

                                        JsscSerialPortInputStream.class

                                        1 Reply Last reply Reply Quote 0
                                        • C
                                          copytco
                                          last edited by

                                          Thanks, I see that there is no longer error message, but some other appeared. Details are here: http://pasted.co/ae06e69d To know if it resolves the aborted polls issue, I would need to let it run for couple of hours.

                                          1 Reply Last reply Reply Quote 0
                                          • phildunlapP
                                            phildunlap
                                            last edited by

                                            Great! I do not know what you are referring to, "but some other appeared." The only errors I see relate to your meta points having some disabled points in the context. Remember, we turned on debug logging! Please let me know if that fixes the issue for you, and I can discuss the modification I made with the other developers for integration.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post