From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Error Messages

Hello everyone. I have received a few requests on how to "create your own error messages" so they could be logged on the driver station. The good news is this is not hard. .

 

A note of caution: The error messages can be very useful for the support crew to help you and your robot at competition. If there are many "custom" messages on the screen all the time it will make that support harder and take even longer. 

 

All that you need to do is to create a subVI that has an error out. When you drop this in your robot code without wiring the error out to anything. Here is how to do it:

This is a code snippit... you can drag and drop it into the block diagram of a new VI (File -> New VI)

Make sure you connect the "Current Button State" and the "Error Out" to the connector pane at the top right of the front panel.

Generate Error.png

The "Current Button State" receives a button input. From there I save this value for the next time this subVI Runs. 

The case statement and the Selector are catching only when the button changes states (as in when the button changes from False/unpressed to True/pressed) but any other time it doesn't throw an error.

For the case shown, If the previous cycle (t-1) was True and now (t=0) the button is False the message "Button B Released" will be sent. 

For the error message to show up:

  • Error status must be True
  • the Codes reserved for custom error handling are -8999 to -8000 and 5000 to 9999 and 500,000 to 599,999
  • the Source or message can be anything you want it to be. 

Define your error codes somewhere and try to be consistent. 

 

Here is how you use the subVI in the Teleop.vi

Generate Error in Teleop.png

I have attached my example Generate Error.vi 

 

So here is how it works...If you look in your Robot Main.vi below the main loop but above the Vision subVI you will see a subVI with a Blue top and white body that says "DrvrStn" in blue and "START COMM" this is the WPI_DriverStationStart Communication.vi

If you open this VI and look to the lower left you will see a loop with a note that says "Catch unhandled errors and pipe them to the DS". The the gray and white box in the while loop is called an Event Structure. This triggers when a registered event occurs. If there is no event (and the time out state is unwired) it will sit there (not using any clock cycles) until it is triggered.

 

Let me know if this helped or if you have any questions!

Ryan

Team 2341 Mentor

 

(Kudos are always welcome!)

Message 1 of 3
(3,085 Views)

This is exactly what I was looking for and very descriptive. Thank you!

0 Kudos
Message 2 of 3
(3,074 Views)

You are welcome!

Good luck on your robot for this year!

0 Kudos
Message 3 of 3
(3,069 Views)