LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

making a timeout event last longer?

Just had a quick question about how to make each iteration of a timeout execute a little longer without stalling out the rest of the program.  Basically I'm collecting and processing data through a DAQmx input (voltage signal), and my program is mainly centered around the timeout case of an event structure.  The event structure is inside a while loop, and data collection and analysis (graphing, etc.) occurs during the timeout event.  I need to have the timeout event execute as often as possible (i.e., no lag- I set the timer on the event structure to 0) to ensure that the delay between data collections is negligible (we're trying to calculate position data based on how fast we're going and how many datapoints we've taken).
 
So in short, I need to make a timeout event have no lag in between executions, but each timeout event needs to take 100 ms per execution.  It's taking 95 ms per execution.  What's the best way to add 5 ms to the event's execution time?
 
I'm willing to clarify whatever questions that need to be answered.  Thanks in advance.
0 Kudos
Message 1 of 12
(3,489 Views)
Hi balaclava,
you should use a parallel process for you data acquisition. See the shipped Producer/Consumer architecture.
 
Hope it helps.
Mike
0 Kudos
Message 2 of 12
(3,487 Views)

I'm sorry...I don't understand what you mean.  Could you clarify what architecture you're talking about, and how exactly the parallel process (which I thought was inherently being used anyway) that you're talking about would help me?

Thanks in advance.

0 Kudos
Message 3 of 12
(3,479 Views)

Hi balaclava,

i mean the Producer/Consume design pattern. You have to while loops there. One for your events with the event structure and one for your data acquisition. If you use a parallel process you can measure you signals while press a button, or other thinks.

Mike

0 Kudos
Message 4 of 12
(3,477 Views)
Would that ensure that the data collection/processing takes 100 ms every time it executes?  Sorry if this seems like a stupid question, but since we're calculating positional data based on time, speed, and number of datapoints it's essential that we get it up from 95 ms to 100.
 
Thanks again!
0 Kudos
Message 5 of 12
(3,462 Views)
Hi balaclava,
you don´t work with windows, do you? Smiley Wink
Mike
0 Kudos
Message 6 of 12
(3,456 Views)
The Producer-Consumer architecture.

It is impossible to guarantee timing on a non-Real-Time operating system. This gets asked all the time.
0 Kudos
Message 7 of 12
(3,454 Views)
Thanks for the link smercurio, now I get what you're talking about.  Sorry about the repetitive question.
 
Not really sure how exactly to implement that in the program I'm using though.  Basically I've been adding on to Aerotech's HMI VI in 8.5.1...unfortunately where I work we're cheap and only have the Base development system (8.5.1)- not sure if that matters in this case.  http://www.aerotech.com/soloist/software.cfm will get you to a brief description of the VI...it's on the right side of the page.  I don't have permission from the boss to post up the modded version of the VI (I'll ask later today if you want it), but I could post up the unmodified version if you all want me to (and if I won't violate TOS or any laws by doing so).  You won't be able to run it since it has a massive library of subVIs, but I'm pretty sure the block diagram will stay intact.
 
Oh yeah, we use Windows XP on our computers.
 
Sorry if it seems like I'm not listening to you guys- just out of curiosity how bad can the timing errors be on non-real time systems?  Did anyone ever get an error margin for it?
0 Kudos
Message 8 of 12
(3,442 Views)
I'm not sure on how you're able to use the event structure if you say that you have the Base edition since the Base edition doesn't include the event structure. That aside, the little picture and brief (quite applicable word in this case) description simply tell me that you have a pretty interface (sarcasm aside) Smiley Wink.

In any event, the producer-consumer architecture can be used in a variety of ways. One typical means is for the producer loop to handle your UI. The individual event cases shouldn't perform anything that takes a long time. Its intent is to place actions on a queue for the consumer loop to take care of, so that the producer can quickly return to respond to events. The consumer loop is where you do the work.

You can actually have more than one consumer loop. Thus, you can have a consumer loop that performs the UI operations, and the other consumer loop is doing your data collection. There is no error margin that one can give for the timing since it's dependent on way too many factors. You can do a few things in software:
  • You can have a minimum. For instance, you can get the tick count before you start the acquisition, and get it after you've got the data. If the difference is less than your 100 msec, then wait the difference. If it's more, don't wait.
  • You could use a timed loop based on a DAQ clock. Not sure if this is available in the Base edition. This isn't the same as a real-time loop, though, but it's as close as you're going to get.
  • Change the way you perform your data acquisition so that you get your samples at the timing you need. Basically do a buffered acquisition if your DAQ card has that capability. The DAQ card collects data at your desired rate, and the software pulls it from the buffer. As long as your buffer is large enough and you can keep up you should be able to do this.
0 Kudos
Message 9 of 12
(3,437 Views)
Yeah, as far as I can tell I can put stuff in the event structure at different cases, but I can't add or remove cases.  I guess I'll post up the unmodfied version right now- I'd like to see where I can implement the consumer loops- maybe make an entire other while loop and just put all the data acquisition and analysis stuff in there?  Let me know if I'm gonna have TOS issues by posting it up- though I suspect there shouldn't be any since you can't actually run it.
 
Basically that version lets you move a platform around...I'm only really using the Move tab on the front panel.  But like I said, right now I have all of the data acquisition/graphing/analysis in the Timeout case.
 
So if you don't mind, could you take a look at it and see if my idea is feasible?  Thanks in advance.
0 Kudos
Message 10 of 12
(3,430 Views)