Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Remainder and Quotient function

I am using a while loop to do Data acquisition at 100ms and in the same loop I want to send acquired data through RS232 to another computer every 2sec in the same loop. But when I make the program, the overall loop time becomes 2sec. How can i control this problem? How can I use quotient remainder function to control the loop?

0 Kudos
Message 1 of 4
(2,840 Views)

Tie the time in the loop to the Quotent/Remainder and since the time will not be in exact 2.0 seconds, set a "window" for the timer remainer value to be within some tolerance of 0 remainer (near the 2 second multiple) send the boolean signal of this condition to a select case within the while loop to do the RS232 data send. The purpose of the time tolerance for the 0 remainder, is that the time will never be exactly 2 seconds and will be near that interval. You want the tolerance big enough that it catches every loop to do the send, but doesn't catch more than once because the time tolerance is too big. Another option would be to do a double loop. The inner one does the data taking and timing to 2 seconds, when the timer exceeds the 2 second window, it exits the inner loop does the RS-232 send in the outer loop and then cycles back into the measurement loop. Be sure to have loop exit conditions, or it will run forever, so you will need some exit conditions. One method or the other should do the trick. Good Luck.

0 Kudos
Message 2 of 4
(2,833 Views)

Why don't you just use the Elapsed Time Express VI?

0 Kudos
Message 3 of 4
(2,828 Views)

Thank it helped!

0 Kudos
Message 4 of 4
(2,810 Views)