pic: Programming is as easy as you make it.



Here’s a sample of a simple program that uses while loops, case structures and flat sequence structures.

Anyone need help with their programming?

I had been told that it wan’t possible to use while loops in Teleop. I guess I was wrong. This is cool!

I’m pretty sure that wouldn’t be good for use in teleop

As long as it is in a separate thread its fine.

Oh, well I guess you could do that then

Just wire something to the Loop Condition terminal so that it can end. While loops are useful for Autonomous too.

Timed actions are best processed in Periodic Tasks

They will slow down your TeleOp code if placed there

This example is good for use in Autonomous and Periodic Tasks.
As shown, this example cannot be placed in Teleop.

I made this program up to help out someone who wanted to know if he did it right. based on all of your posts, I was able to help him a lot more. Thanks a ton!:slight_smile:

That is not the safest way to accomplish that task nor should it ever be in teleop. You should write the inputs from the joysticks to global variables and read them in period tasks in their appropriate loops.

Yeah, I told him that. I haven’t gotten a reply yet, though.

Do you ever have to write them as global variables?

You can just reference the joystick in Periodic Tasks

Well, I’M not using the program. I recently uploaded a few pictures of my teleop program.

You don’t have to…
…But if you do you can manipulate those variables in autonomous.

I’m just happy that the code WORKS.

I have found that when using Labview, Stacked Sequences are insanely helpful for programming autonomous. I haven’t seen too many people use them.

Without the sequence structures, my autonomous would make my robot die in agony.

But you can still manipulate the variables in auto mode…

I must be missing something

I also, must be missing something. Help! :confused:

Stack sequences are definitely easy, but ideally your gonna want to use a state machine. Even if at first it seems as though using a stacked sequence would have been the better way, you will come to appreciate the ability to control what state comes next as you start to modify your auton and make it more complex.