Archive for September, 2010

28
Sep
10

FRC LabVIEW Programming – more basics

LabVIEW is a Graphical Programming Language. As a programming language it has a lot of the constructs as text based languages but also has a lot of features that make it easier to use. It also has things to keep in mind when you’re programming.

First thing to remember is that LabVIEW is a data flow language. What that means is that a block has to have all its connected data inputs ready before it executes. Also, there is no guarantee of order of execution of the blocks unless they are wired from one to another. In the example below, block 1 will not put out its output until the two inputs are both ready. Also, with block 2 and block 3, there is no way to tell for sure which block will execute first.

The main way to sequence blocks is to use the error wires to sequence the blocks as shown below.

Above, since all of the inputs have to be at the block before it executes, since the output of block 2 goes to block 3, this will force block 2 to execute before block 3.
Another important item that you need to be aware of is that Loops are threads. What that means is that each loop executes independent of each other and executes at the same time…as far as you’re concerned. An excellent use of this feature for your FRC Code is one loop waiting for a button to be pushed to kick while another loop is taking Joystick inputs to drive the robot. The two loops below both run at the same time and would see no difference in execution. One thing to remember is to put “wait” blocks in the loops. Without the wait blocks other loops may not have any time to execute because one is taking up all the processor time. In the example below, without the wait block in the loop with the button read all that would be going on is the processor waiting on buttons the joystick. The loop with the joystick read would only run occasionally and you would see a lot of sluggishness in the movement of the Robot.

Another important construct in any programming language is the state machine. The state machine allows the robot to do one step, once complete, do the next, then do the next, etc. This is great for the autonomous mode where you want to do a sequence of steps. Such as move forward, stop, kick, move forward again, etc.

The pictures below show a simplistic state machine example with 3 states and an idle state (state 0). In the Begin block (in robot main) you would initialize the State Number.vi with a 1. Then once you start executing the loop the state machine is in it would execute the case #1. Of course you would actually need to do something where below I just say to do something. It may be drive the motors forward for a certain amount of time. The true/false case inside the state case should have the output of something with the output of false if not complete and true if the operation is complete. Once the operation is complete a 2 would be output and put into the state number.vi.

Once the state number is 2 then the state case 2 would be executed. Notice the true/false case shown in the picture below shows the false case. What this shows is that if the operation not complete (i.e. a false is output) the state case number stays at 2. And again, once whatever operation is complete and a true is fed into the true/false case, the case number would be changed to 3 (not shown below).

Once the state case is 3, again some actions are performed. Since 3 is the last case we have, once the operation is completed a 0 is put into the state number.

In this case we do nothing else we would just stay in case 0. In this case there is no way to move to another case without re-starting.

Now that I’ve talked about LabVIEW and some concepts of programming, next week, I’m going to go back and talk about some LabVIEW navigation and short cuts that are helpful.

Advertisements
20
Sep
10

FRC LabVIEW Programming Basics

Before you learn the basics of LabVIEW you need to load LabVIEW onto your computer. Your not going to learn any programming language without practice. To many people approach it like they can do it for 1 hour a week and understand or do it well, and they can’t.

OK, time to get off my soapbox and dig in. LabVIEW is the graphical programming language Bill Gates talked about about 10 years ago but has gone unnoticed by many programmers. I think it’s because it’s hard to hack with it…not that I’ve tried, much.

However, it is highly useful and the FRC kit-bot comes with an out of the package driver system. It’s easy to understand so it’s a great starting place. Just remember to right-click.

I’m not going over the basic basics here, it would take to long and to much typing. I’m going to assume you know how to start LabVIEW, create a new project. and create a new Vi. (hint: after clicking on the LabVIEW icon look for the word “new”) I’ll just call the Vi’s blocks from here on out. Each block is a function (in text based equivalent terms)

In 2010 there was an item under the menu that would create a new starting robot control program. Starting with the robot main, you’ll see loops and blocks everywhere. Hit <ctrl+h> and when you hover over a block developed by NI a small window in the corner somewhere that will give you information on the block. Inputs and outputs, what it’s used for, things like that. NI usually has pretty good documentation.

Robot Main

If you’re curious on how a block works, double click it and it will open up another block diagram. This block diagram is the LabVIEW program for that block. If you click another block, it will open up another block diagram. At some point you won’t be able to go down any further. But you can see how each block is made.

To learn programming, you need to play around, try new things, you’re not going to break anything. However, once you deploy to the cRio on your robot, then something might break.

LabVIEW doesn’t have to run on your robot. If you create a new block (hint: click on “New Vi” that has no FRC block on it you can run that block by itself. Once you put blocks on the you new block from the WPI Robotics Library pallet, it may run, it may not.

Robot lib

To add FRC blocks, right click on a blank area of a block diagram, expand the list, and look near the bottom of the list. Hover over the line that says WPI Robotics Library and it will bring up a set FRC blocks. I’ll talk more about these later.

Have fun and Happy Robotics!

12
Sep
10

FRC Preseason

All FIRST Robotics teams know that Robot season is from the first Saturday of January to mid-April. That is from the FRC Kickoff to the Championships.  It’s what we all look forward to and work toward. That makes this time of year the Robotics pre-season. It’s when FRC teams are getting the team together, getting finances together for the upcoming Robot season, and, I hope, getting prepared fro the Robot season

This is the time of year every one should be learning about Robotics. For us Super Nerds, this a really exciting time, we get to experiment, play, and learn. At this time everyone should start learning the mechanics of Robots, how things are put together, how the electronics work, and how to program.

I have found the programming the least understood part of robotics. The robots come with a default program that allows a driver to move the robot around the field. But that is just the start of what can be done.

There are two major goals when thinking of the programming, the autonomous mode and aiding the driver. In order to do either or both of these the teams must understand how to program. It’s not something you can  just start doing when you get the kit of parts. You need to be learning about it before the season starts to be any good at it. It’s something that you have to work at over time. That’s whey there’s so many jokes about programmers having no life.

So the goal of most every FRC team during the preseason should be learning about programming. Get out the computer you put LabVIEW on last year and play with it. Try adding to the program you had on last years robot and improving it. Or start from a new project and build something new and different.

Just play with it….And start Now!

Over the next few weeks I’m going to be talking about the programming, sensors, and some about electronics. I hope it will be helpful.

07
Sep
10

FIRST Introduction

I just want to introduce myself in this first post. I’m a Super Nerd, a FIRST fanatic, and a Robot Enthusiast. I mainly mentor FRC team 704. Phil Harris, team 704 coach and architect, introduced me to FIRST Robotics. Prior to his introduction I was mainly into Artificial Intelligence. I’m still interested in AI but with FIRST, I also get to work with students and get their fresh perspectives on everything. I’m also working with the FIRST Lego League (FLL) team 2293. We’re just getting started and I’m just now learning about FLL.

What I do to pay the bills is work at Lockheed Martin. I have a degree in Math from the University of Texas at Arlington. I started my career as a Software Engineer. Later I was a Real-Time Simulations Engineer and a Systems Engineer. I’m currently a Test Engineer. AI and Complexity is my hobby, yes, a very nerdy hobby.

My goal in this blog is to help teams with technical issues, especially software. I’ve found that software and sensors tends to e the most lacking in FRC robots with the younger teams…and some of the more established teams.

Kids are our future! When I get old I want to make sure there are competent people ensuring my long life. I also want competent people ensuring the continued existence of the human race. Kids are our future, we need to help guide them into that future. FIRST is a great vehicle to guide the kids to the future.