|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
[FTC]: Deadbands (axis/motor power restrictions)
Hello fellow programmers!
I am currently working on finding a solution to a probable bug which in being a programmer for the last 2 years never occurred. The base joystick to motor control has a bug in it. 4wd Code:
motor[motorD]=joystick.joy1_y1; motor[motorE]=joystick.joy1_y2; motor[motorF]=joystick.joy1_y2; motor[motorG]=joystick.joy1_y1; |
|
#2
|
|||
|
|||
|
Re: [FTC]: Deadbands (axis/motor power restrictions)
Here is the code we've used to create deadbands:
Code:
if((joystick.joy1_y1 < 5) && (joystick.joy1_y1 > -5)) joystick.joy1_y1 = 0; motor[motorD]=joystick.joy1_y1; |
|
#3
|
|||
|
|||
|
Re: [FTC]: Deadbands (axis/motor power restrictions)
I dont have it right here, but ours is something like:
Code:
// since joysticks return -127 to 127 values, and since motors react in a
// rance of -100 to 100, this function adds a midpoint deadband and
// adjusts the speed to be within the expected range.
int deadband(int invalue)
{
// if the value is between -27 and 27 then use
// that as the deadband and return 0
if (abs(invalue) < 27) return 0;
// if the value is negative, add 27 to bring the (-27 to -127) to (0 to -100)
if (invalue < 0) return invalue + 27;
// if the value is not > 27 then it already exited, so - 27 and return
return invalue - 27;
}
task main()
{
motor[motorA] = deadband(joystick.joy1_y1);
motor[motorB] = deadband(joystick.joy1_x1);
motor[motorC] = deadband(joystick.joy1_y2);
motor[motorD] = deadband(joystick.joy1_x2);
}
|
|
#4
|
|||||
|
|||||
|
Re: [FTC]: Deadbands (axis/motor power restrictions)
Quote:
![]() I'll just see what works best I may end up going with the other idea too but thank you for your help. John Fogarty GForce 3864 |
|
#5
|
||||
|
||||
|
Re: [FTC]: Deadbands (axis/motor power restrictions)
Another way to do it is
Code:
int threshold = 12; motor[motorD] = (abs(joystick.joy1_y1) >= threshold) * joystick.joy1_y1; ... Last edited by coollog : 04-11-2010 at 19:09. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Will a 1/3 horse power sump pump motor burn up at half power? | Weird Al/ Tony | Motors | 46 | 09-04-2010 21:11 |
| Axis Camera Power polarity | hurtzmyhead | Electrical | 4 | 03-02-2010 09:21 |
| Axis 206 Camera Power Supply | EricWilliams | FRC Control System | 1 | 02-02-2010 17:18 |
| Axis Camera 206 Power Connection | Matt2081 | Electrical | 7 | 24-01-2010 15:51 |
| axis camera power cable falling out.. | dani190 | Electrical | 7 | 19-02-2009 13:55 |