LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timing problem multiple hardware-interaction

Solved!
Go to solution

Hi all! I’m not really used to programming in LabVIEW but I’m trying to write an application that can make simple data reads and writes via RS232.

 

Problem is:

I need to make one read every five minutes or so, and another write every 20 minutes or so (it’s not crucial that it’s accurate at a millisecond-level).

 

How should I arrange the timing? Should I use the wait(ms)-function or have some sort of loop that polls the system time and check whether it’s time to do the read/write?

 

If I’d use the wait(ms)-function wouldn't all LabVIEW lock down for five or twenty minutes?

0 Kudos
Message 1 of 5
(2,351 Views)

What you do will depend upon how interruptible you want the resulting code to be.  My personal preference would be to create a loop with a millisecond timer set for somewhere between a tenth of a second to a second delay.  I would then look for elapsed time intervals to trigger the reads and writes.  I would use Wait (ms) for the loop delay and Get Date/Time in Seconds to check the times at each iteration.  You can cache your time intervals in a shift register.

 

You can modify things as needed for your application.  Let us know if you need more help.

Message 2 of 5
(2,324 Views)

Thanks ALOT for your input DFgray!!

 

I've been doing some research and I found this link: http://zone.ni.com/wv/app/doc/p/id/wv-3381

 

Do you think it's a good way to go? I could have one process that polls for whether it's time to do data read/write and when it's time it sends a message to a process that handles the acutal hardware-interaction.

 

Could be a good way to go?

0 Kudos
Message 3 of 5
(2,297 Views)
Solution
Accepted by topic author jhndr-mc

That is precisely what I would do.  I would probably have one loop for UI interaction (contains the event structure), one for timing, and one for controlling hardware.  Note that the last two can be in subVIs or launched as top-running VIs.

 

Good luck!

Message 4 of 5
(2,267 Views)

thanks again DFGray!

0 Kudos
Message 5 of 5
(2,238 Views)