Go to Post I <3 statistics. - Barry Bonzack [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 14-01-2012, 23:27
ProgrammerMatt ProgrammerMatt is offline
Programmer-Electrical-Mechanical
FRC #0228 (Gus)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Southington
Posts: 138
ProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really nice
Getting speed from an encoder

I want to be able to get the speed of the robot from a quad-encoder what would i have to do to convert the ticks into a speed unit?
Reply With Quote
  #2   Spotlight this post!  
Unread 14-01-2012, 23:32
davidthefat davidthefat is offline
Alumni
AKA: David Yoon
FRC #0589 (Falkons)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: California
Posts: 792
davidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud of
Re: Getting speed from an encoder

Code:
private double[] getRPM()
    {
        double rpm[] = new double[2];                                               //Declares an array of integers which the function will return.
        currentTime = time.get();                                                   //Sets currentTime to the time calculatged from FPGA
        rpm[0] = leftEncoder.getRaw() * 16666666.666666 / currentTime;              //dAngle*(60000000us/360deg)/dTime = RPM
        rpm[1] = rightEncoder.getRaw() * 16666666.666666 / currentTime;             //dAngle*(60000000us/360deg)/dTime = RPM
        leftEncoder.reset();                                                        //Resets the left wheel encoder.
        rightEncoder.reset();                                                       //Resets the right wheel encoder.
        time.reset();                                                               //This resets the timer.
        return rpm;
    }
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.
Reply With Quote
  #3   Spotlight this post!  
Unread 14-01-2012, 23:35
ProgrammerMatt ProgrammerMatt is offline
Programmer-Electrical-Mechanical
FRC #0228 (Gus)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Southington
Posts: 138
ProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really nice
Re: Getting speed from an encoder

Great thanks, will try this out soon

Edit:
where do you get the currentTime function?

Last edited by ProgrammerMatt : 14-01-2012 at 23:37.
Reply With Quote
  #4   Spotlight this post!  
Unread 14-01-2012, 23:39
techkid86's Avatar
techkid86 techkid86 is offline
Magic Programer
FRC #3044 (0xBE4)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: ballston spa
Posts: 58
techkid86 is an unknown quantity at this point
Re: Getting speed from an encoder

i am not sure if this will give the same result, but the WPI libs already have an encoder class, and it can give rate in distance. theoretically this is the same, but what ever. im not sure if you are writing your own, but, if you want just he encoder funtions, they are as follows.

Encoder.setDistancePerPulse(x);
Encoder.getRate();

not sure what you wanted but i hope i could help ^_^ good luck ^_^
__________________
"you can build a perfect machine out of imperfect parts" -Urza
Reply With Quote
  #5   Spotlight this post!  
Unread 14-01-2012, 23:42
ProgrammerMatt ProgrammerMatt is offline
Programmer-Electrical-Mechanical
FRC #0228 (Gus)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Southington
Posts: 138
ProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really nice
Re: Getting speed from an encoder

Quote:
Originally Posted by techkid86 View Post
i am not sure if this will give the same result, but the WPI libs already have an encoder class, and it can give rate in distance. theoretically this is the same, but what ever. im not sure if you are writing your own, but, if you want just he encoder funtions, they are as follows.

Encoder.setDistancePerPulse(x);
Encoder.getRate();

not sure what you wanted but i hope i could help ^_^ good luck ^_^
Thankyou ill try both
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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