Need help with Elapsed Time VI

Hi everybody, I’m a programmer for team #2250 (I apologize for my bad English). I got a problem with the Elapsed time VI (i think). I’m trying to set a loop that run in a certain amount of time (4 sec). I put 2 elapsed time VIs in 2 while loop cases. I set the time target is 4, the auto reset setting is true, the start time is 0 for each of them. The 2 loops is inside a sequence flat case (separately). When I try to run it, the robot does exactly what I want (a motor run forward 4 sec, then run backward for another 4 sec). However, when I try to do it the second time (with the same program), the timing goes crazy. The motor run forward for about 2, or 3 sec and then stop when it supposes to run backward. I reset the robot, deploy the same code again, and the first time I press the button, it goes very well (forward and backward), the second time, it is bad. I believe there are some mistakes in settings of the elapsed time VI. I think if I add some codes to reset it completely before run the loop (whenever I press the button) maybe helpful but I don’t know how to fix it. Any ideas will be appreciated.

It’s hard to follow your description well enough to give you good advice. It would help if we could see your code, or at least a picture of it.

Also, where is this code placed? There might be a better or easier way to do what you want.

I think I know what you mean. If you set it to auto reset than when you press the button, the time in between the reset and pressing the button has already occurred and say 1 second has been in between the reset and the time the button was pressed, it will only seem like 3 seconds when really it has been 4 seconds. If you reset the timer when you press the button it should do what you want it to. You will also have to reset the second timer when the first timer has elapsed. But be careful because if you hold the button down then it will continue to reset itself and time will not elapse until 4 seconds after you release the button. Is this what you needed?

sorry for the disconvenient , I got the pic for what inside the button 1- true case ( it is too big, i can’t post the whole code up). Basically, on the left side, the first 2 wires are the solenoid references, the 3rd is the watchdog reference, the last one is for a motor. What supposed to happen is the solenoid goes out, the motor run forward 4 sec, the solenoid goes back in then the motor run backward 4 sec. It always work perfectly the first time I press button 1, but the second time , or third, it doesn’t: The solenoid goes out, motor run for 1 or 2 sec then the solenoid goes in and then motor stop, not running at all. Thanks for replying me.

I’m not entirely sure where and when you’re trying to do this. I think you can make it do what you want by removing the while loops, deleting the Elapsed Time, replacing the watchdog feed inside the loops with watchdog “feed and delay”, and using the error inputs and outputs of the various vi’s to control the order of events. If you have last year’s default LabVIEW code to look at, its Autonomous Independent shows how to do it.

I solved it this afternoon. I was over think the problem. You are right Alan, I don’t need the loop and the elapse time vi, but I have to leave the watchdog feed tinggy( or else it will say watchdog not fed on the driver station). I just put a delay vi, set it to 4 sec and the set motor speed. Everything is working now. Thanks for helping me, both of you.

His point is that if you replace the Watchdog Feed with the Watchdog Delay and Feed, you don’t need the while loop or a separate Delay.

The Watchdog Delay and Feed will feed the Watchdog periodically as it delays.

No, I’m talking about the time delay VI, not the watchdog delay vi.

Right… and what he is saying it to use the delay and feed VI instead of a delay and a feed separately.