![]() |
Encoders and rpm
How do i set the rpms of a motor using an encoder. the encoder is connected to the roborio d i/o, i am using can for the jaguars and programming in java.
|
Re: Encoders and rpm
Wow. What an open question.
The first thing you need to decide is "what is it that you're trying to achieve?" If you're considering an encoder, you should have some goal in mind that isn't easily met by just letting a practiced driver have a proportional joystick. |
Re: Encoders and rpm
i have two motors that i want to sync in auto. mode, i have little knowledge of programming encoders. my thoughts, if i can program one wheel to spin at 30 rpm i could just do the same for the other wheel... basically i want to know how to program motor1.setspeed(30rpm); if there is such a thing.
|
Re: Encoders and rpm
Look at extending PIDSubsystem. There's a lot of info on PIDs at this thread. You could also search CD for "PID" and "Drive" together and check threads. I have never used an encoder on a drive system, but they certainly can be effective.
search CD for PID Drive One thread found in that search that may be helpful |
Re: Encoders and rpm
Quote:
|
Re: Encoders and rpm
If you only want to keep the motors in sync and would not mind not knowing the rpm then you can try something like what I have bellow.
PS: I have not yet tried this code so you might want to play with the initial motor values and by how much they are changed Code:
Encoder leftEncoder = new Encoder(0,1), rightEncoder = new Encoder(2,3); |
Re: Encoders and rpm
I have a DriveForDistance method that uses encoders. I'm assuming you're using command based. Think of what you want to do:
1. Clear the current count of the encoders Code:
I recommend you create a method in your driveTrain called clearEncoders():In your execute, you want to tell the motors to go the appropriate direction that the robot should be moving. In your isFinished: Code:
// code from Joe 2729 |
Re: Encoders and rpm
Let's say you want to go from position P=0 to P=Pf in autonomous Ideally, you'd want your control algorithm to do something like this: 1) ramp the speed up vs time (to limit acceleration to an acceptable level to avoid wheel slip or excessive rocking of the vehicle) until the desired top speed is reached, then hold that speed until you are within distance L of the desired stopping point (i.e. P=Pf-L). 2) then ramp the speed down as a function of L (to avoid excessive deceleration), so that speed=0 when L=0 (i.e P=Pf). 3) all the while keeping the encoder counts synchronized between the left and right motors |
| All times are GMT -5. The time now is 10:37. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi