For this kind of action, you will use the Get Angle VI. This offers you more precision than simply telling the motors to drive together at the same rate to move forward. You may want to use the gyro output to accurately track your robot's direction of travel so that you drive straight, or rotate to the right angle. There are several use-cases for using the gyro output in your code. I've left the default value of “My Gyro RefNum” but you can change this to whatever you want. Right click on the “refnum name” pin on the Registry Set VI and click “Create -> Constant” and create a unique name that you will use to refer to this gyro in the rest of your code. Now you need to assign a name to your gyro. ![]() Then, connect the GyroDevRef pin on the Open VI to the GyroDevRef on the Registry Set VI. Grab the Registry Set VI from the Gyro palette and place to the right of your Open VI. Now you need to assign a reference name to this gyro so that you can refer to it in other VIs. Unless you are using the CS Jumper version of the gyro and want to use C1 or C2 by moving the jumper, do not change this variable! LabVIEW will automatically assign the gyro to CS0, which is the default. Right click on the “ SPI Bus” pin on the Open VI and click “Create -> Constant” to insert an enumerated variable. Next, you need to tell LabVIEW which SPI “chip select” (CS) it will be using. Select “XRS450 SPI Open” to tell your robot that you're working with the ADXRS450 board. When you first bring the instance into your code, it will default to an analog gyro, so you will need to change the type using the drop-down menu below the VI's icon. It doesn't matter where you place it in this VI. Bring the Gyro Open VI into your Begin.vi code. You can find the gyro VI under WPI Robotics Library -> Sensors -> Gyro. The first step is to create a new instance of the gyro, then assign a reference name to it so that you can call the gyro reference anywhere in your robot code. This can be found in the project window under Team Code. Open your robot project, or create a new one if you don't have one created already, and open up your Begin.vi block diagram.
0 Comments
Leave a Reply. |