Upcoming Events:
Kickoff!
Jan 11, 2017 5:30 PM:
MS Science Fair
Feb 9, 2017 3:00 PM:
Chairman's/Woodie Flowers Due
Full event list
Team 358
HomeBlog
Sponsors
News Articles
History
Contact
FIRST® Things First
What is FIRST?FIRST Official Site
FIRST in the News
FRC® Game Details
FRC® Game Animations
Multimedia
FIRST Promo VideosFIRST News Segments
Team 358 Photos & Videos
T-shirt Collection
Team Resources
Start a TeamOrganization
Sponsorship
Fundraising
Marketing/Publicity
Website
Strategy
Scouting
Career Planning
FIRST Scholarships
Technical Resources
Control SystemMechanical
Pneumatic
Electrical
Safety
Workshops
General Resources
Offsite ResourcesFRC® Statistics
Long Island Teams
FIRST® Robotics Competition (FRC®)
Control System 2015-2019
LabVIEW Programming
Joystick | Digital Input | Analog Input | Relay | Servo | Single Motor | Button Toggle | | Single Solenoid | Double Solenoid | Arcade Drive | Tank Drive | Mecanum Drive | CAN Tank Drive | Button Start of Timed Action | Which Button Was Pushed | Button Increment Power | Switch | Limit Switch | Limit Throttle | Limit Max Power | Joystick Response Curve | Joystick Deadband | Voltage Corrected Drive | 3-position Switch | Digital BCD Switch | Write Data to Disk | Write Image to Disk | Tachometer | Encoder | Gyroscope | Accelerometer | Potentiometer | Ultrasonic Sensor | I2CSensor | Counting Things | Moving Average | State Machine | Delayed Event | PID | Camera | Interrupt | Equations | Autonomous |
Resources:
- LabVIEW Keyboard Shortcuts
- WPI workshops
- OpenG Libraries - Hundreds of Free, Reusable VIs
- LabVIEW Wiki
- FRC_Getting_Started.pdf
- FRC_Programming_Guide.pdf
- FRC_Vision_API_Specification.pdf
- LabVIEW Development Environment system requirements
Special Topic Guides
- How to Create a vi
- Adding Global Variables
- Timing is Everything
- FRC LabVIEW Training Outline (rough initial draft)
- Create Your Own FRC Dashboard
LabVIEW Troubleshooting
Special note on the library vi's: Starting in 2013 the cRIO simulator was added. This introduced two different versions of many of the WPILib vi's, one for executing stand-alone on a PC and another for standard operation on the robot cRIO. The proper version of the library code gets loaded depending on the current Target (PC vs. cRIO). An odd side effect of this is that if you drop a library vi onto a blank vi just to drill down to study the internals, then you will probably get the PC version and you'll be studying how the cRIO simulator works, not how the robot version of the code works.
Common Robot Operations
Here are examples of ways to do some of the most common robot functions. Because the framework spreads the required elements over several files these examples are in image form to get all the parts together where you can see everything in one glance. Each example includes the menu paths to where all the icons used within that image are found.LabVIEW also provides stand-alone ready-to-execute examples from the Getting Started Window that include wiring diagrams for connecting devices properly. Those sample projects are great for testing if a device is working and wired correctly. Since they are stand-alone programs it takes some intermediate understanding of the default framework to figure out how to properly integrate the concepts into your LabVIEW project.
- JoystickExample (2015)
WPI Robotics Library->DriverStation->Joystick
Programming->Array->Index Array
- Digital Input Example, e.g., limit switches (2015)
WPI Robotics Library->IO->DigitalInput
- Analog Input Example (2015)
WPI Robotics Library->IO->AnalogChannel
- Relay Example (2015)
WPI Robotics Library->Actuators->Relay
WPI Robotics Library->DriverStation->Joystick
Programming->Comparison
Programming->Array->Index Array
- Servo Example (2015)
WPI Robotics Library->Actuators->Servo
WPI Robotics Library->DriverStation->Joystick
Programming->Comparison
Programming->Array->Index Array
- Single Motor Example (2015)
WPI Robotics Library->Actuators->MotorControl
WPI Robotics Library->DriverStation->Joystick
Programming->Array->Index Array
- Button Toggle Action (2015)
WPI Robotics Library->DriverStation->Joystick
Programming->Structures
Programming->Comparison
Programming->Cluster,Class,&Variant
Programming->Array->Index Array
- Button Control of Motor Example (2015)
WPI Robotics Library->Actuators->MotorControl
WPI Robotics Library->DriverStation->Joystick
Programming->Comparison
Programming->Array->Index Array
Want more buttons? Add a Select for each like so:
Don't want to have to keep holding the button down? Then add a Feedback Node to remember:
Using an xBox where the triggers are actually read as an Axis:
- Single Solenoid Example (2015)
WPI Robotics Library->Actuators->Solenoid
WPI Robotics Library->DriverStation->Joystick
Programming->Array->Index Array
- Double Solenoid Example (2015)
WPI Robotics Library->Actuators->Solenoid
Programming->Boolean
WPI Robotics Library->DriverStation->Joystick
Programming->Array->Index Array
- Arcade Drive Example (2015)
WPI Robotics Library->RobotDrive
WPI Robotics Library->DriverStation->Joystick
Programming->Array->Index Array
- Tank Drive Example (2015)
WPI Robotics Library->RobotDrive
WPI Robotics Library->DriverStation->Joystick
Programming->Array->Index Array
- Holonomic or Mecanum Drive Example (2015)
WPI Robotics Library->RobotDrive
WPI Robotics Library->DriverStation->Joystick
Programming->Array->Index Array
- CAN Tank Drive Example (2015)
User Libraries->CANJaguar for LabVIEW
WPI Robotics Library->DriverStation->Joystick
Programming->Array->Index Array
- Button Start of Timed Action (2015) - the timed-delays used here as an example can be replaced with sensors that tell positively when the mechanism is cocked or has finished shooting.
WPI Robotics Library->DriverStation->Joystick
Programming->Structures
Programming->Comparison
Programming->Array->Index Array
- Which Button Was Pushed (2015) - Useful for deciding which of several joystick or custom Driver Station buttons was pushed.
This acts based on which of an array of buttons was pushed. Lowest number button wins if several are pushed at once.
WPI Robotics Library->DriverStation->Enhanced IO
Programming->Structures
Programming->Arrays
Programming->Numeric
Programming->Boolean
Programming->Array->Search 1D Array
- Button Increment Power (2015) - This raises or lowers the power to a motor whenever one of the buttons is pushed, so it increments the power one step with each push.
Programming->Structures
Programming->Comparison
Programming->Array->Index Array
- Switch (2015) - has a toggle for selecting Normally-Closed or Normally-Open wiring.
Has a counter mode that counts the number of times the switch is activated.
WPI Robotics Library->Sensors->Switch
Programming->Array->Index Array
- Limit Switch (2015)
WPI Robotics Library->DriverStation->Joystick
WPI Robotics Library->IO->DigitalInput
Programming->Structures
Programming->Comparison
Programming->Boolean
- Limit Throttle (2015) - this example works ONLY in Teleop.vi because it depends on the regular 50Hz rate at which Teleop.vi gets called. To use
it in Periodic Tasks, for instance, it would be called inside a loop and a loop delay would be added.
WPI Robotics Library->DriverStation->Joystick
WPI Robotics Library->Actuators->MotorControl
Programming->Numeric
Programming->Array->Index Array
- Joystick Response Curve (2015) - example is a simple cubed response curve
WPI Robotics Library->DriverStation->Joystick
WPI Robotics Library->Actuators->MotorControl
Programming->Comparison
Programming->Numeric
Programming->Array->Index Array
- Joystick Deadband (2015) - How to deal with a sloppy joystick that doesn't quite return to zero when released.
The first example has the same deadband, but truncates the motor output delivering between .1 and 1 (or -.1 and -1), so no .05 power ever shows up. This is good for devices, such as drivetrains, that won't move with less than .3 power anyway. It gives the joystick a little more range.
In the second example the joystick is ignored within the deadband (.1 to -.1 in this example) and outside that band delivers motor power from 0 to 1.
WPI Robotics Library->DriverStation->Joystick
WPI Robotics Library->Actuators->MotorControl
Programming->Comparison
Programming->Numeric
Programming->Array->Index Array
- Joystick Max Throttle Limit (2015) - How to deal with a drive train that's too fast (well if you can't gear it down).
The first example uses the throttle on an Extreme 3D joystick as a variable control to limit max driving power to between 50-100%. A possible variation might be to allow more power to the Arcade rotate input.
In the second example the max power is limited to a hardcoded 80%.
WPI Robotics Library->DriverStation->Joystick
WPI Robotics Library->Actuators->MotorControl
Programming->Comparison
Programming->Numeric
Programming->Array->Index Array
- Voltage Corrected Tank Drive Example (2015) - this is a simple way to make your drive controls response a little more consistent
WPI Robotics Library->RobotDrive
WPI Robotics Library->DriverStation->Joystick
- 3-position Switch (2015)
WPI Robotics Library->IO->DigitalInput
Programming->Comparison
Programming->Numeric
- Digital 0-9 BCD Switch (2015)
WPI Robotics Library->IO->DigitalInput
Programming->Boolean
Programming->Array
- Write Data to Disk (2015)
Programming->File I/O
Programming->File I/O->File Constants
- Write Image to Disk (2015)
Programming->File I/O
Programming->File I/O->File Constants
FIRST Vision->Image Management
- Tachometer (2015) - assumes a digital sensor, such as a retro-reflective light sensor, is used to detect a spinning object.
One caution about Counter - it can produce scrambled or bogus values on startup, so be careful and examine the results when you first put it to use.
WPI Robotics Library->Sensors->Counter
- Encoder (2015)
Only allows for four encoders to be sampled at 4x, but many at 2X.
WPI Robotics Library->Sensors->Encoder
WPI Robotics Library->IO->DigitalInput
- Gyroscope (2015)
WPI Robotics Library->Sensors->Gyro
- Accelerometer (2015)
WPI Robotics Library->Sensors->Accelerometer
- Potentiometer (2015)
WPI Robotics Library->Sensors-> Potentiometer
- Ultrasonic Sensor - Only for paired emitter/sensor Vex-style (2015)
WPI Robotics Library->Sensors->Ultrasonic
- I2C Sensor (2015)
WPI Robotics Library->Communications->I2C
Programming->Array
Programming->Numeric->Data Manipulation
Programming->Array->Index Array
- Counting Things (2015)
WPI Robotics Library->IO->DigitalInput
Programming->Structures
Programming->Comparison
Programming->Boolean
- Moving Average (2015) - You call this subvi to add a new value with each call and it produces the average over a window of the last n samples.
You tell it the number of values (n) to average only with the first call, thereafter, that input is ignored. It also lets you know when you have reached
a full set of values. This example illustrates initialization, sequencing to avoid clobbering values as you use them, safeguarding from changing inputs that cannot be changed, array manipulation, and creating a cycling index.
LabVIEW has quite a few built-in filters that do the work for you located in the Functions pallete under Signal Processing->Filters.
Programming->Array
Programming->Structures
Programming->Comparison
Programming->Numeric
Programming->Numeric->Conversion
Programming->Boolean
Programming->Synchronization
- State Machine (2015) - the idea here is that you want to do different things based on a particular state your program is tracking. In this example you'd add some kind of activities for each state, such as activating solenoids or motors. States might change based on sensor feedback, such as a ball sensor.
WPI Robotics Library->DriverStation->Joystick
Programming->Structures
Programming->Comparison
Programming->Numeric
Programming->Array->Index Array
- Delayed Event (2015) - this is for use within iterative vi's, such as Teleop, and simply might start an action, then stop it n seconds later.
This type of action can also be performed for you by the Elapsed Time vi.
WPI Robotics Library->DriverStation->Joystick
Programming->Structures
Programming->Comparison
Programming->Timing
Programming->Numeric
Programming->Numeric->Conversion
Programming->Array->Index Array
- P(ID) Example (2015)- This code slaves a pot on the robot to the x-axis of a joystick via Proportional feedback. No I or D terms are used.
Most of the work here is just the part that maps the full range of joystick movement to the steering motor potentiometer (pot) sensor. The PID part is pretty simple.
The harder part is tuning the P coefficient by experimenting with the real robot.
WPI Robotics Library->DriverStation->Joystick
WPI Robotics Library->IO->AnalogChannel
WPI Robotics Library->Actuators->MotorControl
PID
Programming->Numeric
Programming->Array->Index Array
- Camera Example (2015)
WPI Robotics Library->Camera
FIRST Vision->Image Management
Programming->Structures
- Interrupt (2015)
Use of this will be rare, but this can be used with either a Digital Input or an Analog Trigger.
WPI Robotics Library->Utilities->Interrupts
WPI Robotics Library->IO->DigitalInput
- Equations (2015)
Programming->Numeric
Mathematics->Elementary & Special Functions->Trigonometric Functions
Programming->Structures
The formula node allows for the insertion of a pretty good subset of C. It not only lets you write equations, but loops and conditional code as well.
- Calling C code (2015)
To call C functions from LabVIEW you can create a C source library, then call into that library using a Call Library Function.
For simple code use the formula node mentioned just above. The formula node allows for the insertion of a pretty good subset of C. It not only lets you write equations, but loops and conditional code as well.
Autonomous Programming
Autonomous Independent.vi can be multiple parallel tasks. For example, the following two samples can co-exist quite comfortably in the same vi. Two independent sequences operating at the same time, one driving the robot while the other blinks a solenoid status light. This case is quite simple, however, it illustrates that much more complicated parallel independent tasking such as this is possible. Maybe a robot juggling while navigating a maze.Flat Sequence - Probably the simplest method of programming a fixed sequence of autonomous moves. Everything within a frame must complete before the next frame will start. It has the look of movie film. This example assumes any Enabled Motor Safety's have been Disabled:
Get Microsoft Excel Viewer
Get Microsoft PowerPoint Viewer
Get WinZip