Recommended Guide somewhere? - How to create a custom VI?

I am trying to help my programming student with a better understanding how to make a custom VI. He’s done a great job coding this years robot but everything is in the teleop VI, including our elevator controls which is alot… It’s not often, but sometimes we get the “teleop loop too slow” error on the driver station. I think because there is alot going on in that loop.

Is there a recommended guide on best practice to move something out of teleop like for example create a custom Elevator VI, that would have it’s own loop and not slow down the normal teleop loop? Any pointers would be helpful to learn a bit more higher level learning about labview and making the code execute faster.

In the PLC world, I would create a custom function block with parameters, and feed my block parameters. This is what I think we need with the elevator. Is create a custom VI for elevator with it’s own loop and feed it values from tele-op with globals or something like that.

Where do you put that VI so it’s active? Just drop it in robot main? Labview is still strange to me how it thinks and processes data compared to a PLC.

If he feels comfortable in LabVIEW, here’s a link to start looking at the more advanced LabVIEW architecture:

This will naturally pull those loops out of teleop and communicate between teleop and the controller.

https://www.youtube.com/watch?v=Y9Nk5nHOoK4 This is an ~hour presentation given on Twitch a few weeks ago to discuss the architecture as well.

Put looped code in Periodic Tasks to be constantly executed.
That covers Disabled, Auto & Teleop and can loop as much as it wants.
If it’s just one time pass though code it can still be called from Teleop, but not if it’s a loop, then it’d stop Teleop execution.

Stay out of Robot Main as a matter of general principle.

To create a custom VI, you can just press the “New VI” button while having your project open and save it in your project folder, it should now appear in your project explorer (I named mine tutorial). You can move the newly created VI in a virtual folder or in the “Team code” folder (or whatever you want to do with it). To use the custom VI, you just have to drag in a loop in “Periodic tasks” (that’s where I put it, but you can put it wherever you want it to be executed). You can now edit the VI’s icon for easier utilization and change it’s connectors to use with indicators in the top left of the VI’s “Front panel” screen.

You can see how our team used it in the code (in my signature). Feel free to contact me if you have any questions.




There is a tutorial on separating things (in particular actuator code) out and putting it in Periodic Tasks at https://frclabviewtutorials.com/producer-consumer/

This tutorial in a nut shell is exactly what I was thinking. I will show him what you have. And maybe have him make a sub-VI in the periodic task he can feed the “consumer” values.

Thanks for the pointers! I’ll mention this as well.