LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Code Slows Down Over Time

While using LabVIEW to code an optical sensor that is used to see when a coin passes through a passage, the code will initally run at a fast enough rate to read a coin falling through it. Yet as time goes on the while loop the sensor is within slows down to a point where it is not quick enough to see/detect a coin falling through. There are two while loops running in parallel, that may still be causing some issues in priority?

Thanks in advance,

Ben

0 Kudos
Message 1 of 7
(3,709 Views)

Can you either post your VI or provide the settings you are using for the DAQ Assistant?

It looks like you're throttling your loop with the DAQ Assistant and it's hard to evaluate if the other loop could be interfering since you don't provide it.

0 Kudos
Message 2 of 7
(3,658 Views)

Is this all you would need? It has more coding within it in order to turn on the conveyor belt that returns the coins to the hopper, which in turn will spit out the coin through the optical sensor's passage.

0 Kudos
Message 3 of 7
(3,650 Views)

Some comments on your code

1. You should use shift registers to hold values from one iteration to the next.  You should avoid using the local variables.

2. Your loop stops after 1000 iterations.  Perhaps you should use a Stop button instead.

3. I tend to question the DAQ Assistant when it comes to memory issues (which is normally the cause of a loop slowing down).  You might want to look into using the actual DAQmx API instead.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 7
(3,645 Views)

Along with what 

 

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 5 of 7
(3,621 Views)

Sorry, I'm fairly new to LabVIEW, DAQ assistant seemed like an easier option for the DAQ to LabVIEW interation. How would you write the code for the DAQmx as I seem to be getting errors when ever I inset a timer to set a sampling rate.

I made the changes crossrulz stated, by switching to a shift register along with including a stop button, just the DAQmx writing is left.

Thanks again.

0 Kudos
Message 6 of 7
(3,605 Views)

You can set the timing up in the Express VI. Change acquisition mode to Continuous Samples. You'll then need to adapt the code to analyze an array of booleans instead of a single value like you have now.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 7 of 7
(3,519 Views)