LabVIEW Programming Resources.
Open all your motors, controllers an devices here, and create refnum names to uniquely identify each of them. This is called only once at the very start.
The Framework is setup here in Begin.vi to automatically call the Autonomous Independent.vi at the start of Autonomous Mode and to automatically kill it when Autonomous Mode ends.
Typical driver controls. This is called 50 times per second as the Driver Station control packets arrive. Do NOT write code in here that waits or takes more than a few milliseconds to execute. If this vi takes too long to execute, then your driver controls will respond sluggishly, sporadically, or not at all. That means no While loops, no wait timers, no Watchdog Feed & Delay.
Normal driver operating code will usually be split between Teleop.vi and Periodic Tasks.vi. This gets the flow-through actions, such as driving via the joysticks, that don't require delays to give a mechanical mechanism time to complete operation.
Periodic Tasks.vi gets the complex time-consuming actions that need much time to complete, like a catapult that needs to be released and cocked again as part of a single joystick button press. Anything that makes you want to add a time delay or have to wait for a sensor to tell you it's ready can more easily be done in Periodic Tasks.vi than anywhere else.
This is called only once, but it is expected that tasks in here will execute within a never ending While loop or a Flat Sequence structure. Typically, you'll have several completely separate loops running in here to do mutually independent stuff. This can be used for timed sequences, for instance, if you have a mechanism that operates in several discrete steps. Like a motor cocking a catapult with a lact that holds it down, then is released with pneumatics and after launch the process is looped. You can have a completely separate loop just paying attention to one of your joystick buttons and jumping to do what you want whenever that button is pressed.
This simply closes all the devices you opened in Begin.vi to clean up when the program exits.
Oddly enough due to the way we shutdown, i.e., we un-power the robot, this Finish.vi will never be executed. It's presence here is to teach good form that will be important in most normal applications of LabVIEW that students will encounter when using it at college and work.
Below are some common LabVIEW operations that we have came across and used! This list is still under heavy construction so check back frequently!
Encoder motor example- Read outs and other variables.
Using Encoder as a Limit Switch
Periodic Tasks.vi- Main Loop
This task allows the motors to stop at a certain encoder readout, similar to that of a limit switch, only less physical properties. Keep in mind that this will only allow motor movement in the opposite direction once a limit is reached: any further movement is from the motors lack of torque or the weight of the object being held. The button for reset is completely optional. Basic wiring and knowledge is required. Creation of global variables is also a required task. The boxes encasing the examples are completely
Encoder- Setting the Limits
This is the call for the encoder that tells when the limits are being passed. The '5.178' is the divisor found by moving the motor 180 degrees, then dividing the current output by 180. The '120' and '-120' are the current limits, based on what has already been found with the divisor.