Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   speed controller max speed (http://www.chiefdelphi.com/forums/showthread.php?t=34510)

Team 668 12-02-2005 17:50

speed controller max speed
 
we were testing our robot and we realized that the mototrs are way to sensitive. how do we make the max speed on the speed controllers from 255 to around 200. what is the code for that. whenever we use the triggers the robots moves and we dont want that. HELP!!!! thanks.

Team 668 12-02-2005 18:53

Re: speed controller max speed
 
any help plz. i kind of need the answer as quick as possible

whakojacko 12-02-2005 18:57

Re: speed controller max speed
 
yay for fellow San Jose Team. What you need to do is add a limit to the pwm values that are being sent to the speed controllers.
For instance
(insert x for the pwm number)

if(pwmX >= 200)
{
pwmX=200;
}

or

pwmX= pwmX >=200 ? 200 : pwmX;

We also added a dead band where any value +30 or the middle 127 on the joystick will not make the motors move since the joysticks are so sensitive

AIBob 12-02-2005 18:59

Re: speed controller max speed
 
You could one of three basic things:
You could use a formula to squish things in, which may take longer, but consume less space
or you could use a lookup table, which would take less time, but consume more space.
Or you could just cut everything off after 200, which is small and takes little time.
Here is a an example fomula one:
Code:

unsigned int Limit(unsigned int pwmin)
{
unsigned int tmppwm = 0;
tmppwm = (unsigned int)(((pwmin-127)*72)/127) + 127);
return (tmppwm+127);
}


Team 668 13-02-2005 12:48

Re: speed controller max speed
 
how do u set the dead band because the joysticks are really sensitive? thanks for your help

AIBob 13-02-2005 12:54

Re: speed controller max speed
 
Quote:

Originally Posted by Team 668
how do u set the dead band because the joysticks are really sensitive? thanks for your help

I think this is what you mean:
Code:

unsigned int DeadLimit(unsigned int pwmin)
{
if(((pwmin-127) && 0x7F) >15 ) return pwmin;
else return 127;
}

Which would make anything from 112 to 142 all to 127.

Team 668 13-02-2005 13:04

Re: speed controller max speed
 
it comes up with an error on the line that has the " { " on it

AIBob 13-02-2005 13:06

Re: speed controller max speed
 
Quote:

Originally Posted by Team 668
it comes up with an error on the line that has the " { " on it

What does the error say?

Team 668 13-02-2005 13:11

Re: speed controller max speed
 
error: syntax eror c:233. it says it when i compile it. on line 233 is the " { " after:

unsigned int deadlimit (unsigned int pwmin)
{ <--- that is where the error is

AIBob 13-02-2005 13:22

Re: speed controller max speed
 
It might be because you left a bracket open from another peice of code earlier in the code..

If that is not the problem... it might be that you did not define
"unsigned int DeadLimit(unsigned int pwmin);" in an h file for referring to it in anotehr piece of code.

Team 668 13-02-2005 13:23

Re: speed controller max speed
 
nvm that i figured it out but now it says pwmin has not been defined. do i just do #define or do io have to define it a different wway. thanks a lot for your help.

AIBob 13-02-2005 13:25

Re: speed controller max speed
 
Quote:

Originally Posted by Team 668
nvm that i figured it out but now it says pwmin has not been defined. do i just do #define or do io have to define it a different wway. thanks a lot for your help.

no you do not need to use a define....
you should just call it as a function like so:
Code:

pwm01 = deadlimit(pwm01);
or something like that...

The pwmin is defined by the function...
be sure that you define:
"unsigned int DeadLimit(unsigned int pwmin);"
inside of an h file that you have included in it.

Team 668 13-02-2005 13:38

Re: speed controller max speed
 
Quote:

Originally Posted by AIBob
no you do not need to use a define....
you should just call it as a function like so:
Code:

pwm01 = deadlimit(pwm01);
or something like that...

The pwmin is defined by the function...
be sure that you define:
"unsigned int DeadLimit(unsigned int pwmin);"
inside of an h file that you have included in it.

so i should add unsigned int deadlimit ..... into and h file and then the

"{
if (((pwm-127) && 0x7f >15) return pwmin
else return 127;
}"

into user_routines.c. where do i put the pwm01 = deadlimit(pwm01)?

Team 668 13-02-2005 13:41

Re: speed controller max speed
 
im really confused right now. so if you could right it out in a post that would be really appreciated.

Team 668 13-02-2005 13:57

Re: speed controller max speed
 
is there an easier way to do this because it to compile but then when it gets to the 3rd stage it says : could not find definition of symbol deadlimit in file user_routines.o

AIBob 13-02-2005 14:05

Re: speed controller max speed
 
Quote:

Originally Posted by Team 668
into user_routines.c. where do i put the pwm01 = deadlimit(pwm01)?

you would put "pwm01 = deadlimit(pwm01);" into the code right before you are outputting inside of function User_Driver() in user_routines.c...
Quote:

Originally Posted by Team 668
is there an easier way to do this

Yes...
You could just forget about a function and just do the code like this:
Code:

if (((pwm01-127) && 0x7f <=15) pwm01=127;
and just replace the 01 with whatever pwms you want to put out to....

I forgot about another way you could do it...
Which is just do the same for the joystick... like so:
Code:

if ((((signed int)p1_x-127) && 0x7f <=15) p1_x=127;
if ((((signed int)p1_y-127) && 0x7f <=15) p1_y=127;



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

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