LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sequence structure executing very slowly

Hello,

 

The block of code in the image below is from a much larger VI, but this is the section I am concerned with. I am not able to post the entire VI. In this section, I need to turn on 2 digital outputs, wait a specific amount of time, then turn them off. The problem is each frame of this sequence structure is taking MUCH longer than it should (around 20-30 ms). I put in the tick counts to measure the time. I created a separate VI where I re-created this small section of code and it ran fast as it should. Each section of the sequence structure took <1 ms. I attempted using "wait until next ms" blocks and setting the input to 0 to speed the process up, but that did not work. Any suggestions?

 

Thank you in advance

0 Kudos
Message 1 of 6
(1,236 Views)

There is no image.

A sequence frame executes in no time, so it only matters how long the code inside the frame completes. Please attach. Once we see the picture, we can comment more. On what information do you base the time duration it "should" take?

 

0 Kudos
Message 2 of 6
(1,231 Views)

First, you need to actually to attach the picture. Attaching the actual VI is much better but given you said you can't I guess we will have to work off the picture. However, since you are stating you are using sequence frames I suspect this is poorly written code to begin and it will need quite a bit of rework. It also sounds like you are using very few subVIs which is also not a desirable code architecture.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 3 of 6
(1,226 Views)

I updated the post to include the picture. I'm not sure why it didn't post the first time. I am basing my idea of how long it should take on previous experience. I don't believe it should take 30 ms to do something simple like turn on 2 digital outputs. As I mentioned in the post, I re-created a similar code outside this larger VI and it executed each step instantly (<1ms).

0 Kudos
Message 4 of 6
(1,219 Views)

OK, your truncated picture does not tell us much either (hidden, overlapping wires, duplicate tunnels, etc.)

 

Which of the frames are "slow"? (all?, DIO?, middle?, etc.). When you do the standalone test, do you use the same instrument IO?

 

image%20(7)

 

What kind of instrument is this and how is is connected and configured?

These 0ms waits make no sense at all. (If there are tight loops running in parallel, you could place some there to allow a task switching.)

Why not use a state machine instead of a sequence? You know you could use boolean array diagram constants (2 elements) for fewer cats to herd.

0 Kudos
Message 5 of 6
(1,212 Views)

The calls to the DAQmx take how ever long they take, that being said 20ms sound like a long time. Some suggestions:

 

Make sure highlight code execution is turned off 

 

Try using the High Resolution Relative Seconds VI for timing, it works great

 

Don't use the flat sequence, its not helping anything in this case, wiring the error line to VIs form left to right will cause things to execute in sequence. 

 

Try not to use waits, its almost always better to set up a queue and send a delayed message instead of waiting, and waits are the antithesis of fast executing code ( I used to work for a boss that said I owed him $500 for every wait he found in my code, it was good motivation)  It looks like there is a wait for 'Total open time' I would push that timing to hardware if you have it, Its probably not a RTOS so you may get some undesirable error there (not sure if that is 10000s or 0.000000001s, sounds mechanical so probably not that fast) 

 

If you are updating a tree on the front panel, that can take time depending on what you are  doing, depends on the code in the subVI. Move all your UI interaction to a UI loop that runs in parallel to your DAQmx tasks. 

 

If you must use a flat sequence dont pull wires from inside out the bottom or top, im sure it works but for data flow and readability it makes no sense, when do you expect that code to execute?

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 Kudos
Message 6 of 6
(1,166 Views)