Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Getting speed from an encoder (http://www.chiefdelphi.com/forums/showthread.php?t=100248)

ProgrammerMatt 14-01-2012 23:27

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?

davidthefat 14-01-2012 23:32

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;
    }


ProgrammerMatt 14-01-2012 23:35

Re: Getting speed from an encoder
 
Great thanks, will try this out soon

Edit:
where do you get the currentTime function?

techkid86 14-01-2012 23:39

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 ^_^

ProgrammerMatt 14-01-2012 23:42

Re: Getting speed from an encoder
 
Quote:

Originally Posted by techkid86 (Post 1105811)
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 :)


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

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