LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extremely slow FieldPoint read

I have a number of working programs (programmed by my predecessor) which measure thermocouple temperatures, using sub-vi to open a refnum to an FP device, take a measurement, and then close the refnum again (vi attached).

I can't pin down exactly when, but occasionally the refnums returned by the OpenFP vi are different with each sub-vi execution, and when that happens the FP Read sub-vi seems to slow to a crawl. The majority of the time the same refnum is returned and it all runs very quickly. 

Does anyone have any idea why this would suddenly be returning a different refnum with each iteration?

 

 

0 Kudos
Message 1 of 5
(2,653 Views)

How are you running this?  You said it is a subVI.  How frequently are calling this subVI?

 

If you are trying to do something on a frequent basis, which seems likely since you say things are running noticeably slow, you shouldn't be opening and closing references every time you read the fieldpoint channels.  You should open once, read as often as you need to, then close at the end of the program.  If you use an Action Engine type of architecture, you would have 3 actions, Open, Read, and Close, and the uninitialized shift registers would store the refnums between calls of the subVI.

0 Kudos
Message 2 of 5
(2,647 Views)

Hi ravens fan, thanks for the reply and link; that's a great guide, and I'll be sure to make use of it. Having started labview with a bunch of existing programs and mostly only modifications to be done, I've had to hit the ground running and not had a chance to learn proper methods from the ground up. Quick guides like that really help.

 

The sub-vi is being called within a while loop as part of PID control, with temperature as the reference variable. It loops at ~2Hz, though when it's running smoothly it can happily update at >10 times that. When it slows down though, that drops to ~0.2Hz.

I am aware of the principle to only open/close a session once within a vi, but this vi was programmed by my predecessor, and has always worked, so I'm trying to adopt an 'if it ain't broke, don't fix it' policy (otherwise i'd be incurring a whole lot of work!). And the majority of the time it does work - it runs fine on a dev machine, but if i build it, it runs slowly. If i then close the built version and re-open the dev version, that also now runs slowly... But if i open the sub-vi being called and hit 'stop' on that while it's running, then everything goes back to normal. Smiley Indifferent Perhaps it's closing the FP Open refnum rather than just the bank refnum?

0 Kudos
Message 3 of 5
(2,640 Views)

And suddenly, the built version now runs quickly too. For now...

I do however have an error on closing the vi;

"Application Error; The instruction at "0x04062318" referenced memory at "0x00000008". The memory could not be "read". Click OK to terminate the program."

0 Kudos
Message 4 of 5
(2,634 Views)

Found more info on that error here, again something to do with the Call Library function being passed an invalid input. Since Call Librarys are only used in FP read and are passed the FP refnums, it all seems related, but that I'd get an error when everything runs fine and no error when it doesn't seems a bit backwards.

0 Kudos
Message 5 of 5
(2,629 Views)