Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   EasyC Timer and Gyro questions (http://www.chiefdelphi.com/forums/showthread.php?t=43128)

TubaMorg 01-02-2006 21:39

EasyC Timer and Gyro questions
 
I can't seem to figure out the answer for two things.

1. EasyC gyro code seems to work well, giving the correct heading when the robot is turned. However we would like to use the actual yaw rate...how can we access this data?

2. We tried to calculate yaw rate ourselves using one of the EasyC timers, however the timer doesn't seem to change. We start it in the Initialize block but subsequent calls return 0, thus we still can't get yaw rate.

We would rather just get yaw rate from the gyro but EasyC doesn't seem to allow this. The reason we want it is so we can use the yaw rate to control our drive better, so that straight stays straight and turns are constant. So if anyone has any ideas on how to do this, we would appreciate the advice!

TubaMorg 01-02-2006 22:05

Re: EasyC Timer and Gyro questions
 
Hmmm right after I posted my question I think I may have figured out the solution. We can access the gyro output directly with GetAnalogInput(1) which is, of course, the yaw rate, right? Have to wait til tomorrow to try it though. It just figures that after two hours of head scratching that it would be this easy (get it? EasyC!).

That just leaves me with the question of why the timer isn't timing?

In the Intialize block:
StartTimer(1)

In another function:

timer = GetTimer(1);
PrintToScreen ("Time is %ld\n", (long)timer);


I've tried various permutations of casting but get 0 almost every time. Sometimes, if I'm patient, it will go to 1. Any ideas? I should add all of this is taking place on the 2005 RC.

Chris_Elston 01-02-2006 23:16

Re: EasyC Timer and Gyro questions
 
Quote:

Originally Posted by TubaMorg
That just leaves me with the question of why the timer isn't timing?

In the Intialize block:
StartTimer(1)

In another function:

timer = GetTimer(1);
PrintToScreen ("Time is %ld\n", (long)timer);


Your not using it somewhere else are you?

In your "other function" is it in the "loop". A While Loop?

Your code looks ok to me. We haven't had any timer problems.

Try timer 6 for kicks and giggles....

TubaMorg 02-02-2006 00:20

Re: EasyC Timer and Gyro questions
 
Quote:

Originally Posted by chakorules
Your not using it somewhere else are you?

In your "other function" is it in the "loop". A While Loop?

Your code looks ok to me. We haven't had any timer problems.

Try timer 6 for kicks and giggles....


Yeah it is only being used once...I even tried it in the simple gyrotest code and still got nuthin. I guess I will try another one... since your no. 6 timer works, I will try it.

BradAMiller 02-02-2006 07:31

Re: EasyC Timer and Gyro questions
 
Quote:

Originally Posted by TubaMorg
I can't seem to figure out the answer for two things.

1. EasyC gyro code seems to work well, giving the correct heading when the robot is turned. However we would like to use the actual yaw rate...how can we access this data?

As you said in your other post, you can retrieve the raw yaw rate just polling the gyro analog port directly. It returns 12.5mv/deg/sec of rotation. The analog to digital converter returns a value from 0-1024 for the range of 0-5000mv. So by doing some arithmetic, you can create a function that returns the actual rate of rotation directly.

Quote:

Originally Posted by TubaMorg
I can't seem to figure out the answer for two things.
2. We tried to calculate yaw rate ourselves using one of the EasyC timers, however the timer doesn't seem to change. We start it in the Initialize block but subsequent calls return 0, thus we still can't get yaw rate.

Can you try putting in a print statement when the timer is started and another when you are reading the timer just to verify that it is being started? Also, are you doing a Preset operation on the timer anywhere in your code that might be getting unintentionally executed repeatedly?

TubaMorg 02-02-2006 09:17

Re: EasyC Timer and Gyro questions
 
Quote:

Originally Posted by BradAMiller
As you said in your other post, you can retrieve the raw yaw rate just polling the gyro analog port directly. It returns 12.5mv/deg/sec of rotation. The analog to digital converter returns a value from 0-1024 for the range of 0-5000mv. So by doing some arithmetic, you can create a function that returns the actual rate of rotation directly.


Can you try putting in a print statement when the timer is started and another when you are reading the timer just to verify that it is being started? Also, are you doing a Preset operation on the timer anywhere in your code that might be getting unintentionally executed repeatedly?

I will add a print statement for when the timer is started. I assume you mean to use a GetTimer right after initialization? Also there is no PresetTimer call in the code anywhere.

TubaMorg 02-02-2006 09:40

Re: EasyC Timer and Gyro questions
 
Quote:

Originally Posted by BradAMiller
As you said in your other post, you can retrieve the raw yaw rate just polling the gyro analog port directly. It returns 12.5mv/deg/sec of rotation. The analog to digital converter returns a value from 0-1024 for the range of 0-5000mv. So by doing some arithmetic, you can create a function that returns the actual rate of rotation directly.


Can you try putting in a print statement when the timer is started and another when you are reading the timer just to verify that it is being started? Also, are you doing a Preset operation on the timer anywhere in your code that might be getting unintentionally executed repeatedly?


So for the gyro yaw rate, we are using a 300 deg/sec gyro, so 5 mv/deg/sec. However, the ADC still returns 0-1024 right? It's just a matter of scaling (which we've implemented for heading conversion).

BradAMiller 02-02-2006 10:54

Re: EasyC Timer and Gyro questions
 
Quote:

Originally Posted by TubaMorg
So for the gyro yaw rate, we are using a 300 deg/sec gyro, so 5 mv/deg/sec. However, the ADC still returns 0-1024 right? It's just a matter of scaling (which we've implemented for heading conversion).

Sorry about that... I was assuming you were using the kit gyro.

You are correct, if you use a different gyro, then just look at the gyro spec. And the ADC will return a 10 bit value between 0-1023 (1024 possible values).

Dillon Compton 04-02-2006 00:33

Re: EasyC Timer and Gyro questions
 
My team is interested in using a slightly more accurate gyro than the one in the KoP...80deg/sec probably wont be enough to do what we want it to do. Can anyone give me an idea of where to start with the code needed in easy C to do this? We plan on using one from the same manufacturer, can I still drag and drop or do I need to write an original function? What is the relationship between yaw rate (the 0-1024 number, I assume?), and degrees rotation?

Thanks,
Dillon

BradAMiller 04-02-2006 17:52

Re: EasyC Timer and Gyro questions
 
Quote:

Originally Posted by Dillon Compton
My team is interested in using a slightly more accurate gyro than the one in the KoP...80deg/sec probably wont be enough to do what we want it to do. Can anyone give me an idea of where to start with the code needed in easy C to do this? We plan on using one from the same manufacturer, can I still drag and drop or do I need to write an original function? What is the relationship between yaw rate (the 0-1024 number, I assume?), and degrees rotation?

Thanks,
Dillon

It turns out you can use the existing block and just scale the output. Check out this thread (down at the bottom).

MarkVH 09-02-2006 19:43

Re: EasyC Timer and Gyro questions
 
does the gyro function in easyc return the angle in radians or degrees?
This is my first time using a gyro.

TubaMorg 09-02-2006 21:19

Re: EasyC Timer and Gyro questions
 
Quote:

Originally Posted by MarkVH
does the gyro function in easyc return the angle in radians or degrees?
This is my first time using a gyro.

The EasyC call GetGyroAngle(port number) returns the heading in tenths of a degree. Check out the Help section in EasyC. It does a good job of explaining how each of the EasyC functions work.


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

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