12-24-2018 10:15 PM
We have Labview 2014 project that control big stand with many different equipment. Some of them read by serial ports, some by modbus protocol. Each type of equipment read by its own timed loop structure. Our problem that sometimes, let's say once per day, one of the cycles reading modbus devices freezes. And we have no idea why it happens. We have error clasters, but they show no error. Just cycle is freezing, the iteration is not increasing. Any ideas where is problem or what should we do to catch it?
Configuration:
NI PXIe-8135 Embedded Controller
Microsoft Windows 7 Professional (Service Pack 1)
Total Physical Memory 3.48 Gb
Here is screenshot with one of cycles for information.
Thank you in advance.
12-24-2018 10:27 PM
For an application running on Windows, I wouldn't use a timed loop. Just use a regular loop with timing functions in it.
Since all of those modbus functions are using the same serial port, I would serialize them with the reference wire and the error wire rather than running in parallel. I don't know if those Modbus functions are re-entrant or not. If they are not, you should be okay as they will block each other until each one completes. if they are, then you could have issues as there messages will conflict on the serial port.
Don't use array to cluster, then unbundle. Just index the array. And since you are getting an array of U16's, you can probably typecast that to an array of SGL's to get the same result with fewer functions. You'll have to experiment as word order may come into play.
Your iteration function isn't wired to any indicator, so I don't know how you know it is freezing. Are you sure it is freezing? What if you do a boolean indicator that toggles state every iteration?
I don't see why things would freeze, but first I would get rid of the timed loop and use a regular while loop.
12-25-2018 01:07 AM
@RavensFan wrote:
Since all of those modbus functions are using the same serial port, I would serialize them with the reference wire and the error wire rather than running in parallel.
In addition, you have 6 identical code "trains" that differ by a single Unit ID. You could use a single instance of the code and autoindex in an array of Unit IDs.
(6x less code is significant. To make Ravens suggested modification, you currently need to make identical changes in 6 different places, taking you 6x longer and there are 6x more places for bugs to hide. If you are paid by the hour, better code is like increasing your wage by a factor of six, and instead of a $5 burger, you could afford a $30 steak instead. :D)
12-25-2018 05:23 AM
Thank you for answers.
First of all sorry for some misinformation. This screenshot from previous version of our program, before I noticed problem with freezings. After it I started to control iterations of loops, and if they don't change their values for some time other program restart this one. I know this is not best way, but only one I could find for now.
I will follow your advices, and at first I will replace timed loop structures with while loops.
12-25-2018 11:58 AM
@Ferghus wrote:
I know this is not best way, but only one I could find for now.
All you need is connect a numeric indicator to the iteration terminal as has been suggested. If measured values don't change, you can never be sure if they are just constant of if the loop has stalled. (Your indicator at the "iteration duration" does not help because it displays a constant value during normal operation and it would only update at the next iteration again, which does not happen if the loop stalls forever)
12-26-2018 12:57 PM - edited 12-26-2018 01:02 PM
@Ferghus wrote:
Thank you for answers.
First of all sorry for some misinformation. This screenshot from previous version of our program, before I noticed problem with freezings. After it I started to control iterations of loops, and if they don't change their values for some time other program restart this one. I know this is not best way, but only one I could find for now.
I will follow your advices, and at first I will replace timed loop structures with while loops.
A few things wrong with that. First, the i terminal has a maximum value, 2^31-1, the loop will continue to iterate but the value will stop incrementing. use your own U64 counter on a Shift register. Next, if you insist on using a timed loop, Name it! get rid of the Stop Local and the conditional terminal, then and stop the loop by name. Trust me, that is probably a latching boolean and you are going to get race conditions with that local. Bonus, your main control loop can execute an ordered shutdown by shutting down the loops in order.
And yes, since there is only 1 modbus master and only 1 physical BUS you need to serialize the querys (that for loop is looking better and better)
@CA If you are paid by the hour, better code is like increasing your wage by a factor of six, and instead of a $5 burger, you could afford a $30 steak instead. )
Not really, he gets the the code done in 1/6th the time with 1/6th of the bugs for the same wage earning him 13 cents for the same outcome. But, the stick of chewing gum will last longer than the Steak:)