Log in

View Full Version : How often is code run in teleop?


DominickC
30-01-2012, 20:40
Hello -

I'm looking to migrate some of my code which I have written into Teleop.vi (mainly moving motors and servo's with buttons) into Periodic Tasks.vi, mainly to cut down on the Watchdog errors we get periodically.

However, I know that I must put the code within a while loop and tell it how long to wait till the loop executes again.

If I'm getting the value of a joystick button, and if someone is holding the button then we are changing a case structure to true which moves a servo +1 degree, how much wait between each iteration of the code will result in the fluid motion we see within Teleop.vi?

Thanks.

EDIT - Also, is the Select function more efficient than a Case Structure?

Ether
30-01-2012, 20:48
Re: How often is code run in teleop?

Roughly 20ms.

Greg McKaskle
30-01-2012, 20:59
Ether is correct. But I posted a notice to the CPU usage thread pointing out that the loops have no delays and are probably running hundreds of times in the 500ms and are maxing out the CPU.

Greg McKaskle

DominickC
30-01-2012, 21:22
Awesome, thanks.

Now, how can I set code to write a value, sleep/wait for x ms, then write another value?

Ether
30-01-2012, 21:24
Awesome, thanks.

Now, how can I set code to write a value, sleep/wait for x ms, then write another value?

Use a state machine or a parallel loop (thread).

Explained here:

http://www.chiefdelphi.com/forums/showpost.php?p=1094796&postcount=3

... and here:

http://www.chiefdelphi.com/forums/showpost.php?p=1094821&postcount=6