Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Problems with the Gyro (http://www.chiefdelphi.com/forums/showthread.php?t=50173)

Guy_E 29-11-2006 14:03

Problems with the Gyro
 
Hi,
I started to learn how to use the gyro. I downloaded Kevin's code from the internet and tried to use it. There are some things which I haven't understood completely.
I tried to print the variable "gyro_rate", but its values were between 1800-2200.
Shouldn't it be much lower? Shouldn't this variable be measuring the angular velocity in (radians/seconds)? I don't know if there is something wrong with the code, or something wrong with my understanding. I then tried to print the value from the function Get_Gyro_Angle(), but again, the printed values were unreasonable. The value jumped from positive to negative numbers without any logical order.

I would be very glad if someone could guide me through it.

Thanks,
Guy

neilsonster 29-11-2006 14:13

Re: Problems with the Gyro
 
Quote:

Originally Posted by Guy_E
Hi,
I started to learn how to use the gyro. I downloaded Kevin's code from the internet and tried to use it. There are some things which I haven't understood completely.
I tried to print the variable "gyro_rate", but its values were between 1800-2200.
Shouldn't it be much lower? Shouldn't this variable be measuring the angular velocity in (radians/seconds)? I don't know if there is something wrong with the code, or something wrong with my understanding. I then tried to print the value from the function Get_Gyro_Angle(), but again, the printed values were unreasonable. The value jumped from positive to negative numbers without any logical order.

I would be very glad if someone could guide me through it.

Thanks,
Guy

I haven't used the gyro code in a little over a year, but if I remember right the angular unit used in Kevin Watson's gyro code is milliradians, not radians. You should also be able to change it to tenths of a degree in the gyro.h file. That would at least explain the large numbers you were getting.

Sorry I don't know the complete answer to your question, but it's a start.

JamesBrown 29-11-2006 14:33

Re: Problems with the Gyro
 
Hey, I don't have the code in front of me but I can look at it when I get back to my dorm.

For your First question neilsonster is right about the units. That would explain the large numbers 1.8 radians per second is alot easier to explain than 1800. I am assuming that the values you are giving us are when the robot is at rest if this is not the case then please specify what you are doing to the robot while it is printing out the data. If the robot is just sitting there than your problem is probably in the initialization of the gyro. When you enable the robot let it sit for a second or two, also make sure the gyro isn't too close to the compressor or anything else that may cause it to vibrate. If this doesn't help then give us any more information that you can and I'll try again.

Guy_E 29-11-2006 14:47

Re: Problems with the Gyro
 
The value of "gyro_rate" is about 2030 while not moving. When I do rotate the gyro the value decreases or increases depending on the direction. My guess is that the gyro is somehow not calibrated or initialized well, but I don't know how to make it correct....

Noah Kleinberg 29-11-2006 18:08

Re: Problems with the Gyro
 
That sounds like a problem with the bias. You should try calling Get_Gyro_Bias() and printing the return value, which I think should be something relatively close to 512 if I remember correctly, also make sure that you called Initialize_Gyro() at some point in the code, otherwise it might be the case that the variable holding the bias was never initialized, and contains a random number, offsetting all of your data by that number.

eshteyn 29-11-2006 21:51

Re: Problems with the Gyro
 
hey , whats up, ask our programmer Dan about the gyro, we put one in Rambo last year and Dan has some great experience with it, good luck.

Guy_E 30-11-2006 06:12

Re: Problems with the Gyro
 
Quote:

Originally Posted by Noah Kleinberg
That sounds like a problem with the bias. You should try calling Get_Gyro_Bias() and printing the return value, which I think should be something relatively close to 512 if I remember correctly, also make sure that you called Initialize_Gyro() at some point in the code, otherwise it might be the case that the variable holding the bias was never initialized, and contains a random number, offsetting all of your data by that number.

I printed Get_Gyro_Bias ans the outcome was 0. What does this value represent? I call Initialize_Gyro in User_Initialization, where Kevin located it.

chris31 30-11-2006 07:04

Re: Problems with the Gyro
 
Quote:

Originally Posted by Noah Kleinberg
That sounds like a problem with the bias. You should try calling Get_Gyro_Bias() and printing the return value, which I think should be something relatively close to 512 if I remember correctly, also make sure that you called Initialize_Gyro() at some point in the code, otherwise it might be the case that the variable holding the bias was never initialized, and contains a random number, offsetting all of your data by that number.

I havent used to gyro but if i recall it is supposed to be 512 for the x and 512 for the y when they gyro isnt moving. Then then you start moving it values will vary from 0 to 1023.

Guy_E 30-11-2006 07:05

Re: Problems with the Gyro
 
Any idea what the problem could be?

EHaskins 30-11-2006 11:54

Re: Problems with the Gyro
 
Do you have your code calling the StartGyroCalibration() and StopGyroCalibration()?

If you tried to integrate Kevin's code into your own code you might not be initializing the gyro correctly. Look at the ProcessDataFromMasteruP() in Kevin's code.

aviv 30-11-2006 13:57

Re: Problems with the Gyro
 
You need to set the gyro's bias.. You do this by using the Start_Gyro_Bias_Calc() and
Stop_Gyro_Bias_Calc(). Let The start_bias_calc() run for a few secs while the robot isn't moving.

If you need anymore help u can email me at avivgalon@gmail.com

I haven't seen you for a while... (Samur)

6600gt 30-11-2006 16:32

Re: Problems with the Gyro
 
Quote:

Originally Posted by Guy_E
The value of "gyro_rate" is about 2030 while not moving. When I do rotate the gyro the value decreases or increases depending on the direction. My guess is that the gyro is somehow not calibrated or initialized well, but I don't know how to make it correct....

If you are using Kevin Watson's code, Get_Gyro_Angle is giving you the actual calculated angle 1800 is 180.0 degrees. He removed the decimal to help the pic process faster(it sucks at floating point stuff).

The actual gyro only outputs the angular rate but his code integrates to give you the actual angle at that point in time.

Read the "Readme" file that came with the gyro code. It should help you setup and calibrate the whole gyro.

Guy_E 01-12-2006 07:35

Re: Problems with the Gyro
 
I'm such a fool. I forgot that there was code executed in the Process_Data_From_Master_uP function, and I worked with the gyro with the RC turned off...

When I did work with the RC switched on, the gyro's bias was indeed calculated, but its value was 2040.... As a consequence, I believe, the angle and the angular rate were not calculated correctly.

Any idea how can I correct it?

Guy_E 02-12-2006 09:52

Re: Problems with the Gyro
 
Please, someone?

EHaskins 02-12-2006 10:19

Re: Problems with the Gyro
 
Try running a "clean" copy of kevin's code . Then if the gyro acts correctly you'll know its your code. If it still has problems it could be a hardware issue.


All times are GMT -5. The time now is 02:07.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi