FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Gyro Response Time is Slow

Solved!
Go to solution

I'm programing in LabVIEW 2011 for the 2012 US First Robotics Competition while also using the FRC cRIO and the FRC cRIO II robot controller. I'm trying to add a gyro to our robot project to work with our mecanum drive train so we can try the frisbee driving affect, allowing us to drive with orientation to the field instead of the robot. However, When I call my "get angle.vi" in teleop to get the current angle, it only updates about 1 a sec rather than updating immedently. When I run the Gyro Example from the NI Example Finder, it updates much quicker like how I need it to be.

I'm not sure what in the code is causing the delay. I've attempted to put the "get angle.vi" in the 10ms section of "Periodic Task.vi", have it update a global variable and then read that global variable in teleop but that is just as slow as getting it directly from teleop.

Does anyone have gotchas or anything else I might be able to check to resolve this issue and make the robot more responsive? Does Anyone know a little more on how to check the performance of that actual code?

0 Kudos
Message 1 of 6
(5,685 Views)

Hey william_edds,

Would you be able to post your project in a .zip file? You can see how fast your loop rate is running by looking at the charts page of the Driver Station. It sounds like something in teleop is dramatically slowing down your loop time.

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 2 of 6
(3,632 Views)

Attached my project. In addition to that, I believe I fiound what is cauing the issue delay but I'm not sure how to correct it.

I used Diagram Disable Structures to disable parts of the code in teleop and tested. I found that when I disabled the code that set the output to my motors (CAN Motors) that my program was a lot more responsive. When I re-enabled that code, it was slow again. In the error log for my driver station, I find several of the following:

ERROR <Code> -44087 occurred at NetComm_CAN_Send.vi:26

FRC:  JaguarCANDriver timed out waiting to receive a response from a Jaguar.

Now, I currently have my jags disconnected. However, even when I have them connected I still get the same errors. I'm not sure whats wrong with my CAN bus that would be causing this error. I'm using the 2CAN Bus Adapter (version 2) and I have a terminator in my last jag that has a 120 Ohm resistor as per the 2CAN user manual.

0 Kudos
Message 3 of 6
(3,632 Views)

If you open the webdash to the 2CAN, you can see if the CAN bus is working.  Don't leave it open, though...the webdash causes the 2CAN to drop packets from the cRIO.

0 Kudos
Message 4 of 6
(3,632 Views)

Hey william_edds,

The timeout definitely explains the slow loop rate. How familiar are you with setting up a CAN system? If you don't have a lot of experience with CAN I would recommend just using the PWM control for the jaguars. That being said this post has some information about possible solutions for 2CAN timeouts:http://www.chiefdelphi.com/forums/showthread.php?t=99898

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 5 of 6
(3,632 Views)
Solution
Accepted by william_edds

I solved it in the simplest way. I actually hooked up the CAN bus. All the time I was working with the gyro (and other things) with the CAN Bus not connected and I didn't know it wasn't. Once I connected the 2CAN adapter back in and then connected the jags to it, everything started responding quickly and correctly.

The moral of the story: Once you go CAN Bus, make sure you have CAN Bus everytime!

0 Kudos
Message 6 of 6
(3,632 Views)