|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Gyro angle will not work with robot code
I am trying to get an angle from the gyro and I am able to get the sample code to work. But when I try to use the sample code on the robot code it just outputs a constantly increasing number from 0-360. I attached the code below. Can anyone tell me why this is happening?
|
|
#2
|
|||||
|
|||||
|
Re: Gyro angle will not work with robot code
You didn't set the gyro gain. Try this:
![]() |
|
#3
|
||||
|
||||
|
Re: Gyro angle will not work with robot code
I copied your code and it is still constantly increase but this time by a smaller number.
|
|
#4
|
|||||
|
|||||
|
Re: Gyro angle will not work with robot code
The spec sheet for the gyro you are using should list a value for "voltage per degree of rotation per second", use the value they list for the gain.
When the cRIO is first booted, you know you must not touch the robot while the gyro initializes? That's how it decides what zero is. |
|
#5
|
||||
|
||||
|
Re: Gyro angle will not work with robot code
Quote:
|
|
#6
|
||||
|
||||
|
Re: Gyro angle will not work with robot code
It is to the forth decimal place and moving the gyro doesn't do anything.
|
|
#7
|
||||
|
||||
|
Re: Gyro angle will not work with robot code
Quote:
|
|
#8
|
||||
|
||||
|
Re: Gyro angle will not work with robot code
I can't take a picture of it until tonight. However, I know the wiring is correct because I loaded the sample code on the robot and it ran fine and gave me the angles I wanted.
|
|
#9
|
||||
|
||||
|
Re: Gyro angle will not work with robot code
Quote:
I just saw on another thread that you are intending to use the gyro for your shooter altitude angle. I think you want a potentiometer or encoder instead. |
|
#10
|
||||
|
||||
|
Re: Gyro angle will not work with robot code
I think an encoder would work best. I don't think a potentiometer came in the KOP. Do you have an idea of what would be best for a shooter that is going to only moving up and down in a range of 70 degrees?
|
|
#11
|
||||
|
||||
|
Re: Gyro angle will not work with robot code
Quote:
|
|
#12
|
||||
|
||||
|
Re: Gyro angle will not work with robot code
I don't think I have potentiometer but I can play with an encoder.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|