From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Delay problem

Solved!
Go to solution

Hi there,

 

I made a Labview vibration analyser to use with 2 phidgets at the same time, everything works as intended, I was testing the program and it was working as intended, then after some time a delay emerged and that delay was increasing in time, the graphs started to show data that had happened 30 seconds to 1 min before. Since I already knew how to make the program my teacher suggested to me that I should make a new one and try to find what was wrong, which I did and everything was fine for some time without me finding the problem(it just worked well), I had zero delay, but then after an hour the delay showed up again, starting from a few seconds delay and increasing. I have no idea why this happens specially because I don't save the program and when I start it again the delay is there from the start, makes no sense to me. Any help would be awesome, I send the files required as an attachment.

 

João Pereira.

0 Kudos
Message 1 of 49
(5,927 Views)

The biggest problem I see is you have two arrays that are continually growing and nothing to limit their size.  The longer this program runs the larger the arrays will get.  They will eventually fill up the memory of your machine.  As these arrays get larger it takes longer to insert an element into them.  This is a big memory leak.  You need to do something to limit the size of the arrays.

 

Kelly Bersch
Certified LabVIEW Developer
Kudos are always welcome
Message 2 of 49
(5,875 Views)

Thx for ur reply, im not very good in labview but i will try figure out how to limit the size of the arrays.

0 Kudos
Message 3 of 49
(5,859 Views)

Hello Co0ki3,

 

Your code is fairly hard to read, but I see two major issues- The first, as has been noted, is that you have two arrays that are unbounded; this could cause issues with memory but I don't believe it would cause the sort of slowdown you're experiencing.

 

More problematic is that your phdiget VIs don't seem to be designed for parallel use, the "Event" VIs that you're using in parallel (SpatialEventExe) are configured to be non-reentrant and will block one another's execution. The calls you're making to the driver DLL are also configured to be single-threaded, although that may or may not be relevant. I don't know what happens in the driver when an event is missed, but this may be the source of your slowdown. It also appears that the event VI does not actually check the source of the data and assumes that there is only one device, and depending on how the DLL fires the events you might be getting bad data. You may be able to just configure SpatialEventExe.vi to be reentrant (preallocated clones), but I would also get in touch with whoever provided you with these VIs and confirm that the this driver and the LabVIEW interface can be used in this fashion.

 

You indicated that the values update slowly, but where in the program is the hangup?  Have you tried using debugging tools such as highlight execution to narrow down what part of the program is causing the slowdown?

 

Regards,

 

Tom L.
Message 4 of 49
(5,844 Views)

You are right about the phidgets arent meant to be used together i guess. That was one problem i had before that i managed to fix. I know that has nothing to do with the delay cuz i made a VI for just 1 as a test and it also had a delay 🙂 I am not at home at the moment will try to do more later. Thx for the help!

0 Kudos
Message 5 of 49
(5,830 Views)

Im sorry but im not very good at Labview, can u explain how i should limit the size of the arrays? I'm a newbie in labview sadly!

0 Kudos
Message 6 of 49
(5,801 Views)

I used Reshape array but no results!

0 Kudos
Message 7 of 49
(5,795 Views)

Well i tried some different things that i read and searched, none of them worked... God i suck !

0 Kudos
Message 8 of 49
(5,784 Views)

I used highlight execution and no problems found to my newbie eyes!

0 Kudos
Message 9 of 49
(5,754 Views)

Instead of using the Reshape Array function use the Array Subset function.  After you insert the new data into the array take a subset of the array starting at index 0 with a length of however many points you want to limit your array to.  Here's your VI.  The only changes I've made are to clean up the block diagram so it's readable and adding Array Subset functions that limit the arrays to 2000 points.

 

Vers¦oFinalv5.png

 

You should get rid of one of the timing functions you're using to control loop execution.  The Wait function is set to wait for 8ms while the Time Delay Express VI is set to wait 1ms.  They are running in parallel so whichever one has the longest wait will be the controlling one while the other one just uses resources.

 

Kelly Bersch
Certified LabVIEW Developer
Kudos are always welcome
Message 10 of 49
(5,719 Views)