08-02-2010 10:39 AM
Hello everyone!
I am attempting to communicate over I2C to a slave device using a USB-8451 and have noticed that after a while the communication speed slows way down.
I can send and receive data just fine and at first glance my system appears to be working. But the problem is that as time goes on the speed of data transfer slows so much so that if I leave it running overnight it has slowed to a crawl by morning. My ultimate goal is to gather data, plot and save every second, and at first this is easily achievable, but after 10 - 15 hours I can no longer collect the data as fast as I need. I'm not entirely sure if this is a problem with my LabVIEW code, the NI USB-8451, or the slave device. But if I stop running the LabVIEW program and start it again, everything returns to normal.
The slave device is a custom board with a PIC chip that acts as an I2C slave and returns data at the request of the master. I don't imagine anyone will be able to determine if this is problem directly, but if we can rule out the other two (LabVIEW code or the NI-8451) as the source of the problem then I'll know it's my slave device.
I have greatly simplified the LabVIEW code I was using to gather data over I2C and I am still seeing this progressive slowing over time. Attached is the much simplified VI and the data file it produced. I only ran it for about 45 minutes but from beginning to end you can still see that the execution time is starting to go up.
Hopefully I'm just doing something stupid, thanks in advance!
-Aaron
Solved! Go to Solution.
08-02-2010 12:41 PM
Aaron,
Don't have the extra module loaded for these functions but I'm pretty sure I know whats going on. It looks like each time through the loop "NI-845x I2C Create Configuration Reference.vi" creates a new reference. After a while it will start slowing things down. Better to open the reference before the while loop starts and pass just the reference into the loop. Don't forget to close the reference after the loop stops running.
08-02-2010 01:38 PM
Wayne,
That seems to have done the trick! Actually one of my first thoughts when I started having this problem was that I might not be closing a reference, but the VI profiler did not show any memory leaks and it won't let you close the I2C reference with the standard "Close Reference.vi" from the pallet. After reading your post, however, I looked into it a little bit deeper and I did discover a specialized Close Reference.vi for the NI USB-8451 that I never noticed before because the wire type was not the thin grey of the reference. Instead, it was blocky, like a file path wire, but I discovered you can still connect the configuration wire too it and it will close the reference.
Thanks for the help!!
08-03-2010 08:26 AM
Aaron,
Glad to hear you got it figured out. Kudo for letting us in on the final solution. Welcome to the NI forums.