General LabVIEW questions from a VERY new user

The array looking thing is an array constant. In it I put a cluster constant and two numeric constants inside that. The array constant comes from the Array palette, Cluster from Cluster palette, etc.

The Mechanism Op is a global variable. You should probably open Robot Globals from the palette and add it there, but if you wish, you can make a new file to organize your globals into. The Global I added is an enum, largely because of readability, but a number or Boolean would also work, even a string.

The slot at the top is the border of the Case structure.

Reading the code from outside to inside, it is a While Loop, a Case Structure, then a For Loop, and a Sequence inside that. Do each of them make sense what they do and why they are being used?

Greg McKaskle

I still can’t find Stop or Mechanism Op. (tried going to global data.vi file but ctrl+e didnt bring up a block diagram and I couldn’t figure out how to get it from the right click menus). What kind of vi is Stop?

Does it matter if my case structure says True/False instead of Go?
Does it matter if my variables in the array don’t have labels on them?

Other than that, I think I’ve got it. Once I finish setting it up, I’ll dive in and learn what each thing does. Attached what I have so far





The Robot Global Data vi only has a front panel. There is no associated block diagram. Global variables are just controls on the vi’s front panel. When you want to create a new global variable, just place a control of the appropriate type there. “Mechanism Op.” is a global variable that Greg created for the example. “Stop” and “Go” are values of an enumerated data type that he created to make it easier to read the intent of the values. You can just use a boolean with values of True and False if you don’t want to dive into enumerated types yet.

http://www.fightingpi.org/Resources/Controls/Labview%20Resources/labview_tutorial/FIRST%20Documentation/FRC%202012%20Robot%20Framework%20Tutorial.pdf has some tutorial information about using global variables at the end of the document.

So by creating an enum on the Front Panel of Global Data.vi and renaming is Mechanism Op, I got it in my code. After wiring this up in the 3 places shown, the True/False changed to 1/0

Still not sure how to get the Stop thing.

Once I finish this (and understand how it all fits together), is it just a function I can call in any other files in the project? How do I use it in teleop and autonomous?

Edit the properties of the enum and give it named values of “Stop” and “Go”.

Once I finish this (and understand how it all fits together), is it just a function I can call in any other files in the project? How do I use it in teleop and autonomous?

The code Greg suggested goes in Periodic Tasks. Any time you want to trigger it, set the global variable to True (or 1, or Go, whatever you end up using). You can do that from any vi in the project.

how do you put the blue Stop thing though?

EDIT: Is there one of these VI’s that is a MOTOR vi, not a DRIVE vi? That would make things WAYYYYYYYYYYYYYY simpler, and easier to understand. Pic attached

aaa.jpg


aaa.jpg

After you’ve placed the enum control, right-click on it and choose Properties from the popup menu. Select the Edit Items tab. You can insert new items and rearrange the items in the list. The “Items” column holds the name of the enumerated values; you can double-click on one and edit it to be whatever you like. Greg picked “Stop” and “Go” for his example.

EDIT: Is there one of these VI’s that is a MOTOR vi, not a DRIVE vi? That would make things WAYYYYYYYYYYYYYY simpler, and easier to understand. Pic attached

You don’t need a combined “drive and delay” vi for a motor that has the safety disabled. Just put a Delay in the frame next to the Motor Set Value.

The only timing VI’s i found besides that one are all seemingly independent. The one attached above wires directly to a drive system. So I need one to wire directly to a SetMotorOutput vi. Or if not, then I don’t know how to use one. Once again, all I’m trying to do is:

  1. Send a motor control the value of -1
  2. Wait 0.25 seconds
  3. Send a motor control the value of 1
  4. Wait 0.25 seconds
  5. Send a motor control the value of 0 (and leave it that way until I call this function again)

Greg, shouldn’t that last frame be after the For Loop? You don’t want to Stop execution after each set/delay; you want to Stop after they’re all done.

Yes. Reset the global after the planned movements are complete.

Greg McKaskle

I finally figured out the sequence. It was actually much easier than we were making it.

But now I’m starting to get into Autonomous programming. I think I understand the coding part of it fine, but I do have a few questions about the general use of Autonomous mode:

  1. I was told you can have up to… I think it was 10? different Autonomous modes. At competition, how do I choose one before the match starts?
  2. When practicing during the build season, how do I simulate the Autonomous mode part of the game? Do i change the drive station to Autonomous, Enable, and after 15 seconds it will automatically flip over to teleop, or is it more complicated than that? I’m unable to test anything with our robot at the moment but I also don’t want to accidentally mess anything up

Thanks!

There isn’t a limit on the number of discrete autonomous routines you write.

You can choose the mode to run from the Driver Station, using the I/O tab, or wired selectors, or by choosing with a button press or a sequence of presses.
You can install a switch on the robot itself to choose between autonomous modes. Switch values are available in your cRIO code. Lots of options.

Choosing Autonomous mode on the Operation tab will just run Autonomous mode as long as it’s enabled. No time limit is imposed.

Using Practice mode will by default go through a typical field cycle of Disable/Autonomous/Disable/Teleop/Disable. Options are provided on the Setup tab to adjust the times, so for instance you can reset the Teleop period to be 0 seconds if you don’t want to bother with that mode, but still get the Autonomous time limit and other transitions.





Awesome, i played around with the drive station and understand that part.

Still a little confused how I can tell the drive station or robot to pick (ex) Autonomous Mode 2 of 5. So if we wanted we could have an Auto Mode for the back of the period and the front, and choose between them at the last minute.

EDIT: Also so y’all know, I’m planning on making a video (after build season ends) where I go through our robot’s entire code and explain absolutely everything I can. This way anyone that’s in the position I was/am next year will be able to watch it and learn a ton without having to ask a million questions like me :slight_smile:

And also how to separate multiple Autonomous Modes in the programming

Either use the Dashboard to set a value that you then read on the robot using the SmartDashboard functions, or just use what’s on the I/O tab of the Driver Station.

Turn Autonomous Independent into a single large Case block. Put each mode’s code in a separate case and use the value you receive from the Driver Station (or the Dashboard) to select which case gets executed.