FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with getting Gyro Data using gyro.vi

Solved!
Go to solution

We are a rookie team and have tried using the Gyro.vi to read Gyro data, but always just get the first reading and no further readings. We have connected the Gyro in as an analog input and have designated it as such. When we put in the Gyro input as a Straight analog input using the Analog Inupt VI, we see the voltage on the Gyro changing to appropriate value when we move it, so we know the sensor is operating correctly. Putting in the gyro example code causes us to get no changes in the heading from the Gyro.

So a couple of questions:

1. We currently have the code to read the gyro in the Periodic Tasks section of the code in the 10 msec loop. Is this the best place for it? It seemed that placing it in the Teleop section would not cause it to be read at a constant periodic interval.

2. Are there any known problems with the gyro.vi that comes with LabView? We are to the point where we will start pulling off intermediate values from it as it appears broken, but wanted to know if others have seen this problem and worked around it.

3. Are there problems with the Gyro example code?

Just wanted to ask before we start pulling apart the gyro.vi code as rookies....

0 Kudos
Message 1 of 10
(10,884 Views)

Hey Kenneth,

When you tested using the Gyro example code did you run it in the project provided with the example or did you move it into your robot code first. There are no known issues with the gyro example- I have spoken to a couple teams who have used it successfully. If you are running the example without any changes to it and not seeing heading changes I would suspect some kind of hardware issue but it seems like you have verified the sensor is working correctly already.

Kevin Fort
Principal Software Engineer
NI
Message 2 of 10
(6,712 Views)

The gyro LabVIEW code works. I helped 5 teams in the area and all five got the gyro example to work.

Have you tried the gyro example that shipped with the FRC LabVIEW?

Post your team code so we can see what you are doing.

I spect you are closing the ref to the gyro after the first read

Where you put the gyro code depends alot on what you are doing with it.

Yes there is a gyro example under the FRC\Sensors heading

Under the Help menu the is a "Find Examples"

Under the Support Tab of the FRC "Getting Started" screen there is a "Find FRC Examples"

Omar
Message 3 of 10
(6,712 Views)

We tried the Gyro example project as a standalone project (after changing the CRIO ip address). The gyro example would not load properly on the CRIO.

We can retry it again and post the specific place in the load where it fails.

We also tried embedding all the code from the Gyro example into the Periodic Task.vi and it would not gather data. We had used the same approach for the Untrasonic Sensor and it works correctly.

0 Kudos
Message 4 of 10
(6,712 Views)

I strongly suggest getting the Gyro example working first to verify your wiring and the Gyro are all working. Then try to cut the code into your robot code. What errors are you getting when you try to run the Gyro Example?

What Analog channel is the Gyro connected to and did you set the front panel controls to match? Analog Module 1 Channel AI1 or AI2

Which Gyro do you have? See the notes on the front panel of the Gyro Example about wiring the Gyro.

Maybe the Gyro itself is bad?

With the Gyro power on check the connections at the Gyro with a meter...

Ground to 5V - should see 5 volts

Ground to Rate - should see "about" 2.5 volts (could be anything from 2 to 3 volts. Maybe anything from 1 to 4 volts. Depends if you are moving the gyro when you measure it.

Is there 12 volts wired to the Analog Breakout? Is the Power Good LED on the Analog Breakout lit? Do you see your battery voltage in the driver station?

Once you are getting readings from the Gyro, the Gain (Volts per Degree per Second) will need to be set for the Gyro that you are using. Check the data sheet for your Gyro.

I think it will be .007 V/Deg/Sec

Omar
0 Kudos
Message 5 of 10
(6,712 Views)

The Gyro was connected to AI1. When AI 1 was setup using the plain Analog Input.vi, it showed 2.5V at steady state and when rotated it would vary from 1.5V to 3.5V depending on the direciton and how fast it was rotated. So the Gyro HW and Analog input is working correctly and all the wiring is correct.

We had set the Gyro for 0.007V/Deg/Sec as a calabration level, matching the Gyro Spec sheet.

We will retry the Gryo Example and post the error tomorrow.

Thanks!

0 Kudos
Message 6 of 10
(6,712 Views)

We were able to get the Gyro Example working. It turns out that a change had been made to one of the Gyro VIs causing to not work. On examining the dates of the Gyro VIs we could see which one of the Gyro VIs had been changed.

So with the Gyro Example working and putting in the right scaling factor for the Gyro, we were able to see 90 degrees outputs for 90 degrees turns. So the Gyro hardware, Gyro Example and Gyro VIs appear to work.

We then copied the Gyro example code into the Periodic Tasks.vi and deleted the Open and Close of Communications, much as we had used the copied Examples for analog inputs and Ultrasonic Sensors. We still get a constant reading on the output of the Gyro no matter how much we turn it. When I put an output of the loop counter to the display, I see it continuing to count, showing that the gyro loop is continuing to run and that it has not encountered an error.

Here is our full Robot Code Project

0 Kudos
Message 7 of 10
(6,712 Views)
Solution
Accepted by KennethO

We are also using Analog Inputs for an Ultrasonic Sensor (AI3) and a Switch Sensor (AI2). Are there complications in using the Gyro when other Analog inputs are used?

I was going to create and test with a version of our code with the Ultrasonic Sensor and Switch Sensor removed to see if they are causing issues.

0 Kudos
Message 8 of 10
(6,712 Views)

Could you send me the VI?

0 Kudos
Message 9 of 10
(6,712 Views)

The VI they were using likely won't be of any use to you.  This thread predates the change from cRIO to roboRIO.  I'd have to look at the internals to know if it works smoothly with a change of hardware.

Instead, you should install it the same way the people here did.  If you go to www.ni.com/frc, you'll see four big images to help you find your away around the site.  Choose Getting Started.  At the top of that page, you'll see a big green button to download software.

The link on the left installs all of the LabVIEW software you'll need as a base installation.  The Update Suite on the right includes all of the extra tools and VIs for FRC (to include the gyro VI and any included examples).  You'll need this to program your robot.

0 Kudos
Message 10 of 10
(6,712 Views)