Trouble understanding timed tasks in Periodic vi

My team is using the 2-wire VEX motor 393 to “kick” the frisbee into a wheel that is meant to shoot it. We only want to turn it once so I figured that since the motor is 100 rpm then one revolution would take 600 ms. I know that to do a timed event, you must use the Periodic Tasks VI but I’m not sure on how this works in a block diagram (I was a text based programmer before this). I was thinking that our primary joystick, “Joystick I”, would trigger some sort of case structure when Button 1 is pressed and then have the motor, “Initator”, turn for 600 ms. I’ve looked at resources such as Team 358’s very helpful LabVIEW resources but I don’t understand why the outside while has a wait for 10 ms. Attached is the resource that I am referencing.

Thanks for any help that you can give me.

The outer loop runs all the time just checking to see if the button has been pressed.
The button can’t be pressed any faster than 20ms, because that’s how often a fresh command packet arrives from the Driver Station.

The outside Wait is just to keep the outer loop from running as fast as possible and sucking up all the available CPU when it really isn’t doing anything. All loops should be throttled by a Wait of some kind, because the Wait releases the CPU for time sharing with other tasks that are running on the cRIO.
The outside Wait can actually be 20ms.

Let me restate what Mark said a different way.

There are four things in the loop that run simultaneously. They are the Wait for 10ms, the production of the i, determining if the loop runs another iteration, and the test of joystick button and conditional motor stuff.

The iteration of a loop completes when all inner tasks complete, and the wait of 10 ensures that it doesn’t run faster than 100 times per second. With no delay, it would be way faster than you need and would take all of the CPU time that others aren’t using.

Greg McKaskle

The spreadsheet represents how it would execute if the code and wait were serialized. Since there isn’t a data connection, the delay and code run in parallel. The attached image shows a loop with a number of things that take 10ms – they all happen to be wait functions. And the loop will therefore will execute approximately every 10ms.

Greg McKaskle

Clipboard 1.png

Clipboard 1.png

Hmm. Referring to this paper:

… it looks like the 10ms wait causes an average execution time of 12 ms, whereas the “wait until next multiple” averages 10ms. That’s why I assumed the wait was serialized.

Mark, could you expound on that?

(I deleted the original post pending resolution of this. I don’t want anyone to be misled by it.)

The point of their paper is correct. Wait 10ms will guarantee that the loop period will be 10ms minimum. If enough other stuff is going on, it will accumulate extra time. The ms multiple version will have an initial wait that aligns to the clock phase and will then stay in phase and skip with large overages. The timed loop has many options and has the least jitter by far.

But on the topic, the language doesn’t serialize them, and most users don’t either.

Greg McKaskle