Timed While loop within Teleop

Hello -

I’m looking to drive a Drive motor for 1/8th of a second with the press of a Joystick button. So, here’s what I’ve come up with.

Basically, checking to see if the button is pressed. If not, pass on the set values assigned by the joystick axis. If it’s pressed, substitute the value of -0.8 for 125 iterations, amounting to 1/8th of a second.

Since the Drive Motors will be assigned a value during this time, will I see any watchdog errors?

Thanks.

So these iterations are happening at 1000Hz??
*
*

It’s just a conceptual value to see if I’m understanding the issue/solution at hand. I know that Teleop runs at 20ms, so I’d also be able to do around 6 iterations at a 20ms delay, however I don’t know how Watchdog would respond.

I assume I would start at 1, and keep increasing the delay till Watchdog got unhappy.

Use a state machine instead.

The Safety vi defaults to .1sec, so delaying for .125sec will trigger it.
If you feed the Drive motors the same value (-0.8) at a faster rate than .1 sec, then it won’t trip.

You might trip the watchdog. You’ll certainly mess with your drivers, since everything will pause for 1/8 of a second.

Teleop.vi happens pretty regularly. You really can use it as your timing loop. Have some value that passes between each run of Teleop.vi. (Use a feedback node for this.) If the value =0, do nothing and pass your joystick value through. If the value >0, subtract one from it and substitute 0.8 for your joystick value. To trigger it, set the value = 125 (or whatever’s appropriate. I forget the timing of Teleop.vi) if the button is triggered.

That’s actually a desired outcome, believe it or not.

As for State Machines, I’ve always had trouble comprehending those and still have this issue…

You actually already understand the basic concept, judging from your original post. You just used the wrong numbers.

Since TeleOp runs at ~20ms, just override the joysticks (with the -0.8 command) for 6 iterations (6*20ms = 120ms = approx 1/8 second).

Your motor will be happy because it is being commanded more often than 100ms, so neither the safety nor the watchdog will trip.
*
*

Ah, I see! ~~ 6 iterations it is. Thanks!