03-31-2016 05:20 AM
Hey everyone!
I am trying to control a motor using Labview and a myRio, and everything works fine most of the time. My main control loop uses a timed loop to run at 300ms, and logging the Iteration Duration shows that the loop almost always finished within ~100ms. However, at seemingly random points in time the iteration duration jumps to around 1200ms for a few periods, then returns to the normal value. This happens very rarely, sometimes after just a few hundred iterations, sometimes after over 100'000 iterations.
I have tried to disable everything in my program except the main control loop, with no change. The VI and all sub-VIs are set to highest priority, with debugging and error handling disabled. I have compiled the project and run it as the startup application, with the same outcome. I don't know if there are some background processes running that slow it down, or some settings I overlooked. If anyone has any idea what might cause issues like this I would be very grateful, I am rather stuck by now.. 😕
Thanks and cheers,
Christoph
03-31-2016 05:55 AM
What all do you have in that loop? At the top of my head, things that could slow it down are File IO and network communications. If you could supply some code, that would help us.
03-31-2016 06:20 AM - edited 03-31-2016 06:21 AM
The VI itself looks a bit tricky right now, I'll try and make a presentable version.
Basically I read an encoder, calculate the velocity and use some custom control VI to control a voltage. For data logging I also write 5 data points into 5 FIFOs in a for-loop, maybe that might cause problems?
There are no file IOs. I normally use a parallel loop to transmit data to a host computer via TCP, but disabling this part did not seem to remove the problem.
03-31-2016 07:10 AM
durr wrote: For data logging I also write 5 data points into 5 FIFOs in a for-loop, maybe that might cause problems?
If your FIFOs are getting full, that could be your issue, especially if you have it set to wait for a spot to be available before writing. There are some tricks that could be played with these, but would help to have some real code to mess around with.
Instead of using 5 FIFOs, why not use an array in the FIFO? Then you just have 1 FIFO to read.
03-31-2016 07:52 AM - edited 03-31-2016 07:58 AM
The 5 FIFOs are a leftover from previous versions of the code, when I tried to see if it would improve performance (it didn't really change anything if I remember correctly). They are set to overwrite and work properly. But it seems I have found the culprit - stupidly measuring the tick count of various parts of my code worked rather well.. ^^
I am using a Global Stop functional global that is read and written in various places of my code to stop my loops if the stop button is hit or an error occurs. It seems to me that someone blocks this VI for ~1ms sometimes, in which case this part of the main loop stalls. Now I just have to find out why it happens.. the Global Stop VI is set as subroutine and should thus execute very fast usually, no?
edit:/ I attached the global stop VI 🙂