Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Adjust individual motor speed (http://www.chiefdelphi.com/forums/showthread.php?t=105116)

Butter's 27-03-2012 11:28

Adjust individual motor speed
 
Quick question. I've checked the library and I am unable to find a function that allows me to change an individual motor speed. I read some where that you can do this with Smart Dashboard but it's too late for us to implement that now. Also, I need to set these values is teleop.

Anyone know how do go about doing this?

virtuald 27-03-2012 12:20

Re: Adjust individual motor speed
 
Create an object, call Set() on it.

Code:


// some global somewhere...
Jaguar my_motor(2);

..

// in your main loop
my_motor.Set( 1.0 );  // full speed in one direction
my_motor.Set( -1.0 ); // full speed in another direction

However, I suspect that is not what you're asking. If you want to control the motor using some external input, then the easiest thing is just pass the value retrieved from a joystick.

Code:


// some global somewhere
Joystick stick;

...

// in your main loop
my_motor.Set( stick.GetY() );


Butter's 27-03-2012 14:06

Re: Adjust individual motor speed
 
Quote:

Originally Posted by virtuald (Post 1150094)
Create an object, call Set() on it.

Code:


// some global somewhere...
Jaguar my_motor(2);

..

// in your main loop
my_motor.Set( 1.0 );  // full speed in one direction
my_motor.Set( -1.0 ); // full speed in another direction

However, I suspect that is not what you're asking. If you want to control the motor using some external input, then the easiest thing is just pass the value retrieved from a joystick.

Code:


// some global somewhere
Joystick stick;

...

// in your main loop
my_motor.Set( stick.GetY() );



Thank you so much! I actually needed the first one. Our robot has a slight curve so I wanted to make one robot have a little more power than the other (Not joystick based).

I'll go test out a few different values and tell you if it works out!

EDIT: The first method you gave us would move the robot, the second would just control it. Could I maybe make a function that would automatically (Time based) use the .Set method? It would only turn on if your driving with that stick.

Code:

public void fixCurve(bool x){
while(x == true){
wait(2.0);
rightmotor.Set(whateverTheNumberWouldBe);
}

(X is made true when the robot drives and false when they stop)

EDIT: My function would work but we need a formula to determine the speed so this itself doesn't cause a curve..... FUN!

virtuald 27-03-2012 15:11

Re: Adjust individual motor speed
 
Don't use Wait() to implement a timing delay. Use the timer class instead.

Ether 27-03-2012 15:35

Re: Adjust individual motor speed
 
Quote:

Originally Posted by Butter's (Post 1150150)
Our robot has a slight curve so I wanted to make one robot [ed: motor?] have a little more power than the other

First and foremost, you want to determine if there is an alignment or friction problem in your drivetrain, or a resistance problem in your wiring, that is causing this. For example, see this post. If you find a problem, it is far better to correct it at the source.

Secondly, What kind of drivetrain do you have, and what is your driver interface? I ask because there may be better ways to compensate.



Butter's 27-03-2012 15:42

Re: Adjust individual motor speed
 
Quote:

Originally Posted by Ether (Post 1150204)
First and foremost, you want to determine if there is an alignment or friction problem in your drivetrain, or a resistance problem in your wiring, that is causing this. For example, see this post. If you find a problem, it is far better to correct it at the source.

Secondly, What kind of drivetrain do you have, and what is your driver interface? I ask because there may be better ways to compensate.



I probably could answer your questions, however, I would rather talk to one of the team members on the build committee first before I throw out possibly incorrect information.


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

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