View unanswered posts | View active topics It is currently Sat Apr 30, 2016 1:16 am

 Page 1 of 1 [ 5 posts ]
 Print view Previous topic | Next topic
Angular rotation using Dexter Gyroscope
Author Message
Rookie

Joined: Thu Mar 01, 2012 11:01 pm
Posts: 3
Angular rotation using Dexter Gyroscope
Hi,
I want to get angular rotation using a Dexter gyro but I have more 5-10 degree error in 90 degrees rotation.
This is how I use dps to get rotation:
 Code:DIMUconfigGyro(DIMU, DIMU_GYRO_RANGE_2000);float x_val, y_val, z_val;  while (true){    static int time_temp = 0;    static float total = 0;         // Read the GYROSCOPE    DIMUreadGyroAxes(DIMU, x_val, y_val, z_val);           short loop_delay = nPgmTime-time_temp;    time_temp = nPgmTime;    total += x_val/(1000.0/loop_delay); //  x_val/(1000/50) won't be accurate.         nxtDisplayBigTextLine(4, "Rotation:%f", total);     wait1Msec(50);  }

I'm not sure if that's the correct way to get rotation. If that's the correct way, I guess the inaccuracy is related to third last line of my code. If I divide x_val by a number near 17 the error reduces to 1-2 degrees. (1000.0/loop_delay)=18.5 approx.

Please tell me if I am doing something wrong.
Thanks,

Mon Apr 23, 2012 4:09 am
Expert

Joined: Thu Sep 29, 2011 11:09 pm
Posts: 184
Location: Michigan USA
Re: Angular rotation using Dexter Gyroscope
For an integration loop, it's best to loop as quickly as possible (maybe a 5ms wait). Also, I think using the 250 dps range will give you much higher resolution.

_________________
Matt

Mon Apr 23, 2012 1:19 pm
Rookie

Joined: Thu Mar 01, 2012 11:01 pm
Posts: 3
Re: Angular rotation using Dexter Gyroscope
 mattallen37 wrote:For an integration loop, it's best to loop as quickly as possible (maybe a 5ms wait). Also, I think using the 250 dps range will give you much higher resolution.

5ms wait doesn't make any improvement to 50ms.
with 250dps range, with gyro being static, the rotation starts to increase or decrease very fast. 2000dps gives much lower error in this case.

p.s : If i manually rotate the unit 90 degrees. total x_val will be 1520-1540. 1530/90 gives us 17 and if I divide x_val by 17 the output gets accurate.
Now the problem is that output keeps increasing or decreasing with respect to the direction of last rotation. I assume that happens to all gyroscopes..

Tue Apr 24, 2012 11:53 pm
Guru

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Re: Angular rotation using Dexter Gyroscope
You should not initialize time_temp to zero. That would introduce a random error to your integration because nPgmTime doesn't start at zero. Instead you need to do this:
 Code:DIMUconfigGyro(DIMU, DIMU_GYRO_RANGE_2000);float x_val, y_val, z_val;float total = 0;int time_temp = nPgmTime;  while (true){        // Read the GYROSCOPE    DIMUreadGyroAxes(DIMU, x_val, y_val, z_val);           short loop_delay = nPgmTime-time_temp;    time_temp = nPgmTime;    total += x_val/(1000.0/loop_delay); //  x_val/(1000/50) won't be accurate.         nxtDisplayBigTextLine(4, "Rotation:%f", total);     wait1Msec(50);  }

There may be some other issues with the calculation but not knowing the spec of the gyroscope you are using, I wouldn't know.

Wed Apr 25, 2012 3:22 am
Rookie

Joined: Thu Mar 01, 2012 11:01 pm
Posts: 3
Re: Angular rotation using Dexter Gyroscope
 MHTS wrote:You should not initialize time_temp to zero. That would introduce a random error to your integration because nPgmTime doesn't start at zero. Instead you need to do this:...There may be some other issues with the calculation but not knowing the spec of the gyroscope you are using, I wouldn't know.

That's correct. The code i wrote does not take into account the time before starting the loop.

Thanks for the tip !

Thu Apr 26, 2012 10:09 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 5 posts ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning