LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Home Seek for Delicate Probe

Hello,

 

I have a LabVIEW v8.5 program (attached) for traversing an extremely delicate hot-wire anemometer probe towards an aluminium plate surface using a stepper motor which will exit its respective while loop based on either of the two following conditions being met; maximum voltage of current sample being greater than the target voltage (as proximity is reduced towards 0mm the voltage increases and reaches my targeted 'home' value) or the minimum voltage being less than 1V - this is just for safety because if the wire is switched off it will never reach its target voltage and, left unnoticed, would plunge to its demise into the plate.

 

All I have available to me is software timing (USB 6210 or 6009) so that's what I've used for the pulses along the step line.  Unfortunately though the program slows to a crawl after approximately 500 pulses and I was wondering if there were any suggestions as to how this could be avoided.  I can think of making the code more efficient by moving the (fixed) direction out of the loops or writing the 2nd phase of the for loop concurrently with the sampling but really what I want to get to the bottom of is why it's slowing down in its present form.

 

Any other suggestions would be appreciated, thanks.

---------------------------------------------------

LabVIEW 8.5 User.
0 Kudos
Message 1 of 3
(2,237 Views)

Just glancing at the program, you have some serious arcitectural problems:

 

With every iteration of the while loop, you are configuring a new task, allocations a 1M buffer, read 100 samples, and stop the task, but never clear it. Similarly with the two digital tasks for every iteration of the inner FOR loop you are killing and recreating tasks. What is the point? That does not make sense. No wonder the code slows down after a while. You are creating a serious memory leak! Look at the memory use with the task manager. It increases linearly with time and you will run out eventually.

 

Solution: Typically you would create and configure each task once outside the loop and keep it active during the loop and clear it once the while loop stops.

 

Your also have a lot of duplicate and unecessary code. For example, the inner case structure the cases have identical code except for a boolean array diagram constant. Only the parts that differ belong inside a case structure! In this case you could do a "equal zero", build the result into an array, and feed it to the  DO if line 0 (no case needed! If you would use mode "digital bool 1 line 1 point", you would not even need to build an array).

 

Your writing off line 1 makes no sense. Since all you write is a FALSE, it makes no difference. Write it once at the start of the program and forget about it for the duration of the code. (If you would actually need line 1, you could create a single task for both lines and cut the code complexity by 50%).

 

Try to implement these changes and see if things improve. 🙂

Message 2 of 3
(2,223 Views)

I was able to come to this conclusion about the memory leaks on my own but was unable to access the boards due to maintenance.  Thanks for your help with the clumpsy aspects of my coding, I'm self-taught in LabVIEW but your advice has certainly helped make things clearer!  Thanks for that!

---------------------------------------------------

LabVIEW 8.5 User.
0 Kudos
Message 3 of 3
(2,215 Views)