Go to Post Anyone who makes a minibot that poots out another minibot that blows the wall apart deserves to have it displayed in the Smithsonian. - Koko Ed [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 13-02-2015, 00:06
Fry42guy Fry42guy is offline
fryguy
FRC #3275 (The Regulators)
Team Role: Leadership
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Cass lake mn
Posts: 4
Fry42guy is an unknown quantity at this point
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.
Reply With Quote
  #2   Spotlight this post!  
Unread 13-02-2015, 00:32
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,679
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
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.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #3   Spotlight this post!  
Unread 13-02-2015, 00:41
Fry42guy Fry42guy is offline
fryguy
FRC #3275 (The Regulators)
Team Role: Leadership
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Cass lake mn
Posts: 4
Fry42guy is an unknown quantity at this point
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.
Reply With Quote
  #4   Spotlight this post!  
Unread 13-02-2015, 08:11
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,679
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
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
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #5   Spotlight this post!  
Unread 13-02-2015, 10:36
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Encoders and rpm

Quote:
Originally Posted by Fry42guy View Post
i have two motors that i want to sync in auto. mode ... program one wheel to spin at 30 rpm ... do the same for the other wheel
Have you considered an alternative approach: program the two motors to make the same number of turns, while remaining synchronized?


Reply With Quote
  #6   Spotlight this post!  
Unread 13-02-2015, 10:42
Rakusan2 Rakusan2 is offline
Registered User
AKA: Tomas Rakusan
FRC #3571 (Milton Mustangs)
Team Role: Programmer
 
Join Date: May 2014
Rookie Year: 2011
Location: Milton, ON, Canada
Posts: 22
Rakusan2 is an unknown quantity at this point
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);
	Timer time = new Timer();
	Talon motor1 = new Talon(0), motor2 = new Talon(1);
	public void autonomousInit(){
		time.start();
		leftEncoder.reset();
		rightEncoder.reset();
	}
	public void autonomousPeriodic() {
    		if(time.get() < 5){
    			double left=0.8 , right=0.8;
    			int dif = leftEncoder.get()-rightEncoder.get();
    			if (dif>0){
    				left-=0.1;
    				right+=0.1;
    			}
    			else if(dif<0){
    				left+=0.1;
    				right-=0.1;
    			}
    			motor1.set(left);
    			motor2.set(right);
    		}
	}
Reply With Quote
  #7   Spotlight this post!  
Unread 13-02-2015, 10:46
Ozuru's Avatar
Ozuru Ozuru is offline
It's always the programmer's fault.
no team
 
Join Date: May 2013
Rookie Year: 2010
Location: Earth
Posts: 268
Ozuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to behold
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():
public void clearEncoder() {
		_leftEncoder.reset();
		_rightEncoder.reset();
}

While you're in your drive train subsystem, go ahead and create getter methods for your encoders.

public double getRightDistance() {
		return _rightEncoder.getDistance();
}
In your initialize, you want to clear the encoders.

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
double left = Robot._driveTrain.getLeftDistance();
    	double right = Robot._driveTrain.getRightDistance();
    	double distance = Math.abs(left) > Math.abs(right) ? left : right;
    	if(_forw) {
    		return distance >= _distance;
    	} else {
    		return distance <= _distance;
}
That's how the general layout of your program should be if you want to drive for a distance.
Reply With Quote
  #8   Spotlight this post!  
Unread 13-02-2015, 12:37
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
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


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 18:03.

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