From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

delay after each image saving

Solved!
Go to solution

Hello,

 

Can anyone please help me regarding an issue I am facing. Basically, I have managed to save five image in a directory, what I now want to do is save each image after a specific delay without interrupting the whole program. I tried to do this with the elapsed time vi (under timing) but didn't get it to work. I know it is possible using this vi. I think I what I am doing is not the right way. Attached is a screenshot and the vi I am haaving problems.

Download All
0 Kudos
Message 1 of 8
(3,268 Views)

@naserkhan wrote:

Hello,

 

Can anyone please help me regarding an issue I am facing. Basically, I have managed to save five image in a directory, what I now want to do is save each image after a specific delay without interrupting the whole program. I tried to do this with the elapsed time vi (under timing) but didn't get it to work. I know it is possible using this vi. I think I what I am doing is not the right way. Attached is a screenshot and the vi I am haaving problems.



Yes, you are doing it wrong. I have right now only LabVIEW 2012, so I cannot open your VI, unless you downgrade it for me and attach it (save for previous version from menu).

What I see from the screenshot, you use a FOR loop to create five files, yes?

I am not really sure what you want to do here, but if you want to save 5 different files, why do you need this inner FOR loop? Make the outer loop run 5 times, put the "Time delay" express VI (not the Elapsed time vi) after each file saving operation, and that is all (of course in this case you delay the outer loop too).

If you want the main code running independently of the file saving operation, then you need TWO separate loops, as I wrote earlier, or a state machine. I cannot recommend better solution yet, since I cannot open your VI.

 

As I see, you do not even have the basic idea about how data flow works. I really recommend you to go through the LabVIEW tutorials and online teaching material, otherwise you will not understand what is going on (even if someone gives you a working solution here in the forum).

 

edit1: I put together quickly something which may help you, this is not necessarily the optimal solution (or even a Rube Goldberg if I was not careful 🙂 )

 

example1_BD.png

 

0 Kudos
Message 2 of 8
(3,245 Views)

Hi Blokk,

 

Thank you for replying to my query. The for loop is for generating different names for each image. If I choose the time delay vi then like you said it will affect the whole program which is what I dont want. All I want is to save images with a delay without affecting the rest of the program. Adhereing to your previous advice of using two separate while loops, I tried doing that as well , unfortunately no luck . You are absolutely right about me need to learn a lot. but " drowning men cluthces straw". 🙂 

 

I ahve downconverted the VI to 2012 for you to have a look. I have also attached a vi that i made with two while separate loops (produce/consumer).

 

Hoping for good.

 

Thanks Blokk

Download All
0 Kudos
Message 3 of 8
(3,228 Views)
Solution
Accepted by topic author naserkhan

Is this you want? When you click on the "Save 5 images" latch type button, the VI should produce 5 images, with 3 seconds delay between them.

edit: this VI will also wait 3 seconds BEFORE saving the first file, if you want the first file to be created when the button is clicked, you have to modify the VI a bit, so you can practice a bit more 😉

edit2: important to emphasize, that you did not have any timing in your while loop to slow it down. If you run such while loop without timing, your computer tries to run it as fast as possible. This is not a good practice. So I put a 50 msec wait into the loop, to be ok with this...

edit3: I also forgot to connect wire to your "Photo #" numerical indicator. you can put it into the required place and connect the counter integer wire to it.

 

Message 4 of 8
(3,209 Views)

Dear Blokk,

 

I would like to genuinely thank you, I just ran the code and it works ; saves images with a delay in between. 

 

Can I ask if I have any more modifications to make and if I am stuck again. is it fine to ask for your help again? or is it too much to ask...:)

 

Thanks agian Blokk

0 Kudos
Message 5 of 8
(3,186 Views)

No problem at all, if I have time, I am happy to help. I also get lots of help from others here in the forum.

The important thing is that, you should try to learn from the given examples, the aim is to understand how your VI works.

So as in your other post I suggested, take some time and use the available online learning material. It will help a lot!

0 Kudos
Message 6 of 8
(3,180 Views)

I admire your cleverness in terms of coding; the way you used the shift registers, select,etc. I now completely understand yoour version . However, I have a question, Do you think the 50ms delay you added could affect the reception of data if I use Visa vi to receive data serially (vis RS232) at a baud rate of 19200 bps?

0 Kudos
Message 7 of 8
(3,170 Views)

First of all, many programmers in this forum would give you a much more elegant and compact solution compared to mine one 😄

 

Regarding to your question, if you put a VISA Read function into the loop, of course it will take a certain execution time. It all depends on the actual case, how much data you read, how fast. Usually if you have such VISA Read in a while loop, then you can remove the 50 msec "Wait", since the VISA serial VI takes time. But we need to see your actual VI to give better advice in the particular case.

In general, you can check how much time a single while loop iteration takes in this case, for example:

 

timing.png

 

Anyway, if you have such question or run into problem,  create a new forum post with attachment of your VI, so the people can give you suggestions.

0 Kudos
Message 8 of 8
(3,158 Views)