LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best way to execute code at a specific time?

Hello,

 

I have a problem. I need to execute some code at a specific time: subVI A should run at e.g. 2 seconds (after start) and stop at 3.5 seconds and subVI B should execute at 3.5 seconds until 5 s. The user can choose the time points. It could also be that subVI B has to execute before subVI A or at the same time.
Time precission is not important +/- 20 ms is ok.

I have implemented it like that: In a loop (period time approx. 20ms) I query if the timeframe has come and then the subVI will be executed.

See attached picture.

I don't believe that this is an economic way. It will produce high CPU load. How can I do it better?

 

Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
0 Kudos
Message 1 of 17
(3,324 Views)
and how can you insert pictures, so that you see them inside the posting and not as an attachment? 🙂
Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
0 Kudos
Message 2 of 17
(3,323 Views)

Insert Picture.JPG

 

 

Like this. Smiley Happy  Use the "Upload or insert an image" option on the Toolbar of the Reply window.

Message Edited by parthabe on 10-13-2009 03:56 AM
- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 3 of 17
(3,305 Views)

Use "While Loop" with Case inside, and use Shift register to remember the last time that the Case was executed...

and if you need to run both vi's in parallel use two while loops.

 

0 Kudos
Message 4 of 17
(3,295 Views)

Aah, all right. Smiley Happy

You've uploaded a picture with a red cross?

Message Edited by johanneshoer on 10-13-2009 04:18 AM
Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
0 Kudos
Message 5 of 17
(3,290 Views)

@HaD

 

Something like this?

 

Johannes

LabVIEW 7.1 (!)

 

Timeframe_2.PNG

 

 

 

Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
0 Kudos
Message 6 of 17
(3,283 Views)

I don't think that this is an optimum solution.

 

I see a problem. The timer value will wrap from (2^32)-1 to 0, so there might be a problem during comparison.

Even though it is very seldom, I can not accept that.

 

How can I improve it?   

Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
0 Kudos
Message 7 of 17
(3,274 Views)

How is this?

 

Better?

 

Johannes 

LabVIEW 7.1

 

 

Timeframe_2b.PNG

Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
0 Kudos
Message 8 of 17
(3,248 Views)

Yeah, this is definitely a more correct approach. Smiley Happy

 

 

P.S.:- PFA the missed-out attachment.

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 9 of 17
(3,212 Views)

Thanks parthabe,

 

but doesn't this require considerable processor power? Imagine I needed the timing accureate to a millisecond...

Is there no way similar to event structures?

Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
0 Kudos
Message 10 of 17
(3,166 Views)